You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2018/10/26 21:11:11 UTC

[01/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Repository: hive
Updated Branches:
  refs/heads/master-tez092 8151911b4 -> c55347d52


http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query89.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query89.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query89.q.out
new file mode 100644
index 0000000..673050e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query89.q.out
@@ -0,0 +1,178 @@
+PREHOOK: query: explain
+select  *
+from(
+select i_category, i_class, i_brand,
+       s_store_name, s_company_name,
+       d_moy,
+       sum(ss_sales_price) sum_sales,
+       avg(sum(ss_sales_price)) over
+         (partition by i_category, i_brand, s_store_name, s_company_name)
+         avg_monthly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+      ss_sold_date_sk = d_date_sk and
+      ss_store_sk = s_store_sk and
+      d_year in (2000) and
+        ((i_category in ('Home','Books','Electronics') and
+          i_class in ('wallpaper','parenting','musical')
+         )
+      or (i_category in ('Shoes','Jewelry','Men') and
+          i_class in ('womens','birdal','pants') 
+        ))
+group by i_category, i_class, i_brand,
+         s_store_name, s_company_name, d_moy) tmp1
+where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
+order by sum_sales - avg_monthly_sales, s_store_name
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  *
+from(
+select i_category, i_class, i_brand,
+       s_store_name, s_company_name,
+       d_moy,
+       sum(ss_sales_price) sum_sales,
+       avg(sum(ss_sales_price)) over
+         (partition by i_category, i_brand, s_store_name, s_company_name)
+         avg_monthly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+      ss_sold_date_sk = d_date_sk and
+      ss_store_sk = s_store_sk and
+      d_year in (2000) and
+        ((i_category in ('Home','Books','Electronics') and
+          i_class in ('wallpaper','parenting','musical')
+         )
+      or (i_category in ('Shoes','Jewelry','Men') and
+          i_class in ('womens','birdal','pants') 
+        ))
+group by i_category, i_class, i_brand,
+         s_store_name, s_company_name, d_moy) tmp1
+where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
+order by sum_sales - avg_monthly_sales, s_store_name
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 12 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_115]
+        Limit [LIM_114] (rows=100 width=801)
+          Number of rows:100
+          Select Operator [SEL_113] (rows=4804228 width=801)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_112]
+              Select Operator [SEL_111] (rows=4804228 width=801)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                Filter Operator [FIL_110] (rows=4804228 width=689)
+                  predicate:CASE WHEN ((avg_window_0 <> 0)) THEN (((abs((_col6 - avg_window_0)) / avg_window_0) > 0.1)) ELSE (null) END
+                  Select Operator [SEL_109] (rows=9608456 width=577)
+                    Output:["avg_window_0","_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                    PTF Operator [PTF_108] (rows=9608456 width=577)
+                      Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col2 ASC NULLS FIRST, _col0 ASC NULLS FIRST, _col4 ASC NULLS FIRST, _col5 ASC NULLS FIRST","partition by:":"_col2, _col0, _col4, _col5"}]
+                      Select Operator [SEL_107] (rows=9608456 width=577)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                      <-Reducer 5 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_106]
+                          PartitionCols:_col2, _col0, _col4, _col5
+                          Group By Operator [GBY_105] (rows=9608456 width=577)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                          <-Reducer 4 [SIMPLE_EDGE]
+                            SHUFFLE [RS_22]
+                              PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                              Group By Operator [GBY_21] (rows=27308180 width=577)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col3)"],keys:_col5, _col6, _col7, _col9, _col11, _col12
+                                Merge Join Operator [MERGEJOIN_83] (rows=27308180 width=480)
+                                  Conds:RS_17._col2=RS_104._col0(Inner),Output:["_col3","_col5","_col6","_col7","_col9","_col11","_col12"]
+                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_104]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_103] (rows=1704 width=183)
+                                      Output:["_col0","_col1","_col2"]
+                                      TableScan [TS_9] (rows=1704 width=183)
+                                        default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_company_name"]
+                                <-Reducer 3 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_17]
+                                    PartitionCols:_col2
+                                    Merge Join Operator [MERGEJOIN_82] (rows=27308180 width=301)
+                                      Conds:RS_14._col0=RS_94._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col7","_col9"]
+                                    <-Map 10 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_94]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_93] (rows=652 width=8)
+                                          Output:["_col0","_col1"]
+                                          Filter Operator [FIL_92] (rows=652 width=12)
+                                            predicate:(d_year = 2000)
+                                            TableScan [TS_6] (rows=73049 width=12)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                    <-Reducer 2 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_14]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_81] (rows=76480702 width=364)
+                                          Conds:RS_102._col1=RS_86._col0(Inner),Output:["_col0","_col2","_col3","_col5","_col6","_col7"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_86]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_85] (rows=6988 width=286)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_84] (rows=6988 width=286)
+                                                predicate:((((i_category) IN ('Home', 'Books', 'Electronics') and (i_class) IN ('wallpaper', 'parenting', 'musical')) or ((i_category) IN ('Shoes', 'Jewelry', 'Men') and (i_class) IN ('womens', 'birdal', 'pants'))) and (i_category) IN ('Home', 'Books', 'Electronics', 'Shoes', 'Jewelry', 'Men') and (i_class) IN ('wallpaper', 'parenting', 'musical', 'womens', 'birdal', 'pants'))
+                                                TableScan [TS_3] (rows=462000 width=286)
+                                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand","i_class","i_category"]
+                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_102]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_101] (rows=525329897 width=118)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_100] (rows=525329897 width=118)
+                                                predicate:((ss_item_sk BETWEEN DynamicValue(RS_12_item_i_item_sk_min) AND DynamicValue(RS_12_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_12_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_0] (rows=575995635 width=118)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_sales_price"]
+                                                <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_99]
+                                                    Group By Operator [GBY_98] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_97]
+                                                        Group By Operator [GBY_96] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_95] (rows=652 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_93]
+                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_91]
+                                                    Group By Operator [GBY_90] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_89]
+                                                        Group By Operator [GBY_88] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_87] (rows=6988 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_85]
+


[64/75] [abbrv] hive git commit: HIVE-20788: Extended SJ reduction may backtrack columns incorrectly when creating filters (Jesus Camacho Rodriguez, reviewed by Deepak Jaiswal)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/query23.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query23.q.out b/ql/src/test/results/clientpositive/perf/tez/query23.q.out
index 61d1dd7..7784792 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query23.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query23.q.out
@@ -1,7 +1,7 @@
-Warning: Shuffle Join MERGEJOIN[589][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 29' is a cross product
-Warning: Shuffle Join MERGEJOIN[590][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 30' is a cross product
-Warning: Shuffle Join MERGEJOIN[592][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 33' is a cross product
-Warning: Shuffle Join MERGEJOIN[593][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 34' is a cross product
+Warning: Shuffle Join MERGEJOIN[593][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 29' is a cross product
+Warning: Shuffle Join MERGEJOIN[594][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 30' is a cross product
+Warning: Shuffle Join MERGEJOIN[596][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 33' is a cross product
+Warning: Shuffle Join MERGEJOIN[597][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 34' is a cross product
 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
@@ -166,37 +166,37 @@ Stage-0
     limit:100
     Stage-1
       Reducer 6 vectorized
-      File Output Operator [FS_695]
-        Limit [LIM_694] (rows=1 width=112)
+      File Output Operator [FS_699]
+        Limit [LIM_698] (rows=1 width=112)
           Number of rows:100
-          Group By Operator [GBY_693] (rows=1 width=112)
+          Group By Operator [GBY_697] (rows=1 width=112)
             Output:["_col0"],aggregations:["sum(VALUE._col0)"]
           <-Union 5 [CUSTOM_SIMPLE_EDGE]
             <-Reducer 12 [CONTAINS]
-              Reduce Output Operator [RS_604]
-                Group By Operator [GBY_603] (rows=1 width=112)
+              Reduce Output Operator [RS_608]
+                Group By Operator [GBY_607] (rows=1 width=112)
                   Output:["_col0"],aggregations:["sum(_col0)"]
-                  Select Operator [SEL_601] (rows=1 width=112)
+                  Select Operator [SEL_605] (rows=1 width=112)
                     Output:["_col0"]
-                    Merge Join Operator [MERGEJOIN_600] (rows=1 width=116)
+                    Merge Join Operator [MERGEJOIN_604] (rows=1 width=116)
                       Conds:RS_248._col2=RS_249._col0(Inner),Output:["_col3","_col4"]
                     <-Reducer 11 [SIMPLE_EDGE]
                       PARTITION_ONLY_SHUFFLE [RS_248]
                         PartitionCols:_col2
-                        Merge Join Operator [MERGEJOIN_588] (rows=155 width=0)
-                          Conds:RS_245._col1=RS_638._col0(Inner),Output:["_col2","_col3","_col4"]
+                        Merge Join Operator [MERGEJOIN_592] (rows=155 width=0)
+                          Conds:RS_245._col1=RS_642._col0(Inner),Output:["_col2","_col3","_col4"]
                         <-Reducer 18 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_638]
+                          SHUFFLE [RS_642]
                             PartitionCols:_col0
-                            Group By Operator [GBY_635] (rows=2235 width=4)
+                            Group By Operator [GBY_639] (rows=2235 width=4)
                               Output:["_col0"],keys:_col1
-                              Select Operator [SEL_634] (rows=6548799 width=12)
+                              Select Operator [SEL_638] (rows=6548799 width=12)
                                 Output:["_col1"]
-                                Filter Operator [FIL_633] (rows=6548799 width=12)
+                                Filter Operator [FIL_637] (rows=6548799 width=12)
                                   predicate:(_col3 > 4L)
-                                  Select Operator [SEL_632] (rows=19646398 width=12)
+                                  Select Operator [SEL_636] (rows=19646398 width=12)
                                     Output:["_col0","_col3"]
-                                    Group By Operator [GBY_631] (rows=19646398 width=290)
+                                    Group By Operator [GBY_635] (rows=19646398 width=290)
                                       Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
                                     <-Reducer 17 [SIMPLE_EDGE]
                                       SHUFFLE [RS_24]
@@ -205,96 +205,96 @@ Stage-0
                                           Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
                                           Select Operator [SEL_21] (rows=19646398 width=282)
                                             Output:["_col0","_col1","_col2"]
-                                            Merge Join Operator [MERGEJOIN_573] (rows=19646398 width=282)
-                                              Conds:RS_18._col1=RS_630._col0(Inner),Output:["_col3","_col5","_col6"]
+                                            Merge Join Operator [MERGEJOIN_577] (rows=19646398 width=282)
+                                              Conds:RS_18._col1=RS_634._col0(Inner),Output:["_col3","_col5","_col6"]
                                             <-Map 23 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_630]
+                                              SHUFFLE [RS_634]
                                                 PartitionCols:_col0
-                                                Select Operator [SEL_629] (rows=462000 width=188)
+                                                Select Operator [SEL_633] (rows=462000 width=188)
                                                   Output:["_col0","_col1"]
-                                                  Filter Operator [FIL_628] (rows=462000 width=188)
+                                                  Filter Operator [FIL_632] (rows=462000 width=188)
                                                     predicate:i_item_sk is not null
                                                     TableScan [TS_12] (rows=462000 width=188)
                                                       default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_desc"]
                                             <-Reducer 16 [SIMPLE_EDGE]
                                               SHUFFLE [RS_18]
                                                 PartitionCols:_col1
-                                                Merge Join Operator [MERGEJOIN_572] (rows=19646398 width=98)
-                                                  Conds:RS_627._col0=RS_619._col0(Inner),Output:["_col1","_col3"]
+                                                Merge Join Operator [MERGEJOIN_576] (rows=19646398 width=98)
+                                                  Conds:RS_631._col0=RS_623._col0(Inner),Output:["_col1","_col3"]
                                                 <-Map 21 [SIMPLE_EDGE] vectorized
-                                                  PARTITION_ONLY_SHUFFLE [RS_619]
+                                                  PARTITION_ONLY_SHUFFLE [RS_623]
                                                     PartitionCols:_col0
-                                                    Select Operator [SEL_618] (rows=2609 width=102)
+                                                    Select Operator [SEL_622] (rows=2609 width=102)
                                                       Output:["_col0","_col1"]
-                                                      Filter Operator [FIL_617] (rows=2609 width=102)
+                                                      Filter Operator [FIL_621] (rows=2609 width=102)
                                                         predicate:((d_year) IN (1999, 2000, 2001, 2002) and d_date_sk is not null)
                                                         TableScan [TS_9] (rows=73049 width=102)
                                                           default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date","d_year"]
                                                 <-Map 15 [SIMPLE_EDGE] vectorized
-                                                  SHUFFLE [RS_627]
+                                                  SHUFFLE [RS_631]
                                                     PartitionCols:_col0
-                                                    Select Operator [SEL_626] (rows=550076554 width=7)
+                                                    Select Operator [SEL_630] (rows=550076554 width=7)
                                                       Output:["_col0","_col1"]
-                                                      Filter Operator [FIL_625] (rows=550076554 width=7)
+                                                      Filter Operator [FIL_629] (rows=550076554 width=7)
                                                         predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_16_date_dim_d_date_sk_min) AND DynamicValue(RS_16_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_16_date_dim_d_date_sk_bloom_filter))) and ss_item_sk is not null and ss_sold_date_sk is not null)
                                                         TableScan [TS_6] (rows=575995635 width=7)
                                                           default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk"]
                                                         <-Reducer 22 [BROADCAST_EDGE] vectorized
-                                                          BROADCAST [RS_624]
-                                                            Group By Operator [GBY_623] (rows=1 width=12)
+                                                          BROADCAST [RS_628]
+                                                            Group By Operator [GBY_627] (rows=1 width=12)
                                                               Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                             <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                              PARTITION_ONLY_SHUFFLE [RS_622]
-                                                                Group By Operator [GBY_621] (rows=1 width=12)
+                                                              PARTITION_ONLY_SHUFFLE [RS_626]
+                                                                Group By Operator [GBY_625] (rows=1 width=12)
                                                                   Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                  Select Operator [SEL_620] (rows=2609 width=4)
+                                                                  Select Operator [SEL_624] (rows=2609 width=4)
                                                                     Output:["_col0"]
-                                                                     Please refer to the previous Select Operator [SEL_618]
+                                                                     Please refer to the previous Select Operator [SEL_622]
                         <-Reducer 10 [SIMPLE_EDGE]
                           SHUFFLE [RS_245]
                             PartitionCols:_col1
-                            Merge Join Operator [MERGEJOIN_579] (rows=3941102 width=122)
-                              Conds:RS_702._col0=RS_609._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                            Merge Join Operator [MERGEJOIN_583] (rows=3941102 width=122)
+                              Conds:RS_706._col0=RS_613._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
                             <-Map 8 [SIMPLE_EDGE] vectorized
-                              PARTITION_ONLY_SHUFFLE [RS_609]
+                              PARTITION_ONLY_SHUFFLE [RS_613]
                                 PartitionCols:_col0
-                                Select Operator [SEL_606] (rows=50 width=12)
+                                Select Operator [SEL_610] (rows=50 width=12)
                                   Output:["_col0"]
-                                  Filter Operator [FIL_605] (rows=50 width=12)
+                                  Filter Operator [FIL_609] (rows=50 width=12)
                                     predicate:((d_moy = 1) and (d_year = 1999) and d_date_sk is not null)
                                     TableScan [TS_3] (rows=73049 width=12)
                                       default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
                             <-Map 44 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_702]
+                              SHUFFLE [RS_706]
                                 PartitionCols:_col0
-                                Select Operator [SEL_701] (rows=143930993 width=127)
+                                Select Operator [SEL_705] (rows=143930993 width=127)
                                   Output:["_col0","_col1","_col2","_col3","_col4"]
-                                  Filter Operator [FIL_700] (rows=143930993 width=127)
+                                  Filter Operator [FIL_704] (rows=143930993 width=127)
                                     predicate:((ws_item_sk BETWEEN DynamicValue(RS_246_item_i_item_sk_min) AND DynamicValue(RS_246_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_246_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_243_date_dim_d_date_sk_min) AND DynamicValue(RS_243_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_243_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_item_sk is not null and ws_sold_date_sk is not null)
                                     TableScan [TS_126] (rows=144002668 width=127)
                                       default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_customer_sk","ws_quantity","ws_list_price"]
                                     <-Reducer 14 [BROADCAST_EDGE] vectorized
-                                      BROADCAST [RS_697]
-                                        Group By Operator [GBY_696] (rows=1 width=12)
+                                      BROADCAST [RS_701]
+                                        Group By Operator [GBY_700] (rows=1 width=12)
                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                         <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
-                                          PARTITION_ONLY_SHUFFLE [RS_614]
-                                            Group By Operator [GBY_612] (rows=1 width=12)
+                                          PARTITION_ONLY_SHUFFLE [RS_618]
+                                            Group By Operator [GBY_616] (rows=1 width=12)
                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                              Select Operator [SEL_610] (rows=50 width=4)
+                                              Select Operator [SEL_614] (rows=50 width=4)
                                                 Output:["_col0"]
-                                                 Please refer to the previous Select Operator [SEL_606]
+                                                 Please refer to the previous Select Operator [SEL_610]
                                     <-Reducer 20 [BROADCAST_EDGE] vectorized
-                                      BROADCAST [RS_699]
-                                        Group By Operator [GBY_698] (rows=1 width=12)
+                                      BROADCAST [RS_703]
+                                        Group By Operator [GBY_702] (rows=1 width=12)
                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                         <-Reducer 18 [CUSTOM_SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_643]
-                                            Group By Operator [GBY_641] (rows=1 width=12)
+                                          SHUFFLE [RS_647]
+                                            Group By Operator [GBY_645] (rows=1 width=12)
                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                              Select Operator [SEL_639] (rows=2235 width=4)
+                                              Select Operator [SEL_643] (rows=2235 width=4)
                                                 Output:["_col0"]
-                                                 Please refer to the previous Group By Operator [GBY_635]
+                                                 Please refer to the previous Group By Operator [GBY_639]
                     <-Reducer 34 [SIMPLE_EDGE]
                       SHUFFLE [RS_249]
                         PartitionCols:_col0
@@ -302,29 +302,29 @@ Stage-0
                           Output:["_col0"]
                           Filter Operator [FIL_240] (rows=471875 width=228)
                             predicate:(_col3 > (0.95 * _col1))
-                            Merge Join Operator [MERGEJOIN_593] (rows=1415625 width=228)
+                            Merge Join Operator [MERGEJOIN_597] (rows=1415625 width=228)
                               Conds:(Inner),Output:["_col1","_col2","_col3"]
                             <-Reducer 33 [CUSTOM_SIMPLE_EDGE]
                               PARTITION_ONLY_SHUFFLE [RS_237]
-                                Merge Join Operator [MERGEJOIN_592] (rows=1 width=112)
+                                Merge Join Operator [MERGEJOIN_596] (rows=1 width=112)
                                   Conds:(Inner),Output:["_col1"]
                                 <-Reducer 32 [CUSTOM_SIMPLE_EDGE] vectorized
-                                  PARTITION_ONLY_SHUFFLE [RS_708]
-                                    Select Operator [SEL_707] (rows=1 width=8)
-                                      Filter Operator [FIL_706] (rows=1 width=8)
+                                  PARTITION_ONLY_SHUFFLE [RS_712]
+                                    Select Operator [SEL_711] (rows=1 width=8)
+                                      Filter Operator [FIL_710] (rows=1 width=8)
                                         predicate:(sq_count_check(_col0) <= 1)
-                                        Group By Operator [GBY_705] (rows=1 width=8)
+                                        Group By Operator [GBY_709] (rows=1 width=8)
                                           Output:["_col0"],aggregations:["count()"]
-                                          Select Operator [SEL_704] (rows=1 width=8)
-                                            Group By Operator [GBY_703] (rows=1 width=8)
+                                          Select Operator [SEL_708] (rows=1 width=8)
+                                            Group By Operator [GBY_707] (rows=1 width=8)
                                               Output:["_col0"],aggregations:["count(VALUE._col0)"]
                                             <-Reducer 27 [CUSTOM_SIMPLE_EDGE] vectorized
-                                              PARTITION_ONLY_SHUFFLE [RS_676]
-                                                Group By Operator [GBY_672] (rows=1 width=8)
+                                              PARTITION_ONLY_SHUFFLE [RS_680]
+                                                Group By Operator [GBY_676] (rows=1 width=8)
                                                   Output:["_col0"],aggregations:["count(_col0)"]
-                                                  Select Operator [SEL_668] (rows=11859 width=116)
+                                                  Select Operator [SEL_672] (rows=11859 width=116)
                                                     Output:["_col0"]
-                                                    Group By Operator [GBY_665] (rows=11859 width=116)
+                                                    Group By Operator [GBY_669] (rows=11859 width=116)
                                                       Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                                                     <-Reducer 26 [SIMPLE_EDGE]
                                                       SHUFFLE [RS_51]
@@ -333,65 +333,65 @@ Stage-0
                                                           Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
                                                           Select Operator [SEL_48] (rows=18762463 width=4)
                                                             Output:["_col0","_col1"]
-                                                            Merge Join Operator [MERGEJOIN_575] (rows=18762463 width=4)
-                                                              Conds:RS_45._col1=RS_663._col0(Inner),Output:["_col2","_col3","_col6"]
+                                                            Merge Join Operator [MERGEJOIN_579] (rows=18762463 width=4)
+                                                              Conds:RS_45._col1=RS_667._col0(Inner),Output:["_col2","_col3","_col6"]
                                                             <-Map 41 [SIMPLE_EDGE] vectorized
-                                                              SHUFFLE [RS_663]
+                                                              SHUFFLE [RS_667]
                                                                 PartitionCols:_col0
-                                                                Select Operator [SEL_661] (rows=80000000 width=4)
+                                                                Select Operator [SEL_665] (rows=80000000 width=4)
                                                                   Output:["_col0"]
-                                                                  Filter Operator [FIL_660] (rows=80000000 width=4)
+                                                                  Filter Operator [FIL_664] (rows=80000000 width=4)
                                                                     predicate:c_customer_sk is not null
                                                                     TableScan [TS_96] (rows=80000000 width=4)
                                                                       default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk"]
                                                             <-Reducer 25 [SIMPLE_EDGE]
                                                               SHUFFLE [RS_45]
                                                                 PartitionCols:_col1
-                                                                Merge Join Operator [MERGEJOIN_574] (rows=18762463 width=0)
-                                                                  Conds:RS_659._col0=RS_651._col0(Inner),Output:["_col1","_col2","_col3"]
+                                                                Merge Join Operator [MERGEJOIN_578] (rows=18762463 width=0)
+                                                                  Conds:RS_663._col0=RS_655._col0(Inner),Output:["_col1","_col2","_col3"]
                                                                 <-Map 36 [SIMPLE_EDGE] vectorized
-                                                                  PARTITION_ONLY_SHUFFLE [RS_651]
+                                                                  PARTITION_ONLY_SHUFFLE [RS_655]
                                                                     PartitionCols:_col0
-                                                                    Select Operator [SEL_650] (rows=2609 width=8)
+                                                                    Select Operator [SEL_654] (rows=2609 width=8)
                                                                       Output:["_col0"]
-                                                                      Filter Operator [FIL_649] (rows=2609 width=8)
+                                                                      Filter Operator [FIL_653] (rows=2609 width=8)
                                                                         predicate:((d_year) IN (1999, 2000, 2001, 2002) and d_date_sk is not null)
                                                                         TableScan [TS_36] (rows=73049 width=8)
                                                                           default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
                                                                 <-Map 24 [SIMPLE_EDGE] vectorized
-                                                                  SHUFFLE [RS_659]
+                                                                  SHUFFLE [RS_663]
                                                                     PartitionCols:_col0
-                                                                    Select Operator [SEL_658] (rows=525327388 width=118)
+                                                                    Select Operator [SEL_662] (rows=525327388 width=118)
                                                                       Output:["_col0","_col1","_col2","_col3"]
-                                                                      Filter Operator [FIL_657] (rows=525327388 width=118)
+                                                                      Filter Operator [FIL_661] (rows=525327388 width=118)
                                                                         predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_43_date_dim_d_date_sk_min) AND DynamicValue(RS_43_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_43_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
                                                                         TableScan [TS_33] (rows=575995635 width=118)
                                                                           default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_quantity","ss_sales_price"]
                                                                         <-Reducer 37 [BROADCAST_EDGE] vectorized
-                                                                          BROADCAST [RS_656]
-                                                                            Group By Operator [GBY_655] (rows=1 width=12)
+                                                                          BROADCAST [RS_660]
+                                                                            Group By Operator [GBY_659] (rows=1 width=12)
                                                                               Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                                             <-Map 36 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                                              PARTITION_ONLY_SHUFFLE [RS_654]
-                                                                                Group By Operator [GBY_653] (rows=1 width=12)
+                                                                              PARTITION_ONLY_SHUFFLE [RS_658]
+                                                                                Group By Operator [GBY_657] (rows=1 width=12)
                                                                                   Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                                  Select Operator [SEL_652] (rows=2609 width=4)
+                                                                                  Select Operator [SEL_656] (rows=2609 width=4)
                                                                                     Output:["_col0"]
-                                                                                     Please refer to the previous Select Operator [SEL_650]
+                                                                                     Please refer to the previous Select Operator [SEL_654]
                                 <-Reducer 35 [CUSTOM_SIMPLE_EDGE] vectorized
-                                  PARTITION_ONLY_SHUFFLE [RS_710]
-                                    Group By Operator [GBY_709] (rows=1 width=112)
+                                  PARTITION_ONLY_SHUFFLE [RS_714]
+                                    Group By Operator [GBY_713] (rows=1 width=112)
                                       Output:["_col0"],aggregations:["max(VALUE._col0)"]
                                     <-Reducer 27 [CUSTOM_SIMPLE_EDGE] vectorized
-                                      PARTITION_ONLY_SHUFFLE [RS_677]
-                                        Group By Operator [GBY_673] (rows=1 width=112)
+                                      PARTITION_ONLY_SHUFFLE [RS_681]
+                                        Group By Operator [GBY_677] (rows=1 width=112)
                                           Output:["_col0"],aggregations:["max(_col1)"]
-                                          Select Operator [SEL_669] (rows=11859 width=116)
+                                          Select Operator [SEL_673] (rows=11859 width=116)
                                             Output:["_col1"]
-                                             Please refer to the previous Group By Operator [GBY_665]
+                                             Please refer to the previous Group By Operator [GBY_669]
                             <-Reducer 43 [CUSTOM_SIMPLE_EDGE] vectorized
-                              PARTITION_ONLY_SHUFFLE [RS_717]
-                                Group By Operator [GBY_716] (rows=1415625 width=116)
+                              PARTITION_ONLY_SHUFFLE [RS_721]
+                                Group By Operator [GBY_720] (rows=1415625 width=116)
                                   Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                                 <-Reducer 42 [SIMPLE_EDGE]
                                   SHUFFLE [RS_231]
@@ -400,89 +400,89 @@ Stage-0
                                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
                                       Select Operator [SEL_228] (rows=550080312 width=114)
                                         Output:["_col0","_col1"]
-                                        Merge Join Operator [MERGEJOIN_586] (rows=550080312 width=114)
-                                          Conds:RS_715._col0=RS_664._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        Merge Join Operator [MERGEJOIN_590] (rows=550080312 width=114)
+                                          Conds:RS_719._col0=RS_668._col0(Inner),Output:["_col1","_col2","_col3"]
                                         <-Map 41 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_664]
+                                          SHUFFLE [RS_668]
                                             PartitionCols:_col0
-                                             Please refer to the previous Select Operator [SEL_661]
+                                             Please refer to the previous Select Operator [SEL_665]
                                         <-Map 45 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_715]
+                                          SHUFFLE [RS_719]
                                             PartitionCols:_col0
-                                            Select Operator [SEL_714] (rows=550080312 width=114)
+                                            Select Operator [SEL_718] (rows=550080312 width=114)
                                               Output:["_col0","_col1","_col2"]
-                                              Filter Operator [FIL_713] (rows=550080312 width=114)
+                                              Filter Operator [FIL_717] (rows=550080312 width=114)
                                                 predicate:((ss_customer_sk BETWEEN DynamicValue(RS_248_web_sales_ws_bill_customer_sk_min) AND DynamicValue(RS_248_web_sales_ws_bill_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_248_web_sales_ws_bill_customer_sk_bloom_filter))) and ss_customer_sk is not null)
                                                 TableScan [TS_219] (rows=575995635 width=114)
                                                   default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_customer_sk","ss_quantity","ss_sales_price"]
                                                 <-Reducer 13 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_712]
-                                                    Group By Operator [GBY_711] (rows=1 width=12)
+                                                  BROADCAST [RS_716]
+                                                    Group By Operator [GBY_715] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Reducer 11 [CUSTOM_SIMPLE_EDGE]
-                                                      PARTITION_ONLY_SHUFFLE [RS_562]
-                                                        Group By Operator [GBY_561] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_570]
+                                                        Group By Operator [GBY_569] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_560] (rows=155 width=0)
+                                                          Select Operator [SEL_568] (rows=155 width=0)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_588]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_592]
             <-Reducer 4 [CONTAINS]
-              Reduce Output Operator [RS_599]
-                Group By Operator [GBY_598] (rows=1 width=112)
+              Reduce Output Operator [RS_603]
+                Group By Operator [GBY_602] (rows=1 width=112)
                   Output:["_col0"],aggregations:["sum(_col0)"]
-                  Select Operator [SEL_596] (rows=1 width=112)
+                  Select Operator [SEL_600] (rows=1 width=112)
                     Output:["_col0"]
-                    Merge Join Operator [MERGEJOIN_595] (rows=1 width=116)
+                    Merge Join Operator [MERGEJOIN_599] (rows=1 width=116)
                       Conds:RS_122._col1=RS_123._col0(Inner),Output:["_col3","_col4"]
                     <-Reducer 3 [SIMPLE_EDGE]
                       PARTITION_ONLY_SHUFFLE [RS_122]
                         PartitionCols:_col1
-                        Merge Join Operator [MERGEJOIN_587] (rows=304 width=0)
-                          Conds:RS_119._col2=RS_636._col0(Inner),Output:["_col1","_col3","_col4"]
+                        Merge Join Operator [MERGEJOIN_591] (rows=304 width=0)
+                          Conds:RS_119._col2=RS_640._col0(Inner),Output:["_col1","_col3","_col4"]
                         <-Reducer 18 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_636]
+                          SHUFFLE [RS_640]
                             PartitionCols:_col0
-                             Please refer to the previous Group By Operator [GBY_635]
+                             Please refer to the previous Group By Operator [GBY_639]
                         <-Reducer 2 [SIMPLE_EDGE]
                           SHUFFLE [RS_119]
                             PartitionCols:_col2
-                            Merge Join Operator [MERGEJOIN_571] (rows=7751875 width=101)
-                              Conds:RS_648._col0=RS_607._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                            Merge Join Operator [MERGEJOIN_575] (rows=7751875 width=101)
+                              Conds:RS_652._col0=RS_611._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
                             <-Map 8 [SIMPLE_EDGE] vectorized
-                              PARTITION_ONLY_SHUFFLE [RS_607]
+                              PARTITION_ONLY_SHUFFLE [RS_611]
                                 PartitionCols:_col0
-                                 Please refer to the previous Select Operator [SEL_606]
+                                 Please refer to the previous Select Operator [SEL_610]
                             <-Map 1 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_648]
+                              SHUFFLE [RS_652]
                                 PartitionCols:_col0
-                                Select Operator [SEL_647] (rows=285117831 width=127)
+                                Select Operator [SEL_651] (rows=285117831 width=127)
                                   Output:["_col0","_col1","_col2","_col3","_col4"]
-                                  Filter Operator [FIL_646] (rows=285117831 width=127)
+                                  Filter Operator [FIL_650] (rows=285117831 width=127)
                                     predicate:((cs_item_sk BETWEEN DynamicValue(RS_120_item_i_item_sk_min) AND DynamicValue(RS_120_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_120_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_117_date_dim_d_date_sk_min) AND DynamicValue(RS_117_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_117_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_item_sk is not null and cs_sold_date_sk is not null)
                                     TableScan [TS_0] (rows=287989836 width=127)
                                       default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_quantity","cs_list_price"]
                                     <-Reducer 19 [BROADCAST_EDGE] vectorized
-                                      BROADCAST [RS_645]
-                                        Group By Operator [GBY_644] (rows=1 width=12)
+                                      BROADCAST [RS_649]
+                                        Group By Operator [GBY_648] (rows=1 width=12)
                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                         <-Reducer 18 [CUSTOM_SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_642]
-                                            Group By Operator [GBY_640] (rows=1 width=12)
+                                          SHUFFLE [RS_646]
+                                            Group By Operator [GBY_644] (rows=1 width=12)
                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                              Select Operator [SEL_637] (rows=2235 width=4)
+                                              Select Operator [SEL_641] (rows=2235 width=4)
                                                 Output:["_col0"]
-                                                 Please refer to the previous Group By Operator [GBY_635]
+                                                 Please refer to the previous Group By Operator [GBY_639]
                                     <-Reducer 9 [BROADCAST_EDGE] vectorized
-                                      BROADCAST [RS_616]
-                                        Group By Operator [GBY_615] (rows=1 width=12)
+                                      BROADCAST [RS_620]
+                                        Group By Operator [GBY_619] (rows=1 width=12)
                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                         <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
-                                          PARTITION_ONLY_SHUFFLE [RS_613]
-                                            Group By Operator [GBY_611] (rows=1 width=12)
+                                          PARTITION_ONLY_SHUFFLE [RS_617]
+                                            Group By Operator [GBY_615] (rows=1 width=12)
                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                              Select Operator [SEL_608] (rows=50 width=4)
+                                              Select Operator [SEL_612] (rows=50 width=4)
                                                 Output:["_col0"]
-                                                 Please refer to the previous Select Operator [SEL_606]
+                                                 Please refer to the previous Select Operator [SEL_610]
                     <-Reducer 30 [SIMPLE_EDGE]
                       SHUFFLE [RS_123]
                         PartitionCols:_col0
@@ -490,43 +490,43 @@ Stage-0
                           Output:["_col0"]
                           Filter Operator [FIL_114] (rows=471875 width=228)
                             predicate:(_col3 > (0.95 * _col1))
-                            Merge Join Operator [MERGEJOIN_590] (rows=1415625 width=228)
+                            Merge Join Operator [MERGEJOIN_594] (rows=1415625 width=228)
                               Conds:(Inner),Output:["_col1","_col2","_col3"]
                             <-Reducer 29 [CUSTOM_SIMPLE_EDGE]
                               PARTITION_ONLY_SHUFFLE [RS_111]
-                                Merge Join Operator [MERGEJOIN_589] (rows=1 width=112)
+                                Merge Join Operator [MERGEJOIN_593] (rows=1 width=112)
                                   Conds:(Inner),Output:["_col1"]
                                 <-Reducer 28 [CUSTOM_SIMPLE_EDGE] vectorized
-                                  PARTITION_ONLY_SHUFFLE [RS_683]
-                                    Select Operator [SEL_682] (rows=1 width=8)
-                                      Filter Operator [FIL_681] (rows=1 width=8)
+                                  PARTITION_ONLY_SHUFFLE [RS_687]
+                                    Select Operator [SEL_686] (rows=1 width=8)
+                                      Filter Operator [FIL_685] (rows=1 width=8)
                                         predicate:(sq_count_check(_col0) <= 1)
-                                        Group By Operator [GBY_680] (rows=1 width=8)
+                                        Group By Operator [GBY_684] (rows=1 width=8)
                                           Output:["_col0"],aggregations:["count()"]
-                                          Select Operator [SEL_679] (rows=1 width=8)
-                                            Group By Operator [GBY_678] (rows=1 width=8)
+                                          Select Operator [SEL_683] (rows=1 width=8)
+                                            Group By Operator [GBY_682] (rows=1 width=8)
                                               Output:["_col0"],aggregations:["count(VALUE._col0)"]
                                             <-Reducer 27 [CUSTOM_SIMPLE_EDGE] vectorized
-                                              PARTITION_ONLY_SHUFFLE [RS_674]
-                                                Group By Operator [GBY_670] (rows=1 width=8)
+                                              PARTITION_ONLY_SHUFFLE [RS_678]
+                                                Group By Operator [GBY_674] (rows=1 width=8)
                                                   Output:["_col0"],aggregations:["count(_col0)"]
-                                                  Select Operator [SEL_666] (rows=11859 width=116)
+                                                  Select Operator [SEL_670] (rows=11859 width=116)
                                                     Output:["_col0"]
-                                                     Please refer to the previous Group By Operator [GBY_665]
+                                                     Please refer to the previous Group By Operator [GBY_669]
                                 <-Reducer 31 [CUSTOM_SIMPLE_EDGE] vectorized
-                                  PARTITION_ONLY_SHUFFLE [RS_685]
-                                    Group By Operator [GBY_684] (rows=1 width=112)
+                                  PARTITION_ONLY_SHUFFLE [RS_689]
+                                    Group By Operator [GBY_688] (rows=1 width=112)
                                       Output:["_col0"],aggregations:["max(VALUE._col0)"]
                                     <-Reducer 27 [CUSTOM_SIMPLE_EDGE] vectorized
-                                      PARTITION_ONLY_SHUFFLE [RS_675]
-                                        Group By Operator [GBY_671] (rows=1 width=112)
+                                      PARTITION_ONLY_SHUFFLE [RS_679]
+                                        Group By Operator [GBY_675] (rows=1 width=112)
                                           Output:["_col0"],aggregations:["max(_col1)"]
-                                          Select Operator [SEL_667] (rows=11859 width=116)
+                                          Select Operator [SEL_671] (rows=11859 width=116)
                                             Output:["_col1"]
-                                             Please refer to the previous Group By Operator [GBY_665]
+                                             Please refer to the previous Group By Operator [GBY_669]
                             <-Reducer 40 [CUSTOM_SIMPLE_EDGE] vectorized
-                              PARTITION_ONLY_SHUFFLE [RS_692]
-                                Group By Operator [GBY_691] (rows=1415625 width=116)
+                              PARTITION_ONLY_SHUFFLE [RS_696]
+                                Group By Operator [GBY_695] (rows=1415625 width=116)
                                   Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                                 <-Reducer 39 [SIMPLE_EDGE]
                                   SHUFFLE [RS_105]
@@ -535,30 +535,30 @@ Stage-0
                                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
                                       Select Operator [SEL_102] (rows=550080312 width=114)
                                         Output:["_col0","_col1"]
-                                        Merge Join Operator [MERGEJOIN_578] (rows=550080312 width=114)
-                                          Conds:RS_690._col0=RS_662._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        Merge Join Operator [MERGEJOIN_582] (rows=550080312 width=114)
+                                          Conds:RS_694._col0=RS_666._col0(Inner),Output:["_col1","_col2","_col3"]
                                         <-Map 41 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_662]
+                                          SHUFFLE [RS_666]
                                             PartitionCols:_col0
-                                             Please refer to the previous Select Operator [SEL_661]
+                                             Please refer to the previous Select Operator [SEL_665]
                                         <-Map 38 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_690]
+                                          SHUFFLE [RS_694]
                                             PartitionCols:_col0
-                                            Select Operator [SEL_689] (rows=550080312 width=114)
+                                            Select Operator [SEL_693] (rows=550080312 width=114)
                                               Output:["_col0","_col1","_col2"]
-                                              Filter Operator [FIL_688] (rows=550080312 width=114)
+                                              Filter Operator [FIL_692] (rows=550080312 width=114)
                                                 predicate:((ss_customer_sk BETWEEN DynamicValue(RS_122_catalog_sales_cs_bill_customer_sk_min) AND DynamicValue(RS_122_catalog_sales_cs_bill_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_122_catalog_sales_cs_bill_customer_sk_bloom_filter))) and ss_customer_sk is not null)
                                                 TableScan [TS_93] (rows=575995635 width=114)
                                                   default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_customer_sk","ss_quantity","ss_sales_price"]
                                                 <-Reducer 7 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_687]
-                                                    Group By Operator [GBY_686] (rows=1 width=12)
+                                                  BROADCAST [RS_691]
+                                                    Group By Operator [GBY_690] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
-                                                      PARTITION_ONLY_SHUFFLE [RS_458]
-                                                        Group By Operator [GBY_457] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_464]
+                                                        Group By Operator [GBY_463] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_456] (rows=304 width=0)
+                                                          Select Operator [SEL_462] (rows=304 width=0)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_587]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_591]
 


[17/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query43.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query43.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query43.q.out
new file mode 100644
index 0000000..495b6bd
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query43.q.out
@@ -0,0 +1,135 @@
+PREHOOK: query: explain
+select  s_store_name, s_store_id,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from date_dim, store_sales, store
+ where d_date_sk = ss_sold_date_sk and
+       s_store_sk = ss_store_sk and
+       s_gmt_offset = -6 and
+       d_year = 1998 
+ group by s_store_name, s_store_id
+ order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  s_store_name, s_store_id,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from date_dim, store_sales, store
+ where d_date_sk = ss_sold_date_sk and
+       s_store_sk = ss_store_sk and
+       s_gmt_offset = -6 and
+       d_year = 1998 
+ group by s_store_name, s_store_id
+ order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 7 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_79]
+        Limit [LIM_78] (rows=100 width=972)
+          Number of rows:100
+          Select Operator [SEL_77] (rows=3751 width=972)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_76]
+              Group By Operator [GBY_75] (rows=3751 width=972)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)"],keys:KEY._col0, KEY._col1
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_18]
+                  PartitionCols:_col0, _col1
+                  Group By Operator [GBY_17] (rows=142538 width=972)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)","sum(_col5)","sum(_col6)","sum(_col7)","sum(_col8)"],keys:_col0, _col1
+                    Top N Key Operator [TNK_33] (rows=37536846 width=257)
+                      keys:_col0, _col1,sort order:++,top n:100
+                      Select Operator [SEL_15] (rows=37536846 width=257)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                        Merge Join Operator [MERGEJOIN_55] (rows=37536846 width=257)
+                          Conds:RS_12._col1=RS_66._col0(Inner),Output:["_col2","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col12","_col13"]
+                        <-Map 8 [SIMPLE_EDGE] vectorized
+                          PARTITION_ONLY_SHUFFLE [RS_66]
+                            PartitionCols:_col0
+                            Select Operator [SEL_65] (rows=341 width=192)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_64] (rows=341 width=303)
+                                predicate:(s_gmt_offset = -6)
+                                TableScan [TS_6] (rows=1704 width=303)
+                                  default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id","s_store_name","s_gmt_offset"]
+                        <-Reducer 2 [SIMPLE_EDGE]
+                          SHUFFLE [RS_12]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_54] (rows=187574154 width=129)
+                              Conds:RS_74._col0=RS_58._col0(Inner),Output:["_col1","_col2","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+                            <-Map 6 [SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_58]
+                                PartitionCols:_col0
+                                Select Operator [SEL_57] (rows=652 width=32)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                  Filter Operator [FIL_56] (rows=652 width=99)
+                                    predicate:(d_year = 1998)
+                                    TableScan [TS_3] (rows=73049 width=99)
+                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_day_name"]
+                            <-Map 1 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_74]
+                                PartitionCols:_col0
+                                Select Operator [SEL_73] (rows=525329897 width=114)
+                                  Output:["_col0","_col1","_col2"]
+                                  Filter Operator [FIL_72] (rows=525329897 width=114)
+                                    predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_10_date_dim_d_date_sk_min) AND DynamicValue(RS_10_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_10_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_13_store_s_store_sk_min) AND DynamicValue(RS_13_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_13_store_s_store_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                    TableScan [TS_0] (rows=575995635 width=114)
+                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_store_sk","ss_sales_price"]
+                                    <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_63]
+                                        Group By Operator [GBY_62] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_61]
+                                            Group By Operator [GBY_60] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_59] (rows=652 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_57]
+                                    <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_71]
+                                        Group By Operator [GBY_70] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_69]
+                                            Group By Operator [GBY_68] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_67] (rows=341 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_65]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out
new file mode 100644
index 0000000..13b0936
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query44.q.out
@@ -0,0 +1,193 @@
+Warning: Shuffle Join MERGEJOIN[101][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain
+select  asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
+from(select *
+     from (select item_sk,rank() over (order by rank_col asc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col 
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V1)V11
+     where rnk  < 11) asceding,
+    (select *
+     from (select item_sk,rank() over (order by rank_col desc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V2)V21
+     where rnk  < 11) descending,
+item i1,
+item i2
+where asceding.rnk = descending.rnk 
+  and i1.i_item_sk=asceding.item_sk
+  and i2.i_item_sk=descending.item_sk
+order by asceding.rnk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
+from(select *
+     from (select item_sk,rank() over (order by rank_col asc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col 
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V1)V11
+     where rnk  < 11) asceding,
+    (select *
+     from (select item_sk,rank() over (order by rank_col desc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V2)V21
+     where rnk  < 11) descending,
+item i1,
+item i2
+where asceding.rnk = descending.rnk 
+  and i1.i_item_sk=asceding.item_sk
+  and i2.i_item_sk=descending.item_sk
+order by asceding.rnk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 8 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 1 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 12 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4 vectorized
+      File Output Operator [FS_135]
+        Limit [LIM_134] (rows=100 width=218)
+          Number of rows:100
+          Select Operator [SEL_133] (rows=6951 width=218)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 3 [SIMPLE_EDGE]
+            SHUFFLE [RS_67]
+              Select Operator [SEL_66] (rows=6951 width=218)
+                Output:["_col0","_col1","_col2"]
+                Merge Join Operator [MERGEJOIN_105] (rows=6951 width=218)
+                  Conds:RS_63._col3=RS_64._col3(Inner),Output:["_col1","_col3","_col5"]
+                <-Reducer 2 [SIMPLE_EDGE]
+                  SHUFFLE [RS_63]
+                    PartitionCols:_col3
+                    Merge Join Operator [MERGEJOIN_102] (rows=6951 width=111)
+                      Conds:RS_107._col0=RS_127._col0(Inner),Output:["_col1","_col3"]
+                    <-Map 1 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_107]
+                        PartitionCols:_col0
+                        Select Operator [SEL_106] (rows=462000 width=111)
+                          Output:["_col0","_col1"]
+                          TableScan [TS_0] (rows=462000 width=111)
+                            default@item,i1,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_product_name"]
+                    <-Reducer 9 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_127]
+                        PartitionCols:_col0
+                        Select Operator [SEL_126] (rows=6951 width=8)
+                          Output:["_col0","_col1"]
+                          Filter Operator [FIL_125] (rows=6951 width=116)
+                            predicate:(rank_window_0 < 11)
+                            PTF Operator [PTF_124] (rows=20854 width=116)
+                              Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 ASC NULLS FIRST","partition by:":"0"}]
+                              Select Operator [SEL_123] (rows=20854 width=116)
+                                Output:["_col0","_col1"]
+                              <-Reducer 8 [SIMPLE_EDGE]
+                                SHUFFLE [RS_21]
+                                  PartitionCols:0
+                                  Filter Operator [FIL_20] (rows=20854 width=228)
+                                    predicate:(_col1 > _col2)
+                                    Merge Join Operator [MERGEJOIN_101] (rows=62562 width=228)
+                                      Conds:(Inner),Output:["_col0","_col1","_col2"]
+                                    <-Reducer 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_122]
+                                        Select Operator [SEL_121] (rows=1 width=112)
+                                          Output:["_col0"]
+                                          Group By Operator [GBY_120] (rows=1 width=124)
+                                            Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                                          <-Map 11 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_119]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_118] (rows=258 width=124)
+                                                Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","count(_col1)"],keys:true
+                                                Select Operator [SEL_117] (rows=287946 width=114)
+                                                  Output:["_col1"]
+                                                  Filter Operator [FIL_116] (rows=287946 width=114)
+                                                    predicate:((ss_store_sk = 410) and ss_hdemo_sk is null)
+                                                    TableScan [TS_9] (rows=575995635 width=114)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_hdemo_sk","ss_store_sk","ss_net_profit"]
+                                    <-Reducer 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_115]
+                                        Select Operator [SEL_114] (rows=62562 width=116)
+                                          Output:["_col0","_col1"]
+                                          Group By Operator [GBY_113] (rows=62562 width=124)
+                                            Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                                          <-Map 6 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_112]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_111] (rows=3199976 width=124)
+                                                Output:["_col0","_col1","_col2"],aggregations:["sum(ss_net_profit)","count(ss_net_profit)"],keys:ss_item_sk
+                                                Select Operator [SEL_110] (rows=6399952 width=114)
+                                                  Output:["ss_item_sk","ss_net_profit"]
+                                                  Filter Operator [FIL_109] (rows=6399952 width=114)
+                                                    predicate:(ss_store_sk = 410)
+                                                    TableScan [TS_2] (rows=575995635 width=114)
+                                                      default@store_sales,ss1,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_store_sk","ss_net_profit"]
+                <-Reducer 5 [SIMPLE_EDGE]
+                  SHUFFLE [RS_64]
+                    PartitionCols:_col3
+                    Merge Join Operator [MERGEJOIN_104] (rows=6951 width=111)
+                      Conds:RS_108._col0=RS_132._col0(Inner),Output:["_col1","_col3"]
+                    <-Map 1 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_108]
+                        PartitionCols:_col0
+                         Please refer to the previous Select Operator [SEL_106]
+                    <-Reducer 10 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_132]
+                        PartitionCols:_col0
+                        Select Operator [SEL_131] (rows=6951 width=8)
+                          Output:["_col0","_col1"]
+                          Filter Operator [FIL_130] (rows=6951 width=116)
+                            predicate:(rank_window_0 < 11)
+                            PTF Operator [PTF_129] (rows=20854 width=116)
+                              Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 DESC NULLS LAST","partition by:":"0"}]
+                              Select Operator [SEL_128] (rows=20854 width=116)
+                                Output:["_col0","_col1"]
+                              <-Reducer 8 [SIMPLE_EDGE]
+                                SHUFFLE [RS_49]
+                                  PartitionCols:0
+                                   Please refer to the previous Filter Operator [FIL_20]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query45.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query45.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query45.q.out
new file mode 100644
index 0000000..bf620c8
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query45.q.out
@@ -0,0 +1,183 @@
+PREHOOK: query: explain
+select  ca_zip, ca_county, sum(ws_sales_price)
+ from web_sales, customer, customer_address, date_dim, item
+ where ws_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ws_item_sk = i_item_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
+ 	      or 
+ 	      i_item_id in (select i_item_id
+                             from item
+                             where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                             )
+ 	    )
+ 	and ws_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip, ca_county
+ order by ca_zip, ca_county
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  ca_zip, ca_county, sum(ws_sales_price)
+ from web_sales, customer, customer_address, date_dim, item
+ where ws_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ws_item_sk = i_item_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
+ 	      or 
+ 	      i_item_id in (select i_item_id
+                             from item
+                             where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                             )
+ 	    )
+ 	and ws_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip, ca_county
+ order by ca_zip, ca_county
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 11 <- Reducer 14 (BROADCAST_EDGE)
+Reducer 10 <- Map 7 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 8 <- Map 7 (SIMPLE_EDGE), Reducer 10 (ONE_TO_ONE_EDGE)
+Reducer 9 <- Reducer 12 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_149]
+        Limit [LIM_148] (rows=100 width=299)
+          Number of rows:100
+          Select Operator [SEL_147] (rows=285780 width=299)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_146]
+              Group By Operator [GBY_145] (rows=285780 width=299)
+                Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_41]
+                  PartitionCols:_col0, _col1
+                  Group By Operator [GBY_40] (rows=3715140 width=299)
+                    Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col8, _col7
+                    Top N Key Operator [TNK_69] (rows=10246864 width=302)
+                      keys:_col8, _col7,sort order:++,top n:100
+                      Select Operator [SEL_39] (rows=10246864 width=302)
+                        Output:["_col3","_col7","_col8"]
+                        Filter Operator [FIL_38] (rows=10246864 width=302)
+                          predicate:((substr(_col8, 1, 5)) IN ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792') or _col15 is not null)
+                          Select Operator [SEL_37] (rows=10246864 width=302)
+                            Output:["_col3","_col7","_col8","_col15"]
+                            Merge Join Operator [MERGEJOIN_119] (rows=10246864 width=302)
+                              Conds:RS_34._col0=RS_35._col6(Inner),Output:["_col3","_col4","_col8","_col12"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_34]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_115] (rows=80000000 width=191)
+                                  Conds:RS_122._col1=RS_124._col0(Inner),Output:["_col0","_col3","_col4"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_122]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_121] (rows=80000000 width=8)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_120] (rows=80000000 width=8)
+                                        predicate:c_current_addr_sk is not null
+                                        TableScan [TS_0] (rows=80000000 width=8)
+                                          default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk"]
+                                <-Map 6 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_124]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_123] (rows=40000000 width=191)
+                                      Output:["_col0","_col1","_col2"]
+                                      TableScan [TS_3] (rows=40000000 width=191)
+                                        default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_county","ca_zip"]
+                            <-Reducer 9 [SIMPLE_EDGE]
+                              SHUFFLE [RS_35]
+                                PartitionCols:_col6
+                                Merge Join Operator [MERGEJOIN_118] (rows=10246864 width=119)
+                                  Conds:RS_27._col0=RS_28._col1(Inner),Output:["_col3","_col6","_col7"]
+                                <-Reducer 12 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_28]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_117] (rows=10246864 width=119)
+                                      Conds:RS_144._col0=RS_136._col0(Inner),Output:["_col1","_col2","_col3"]
+                                    <-Map 13 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_136]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_135] (rows=130 width=12)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_134] (rows=130 width=12)
+                                            predicate:((d_qoy = 2) and (d_year = 2000))
+                                            TableScan [TS_17] (rows=73049 width=12)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                                    <-Map 11 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_144]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_143] (rows=143930993 width=123)
+                                          Output:["_col0","_col1","_col2","_col3"]
+                                          Filter Operator [FIL_142] (rows=143930993 width=123)
+                                            predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_21_date_dim_d_date_sk_min) AND DynamicValue(RS_21_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_21_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                            TableScan [TS_14] (rows=144002668 width=123)
+                                              default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_customer_sk","ws_sales_price"]
+                                            <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_141]
+                                                Group By Operator [GBY_140] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_139]
+                                                    Group By Operator [GBY_138] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_137] (rows=130 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_135]
+                                <-Reducer 8 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_27]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_116] (rows=462007 width=4)
+                                      Conds:RS_127._col1=RS_133._col0(Left Outer),Output:["_col0","_col3"]
+                                    <-Map 7 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_127]
+                                        PartitionCols:_col1
+                                        Select Operator [SEL_125] (rows=462000 width=104)
+                                          Output:["_col0","_col1"]
+                                          TableScan [TS_5] (rows=462000 width=104)
+                                            default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                                    <-Reducer 10 [ONE_TO_ONE_EDGE] vectorized
+                                      FORWARD [RS_133]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_132] (rows=5 width=104)
+                                          Output:["_col0","_col1"]
+                                          Group By Operator [GBY_131] (rows=5 width=100)
+                                            Output:["_col0"],keys:KEY._col0
+                                          <-Map 7 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_130]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_129] (rows=5 width=100)
+                                                Output:["_col0"],keys:i_item_id
+                                                Select Operator [SEL_128] (rows=11 width=104)
+                                                  Output:["i_item_id"]
+                                                  Filter Operator [FIL_126] (rows=11 width=104)
+                                                    predicate:(i_item_sk) IN (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                                                     Please refer to the previous TableScan [TS_5]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query46.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query46.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query46.q.out
new file mode 100644
index 0000000..b7a6bd6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query46.q.out
@@ -0,0 +1,240 @@
+PREHOOK: query: explain
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,amt,profit 
+ from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,ca_city bought_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics,customer_address 
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and store_sales.ss_addr_sk = customer_address.ca_address_sk
+    and (household_demographics.hd_dep_count = 2 or
+         household_demographics.hd_vehicle_count= 1)
+    and date_dim.d_dow in (6,0)
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_city in ('Cedar Grove','Wildwood','Union','Salem','Highland Park') 
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
+    where ss_customer_sk = c_customer_sk
+      and customer.c_current_addr_sk = current_addr.ca_address_sk
+      and current_addr.ca_city <> bought_city
+  order by c_last_name
+          ,c_first_name
+          ,ca_city
+          ,bought_city
+          ,ss_ticket_number
+  limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,amt,profit 
+ from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,ca_city bought_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics,customer_address 
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and store_sales.ss_addr_sk = customer_address.ca_address_sk
+    and (household_demographics.hd_dep_count = 2 or
+         household_demographics.hd_vehicle_count= 1)
+    and date_dim.d_dow in (6,0)
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_city in ('Cedar Grove','Wildwood','Union','Salem','Highland Park') 
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
+    where ss_customer_sk = c_customer_sk
+      and customer.c_current_addr_sk = current_addr.ca_address_sk
+      and current_addr.ca_city <> bought_city
+  order by c_last_name
+          ,c_first_name
+          ,ca_city
+          ,bought_city
+          ,ss_ticket_number
+  limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 8 <- Reducer 13 (BROADCAST_EDGE), Reducer 15 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Reducer 10 <- Map 14 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 16 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 14 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 5 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 6 <- Map 5 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 12 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4 vectorized
+      File Output Operator [FS_182]
+        Limit [LIM_181] (rows=100 width=594)
+          Number of rows:100
+          Select Operator [SEL_180] (rows=20351707 width=594)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 3 [SIMPLE_EDGE]
+            SHUFFLE [RS_44]
+              Select Operator [SEL_43] (rows=20351707 width=594)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                Filter Operator [FIL_42] (rows=20351707 width=594)
+                  predicate:(_col5 <> _col8)
+                  Merge Join Operator [MERGEJOIN_143] (rows=20351707 width=594)
+                    Conds:RS_39._col0=RS_179._col1(Inner),Output:["_col2","_col3","_col5","_col6","_col8","_col9","_col10"]
+                  <-Reducer 2 [SIMPLE_EDGE]
+                    SHUFFLE [RS_39]
+                      PartitionCols:_col0
+                      Merge Join Operator [MERGEJOIN_138] (rows=80000000 width=277)
+                        Conds:RS_146._col1=RS_148._col0(Inner),Output:["_col0","_col2","_col3","_col5"]
+                      <-Map 5 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_148]
+                          PartitionCols:_col0
+                          Select Operator [SEL_147] (rows=40000000 width=97)
+                            Output:["_col0","_col1"]
+                            TableScan [TS_3] (rows=40000000 width=97)
+                              default@customer_address,current_addr,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_city"]
+                      <-Map 1 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_146]
+                          PartitionCols:_col1
+                          Select Operator [SEL_145] (rows=80000000 width=188)
+                            Output:["_col0","_col1","_col2","_col3"]
+                            Filter Operator [FIL_144] (rows=80000000 width=188)
+                              predicate:c_current_addr_sk is not null
+                              TableScan [TS_0] (rows=80000000 width=188)
+                                default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk","c_first_name","c_last_name"]
+                  <-Reducer 7 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_179]
+                      PartitionCols:_col1
+                      Select Operator [SEL_178] (rows=20351707 width=321)
+                        Output:["_col0","_col1","_col2","_col3","_col4"]
+                        Group By Operator [GBY_177] (rows=20351707 width=321)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+                        <-Reducer 6 [SIMPLE_EDGE]
+                          SHUFFLE [RS_33]
+                            PartitionCols:_col0, _col1, _col2, _col3
+                            Group By Operator [GBY_32] (rows=20351707 width=321)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col6)","sum(_col7)"],keys:_col1, _col12, _col3, _col5
+                              Merge Join Operator [MERGEJOIN_142] (rows=20351707 width=97)
+                                Conds:RS_28._col3=RS_149._col0(Inner),Output:["_col1","_col3","_col5","_col6","_col7","_col12"]
+                              <-Map 5 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_149]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select Operator [SEL_147]
+                              <-Reducer 11 [SIMPLE_EDGE]
+                                SHUFFLE [RS_28]
+                                  PartitionCols:_col3
+                                  Merge Join Operator [MERGEJOIN_141] (rows=20351707 width=4)
+                                    Conds:RS_25._col2=RS_168._col0(Inner),Output:["_col1","_col3","_col5","_col6","_col7"]
+                                  <-Map 16 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_168]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_167] (rows=1855 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_166] (rows=1855 width=12)
+                                          predicate:((hd_dep_count = 2) or (hd_vehicle_count = 1))
+                                          TableScan [TS_14] (rows=7200 width=12)
+                                            default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_dep_count","hd_vehicle_count"]
+                                  <-Reducer 10 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_25]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_140] (rows=78993142 width=178)
+                                        Conds:RS_22._col4=RS_160._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col7"]
+                                      <-Map 14 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_160]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_159] (rows=85 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_158] (rows=85 width=97)
+                                              predicate:(s_city) IN ('Cedar Grove', 'Wildwood', 'Union', 'Salem', 'Highland Park')
+                                              TableScan [TS_11] (rows=1704 width=97)
+                                                default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_city"]
+                                      <-Reducer 9 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_22]
+                                          PartitionCols:_col4
+                                          Merge Join Operator [MERGEJOIN_139] (rows=196204013 width=218)
+                                            Conds:RS_176._col0=RS_152._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                          <-Map 12 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_152]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_151] (rows=783 width=4)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_150] (rows=783 width=12)
+                                                  predicate:((d_dow) IN (6, 0) and (d_year) IN (1998, 1999, 2000))
+                                                  TableScan [TS_8] (rows=73049 width=12)
+                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_dow"]
+                                          <-Map 8 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_176]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_175] (rows=457565061 width=237)
+                                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                                Filter Operator [FIL_174] (rows=457565061 width=237)
+                                                  predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_26_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_26_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_26_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_20_date_dim_d_date_sk_min) AND DynamicValue(RS_20_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_20_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_23_store_s_store_sk_min) AND DynamicValue(RS_23_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_23_store_s_store_sk_bloom_filter))) and ss_addr_sk is not null and ss_customer_sk is not null and ss_hdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                  TableScan [TS_5] (rows=575995635 width=237)
+                                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_hdemo_sk","ss_addr_sk","ss_store_sk","ss_ticket_number","ss_coupon_amt","ss_net_profit"]
+                                                  <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_157]
+                                                      Group By Operator [GBY_156] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_155]
+                                                          Group By Operator [GBY_154] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_153] (rows=783 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_151]
+                                                  <-Reducer 15 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_165]
+                                                      Group By Operator [GBY_164] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 14 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_163]
+                                                          Group By Operator [GBY_162] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_161] (rows=85 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_159]
+                                                  <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_173]
+                                                      Group By Operator [GBY_172] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_171]
+                                                          Group By Operator [GBY_170] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_169] (rows=1855 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_167]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query47.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query47.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query47.q.out
new file mode 100644
index 0000000..e905b1178
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query47.q.out
@@ -0,0 +1,266 @@
+PREHOOK: query: explain
+with v1 as(
+ select i_category, i_brand,
+        s_store_name, s_company_name,
+        d_year, d_moy,
+        sum(ss_sales_price) sum_sales,
+        avg(sum(ss_sales_price)) over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name
+           order by d_year, d_moy) rn
+ from item, store_sales, date_dim, store
+ where ss_item_sk = i_item_sk and
+       ss_sold_date_sk = d_date_sk and
+       ss_store_sk = s_store_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          s_store_name, s_company_name,
+          d_year, d_moy),
+ v2 as(
+ select v1.i_category
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1.s_store_name = v1_lag.s_store_name and
+       v1.s_store_name = v1_lead.s_store_name and
+       v1.s_company_name = v1_lag.s_company_name and
+       v1.s_company_name = v1_lead.s_company_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and    
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with v1 as(
+ select i_category, i_brand,
+        s_store_name, s_company_name,
+        d_year, d_moy,
+        sum(ss_sales_price) sum_sales,
+        avg(sum(ss_sales_price)) over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name
+           order by d_year, d_moy) rn
+ from item, store_sales, date_dim, store
+ where ss_item_sk = i_item_sk and
+       ss_sold_date_sk = d_date_sk and
+       ss_store_sk = s_store_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          s_store_name, s_company_name,
+          d_year, d_moy),
+ v2 as(
+ select v1.i_category
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1.s_store_name = v1_lag.s_store_name and
+       v1.s_store_name = v1_lead.s_store_name and
+       v1.s_company_name = v1_lag.s_company_name and
+       v1.s_company_name = v1_lead.s_company_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and    
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 13 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 3 <- Map 14 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 15 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE), Reducer 9 (ONE_TO_ONE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 11 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_321]
+        Limit [LIM_320] (rows=100 width=658)
+          Number of rows:100
+          Select Operator [SEL_319] (rows=241454 width=658)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 7 [SIMPLE_EDGE]
+            SHUFFLE [RS_110]
+              Select Operator [SEL_109] (rows=241454 width=658)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                Merge Join Operator [MERGEJOIN_278] (rows=241454 width=546)
+                  Conds:RS_106._col6, _col7, _col8, _col9, _col14=RS_306._col0, _col1, _col2, _col3, _col5(Inner),Output:["_col4","_col6","_col10","_col11","_col12","_col13","_col19"]
+                <-Reducer 6 [SIMPLE_EDGE] vectorized
+                  SHUFFLE [RS_306]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col5
+                    Select Operator [SEL_304] (rows=162257387 width=485)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                      Filter Operator [FIL_302] (rows=162257387 width=489)
+                        predicate:rank_window_0 is not null
+                        PTF Operator [PTF_300] (rows=162257387 width=489)
+                          Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col2 ASC NULLS LAST, _col3 ASC NULLS LAST","partition by:":"_col1, _col0, _col4, _col5"}]
+                          Select Operator [SEL_299] (rows=162257387 width=489)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                          <-Reducer 5 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_297]
+                              PartitionCols:_col1, _col0, _col4, _col5
+                              Group By Operator [GBY_296] (rows=162257387 width=489)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                              <-Reducer 4 [SIMPLE_EDGE]
+                                SHUFFLE [RS_93]
+                                  PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                  Group By Operator [GBY_92] (rows=162257387 width=489)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col3)"],keys:_col8, _col9, _col5, _col6, _col11, _col12
+                                    Merge Join Operator [MERGEJOIN_276] (rows=162257387 width=472)
+                                      Conds:RS_88._col2=RS_295._col0(Inner),Output:["_col3","_col5","_col6","_col8","_col9","_col11","_col12"]
+                                    <-Map 15 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_295]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_294] (rows=1704 width=183)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_293] (rows=1704 width=183)
+                                            predicate:(s_company_name is not null and s_store_name is not null)
+                                            TableScan [TS_79] (rows=1704 width=183)
+                                              default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_company_name"]
+                                    <-Reducer 3 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_88]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_275] (rows=162257387 width=297)
+                                          Conds:RS_85._col1=RS_292._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col8","_col9"]
+                                        <-Map 14 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_292]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_291] (rows=462000 width=194)
+                                              Output:["_col0","_col1","_col2"]
+                                              Filter Operator [FIL_290] (rows=462000 width=194)
+                                                predicate:(i_brand is not null and i_category is not null)
+                                                TableScan [TS_76] (rows=462000 width=194)
+                                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand","i_category"]
+                                        <-Reducer 2 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_85]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_274] (rows=162257387 width=111)
+                                              Conds:RS_289._col0=RS_281._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6"]
+                                            <-Map 12 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_281]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_280] (rows=564 width=12)
+                                                  Output:["_col0","_col1","_col2"]
+                                                  Filter Operator [FIL_279] (rows=564 width=12)
+                                                    predicate:(((d_year = 2000) or (struct(d_year,d_moy)) IN (const struct(1999,12), const struct(2001,1))) and (d_year) IN (2000, 1999, 2001))
+                                                    TableScan [TS_73] (rows=73049 width=12)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                            <-Map 1 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_289]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_288] (rows=525329897 width=118)
+                                                  Output:["_col0","_col1","_col2","_col3"]
+                                                  Filter Operator [FIL_287] (rows=525329897 width=118)
+                                                    predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_83_date_dim_d_date_sk_min) AND DynamicValue(RS_83_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_83_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                    TableScan [TS_70] (rows=575995635 width=118)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_sales_price"]
+                                                    <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_286]
+                                                        Group By Operator [GBY_285] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_284]
+                                                            Group By Operator [GBY_283] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_282] (rows=564 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_280]
+                <-Reducer 9 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_106]
+                    PartitionCols:_col6, _col7, _col8, _col9, _col14
+                    Merge Join Operator [MERGEJOIN_277] (rows=241454 width=717)
+                      Conds:RS_307._col0, _col1, _col2, _col3, _col5=RS_318._col0, _col1, _col2, _col3, _col8(Inner),Output:["_col4","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+                    <-Reducer 6 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_307]
+                        PartitionCols:_col0, _col1, _col2, _col3, _col5
+                        Select Operator [SEL_305] (rows=162257387 width=485)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          Filter Operator [FIL_303] (rows=162257387 width=489)
+                            predicate:rank_window_0 is not null
+                            PTF Operator [PTF_301] (rows=162257387 width=489)
+                              Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col2 ASC NULLS LAST, _col3 ASC NULLS LAST","partition by:":"_col1, _col0, _col4, _col5"}]
+                               Please refer to the previous Select Operator [SEL_299]
+                    <-Reducer 11 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_318]
+                        PartitionCols:_col0, _col1, _col2, _col3, _col8
+                        Select Operator [SEL_317] (rows=241454 width=605)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                          Filter Operator [FIL_316] (rows=241454 width=605)
+                            predicate:CASE WHEN ((_col0 > 0)) THEN (((abs((_col7 - _col0)) / _col0) > 0.1)) ELSE (null) END
+                            Select Operator [SEL_315] (rows=482909 width=601)
+                              Output:["rank_window_1","_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                              Filter Operator [FIL_314] (rows=482909 width=601)
+                                predicate:((_col0 > 0) and (_col3 = 2000) and rank_window_1 is not null)
+                                PTF Operator [PTF_313] (rows=162257387 width=601)
+                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS LAST, _col4 ASC NULLS LAST","partition by:":"_col2, _col1, _col5, _col6"}]
+                                  Select Operator [SEL_312] (rows=162257387 width=601)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                  <-Reducer 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_311]
+                                      PartitionCols:_col1, _col0, _col4, _col5
+                                      Select Operator [SEL_310] (rows=162257387 width=489)
+                                        Output:["avg_window_0","_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                        PTF Operator [PTF_309] (rows=162257387 width=489)
+                                          Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 ASC NULLS FIRST, _col0 ASC NULLS FIRST, _col4 ASC NULLS FIRST, _col5 ASC NULLS FIRST, _col2 ASC NULLS FIRST","partition by:":"_col1, _col0, _col4, _col5, _col2"}]
+                                          Select Operator [SEL_308] (rows=162257387 width=489)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                          <-Reducer 5 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_298]
+                                              PartitionCols:_col1, _col0, _col4, _col5, _col2
+                                               Please refer to the previous Group By Operator [GBY_296]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query48.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query48.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query48.q.out
new file mode 100644
index 0000000..b84dfce
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query48.q.out
@@ -0,0 +1,252 @@
+PREHOOK: query: explain
+select sum (ss_quantity)
+ from store_sales, store, customer_demographics, customer_address, date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 1998
+ and  
+ (
+  (
+   cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 100.00 and 150.00  
+   )
+ or
+  (
+  cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 50.00 and 100.00   
+  )
+ or 
+ (
+  cd_demo_sk = ss_cdemo_sk
+  and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 150.00 and 200.00  
+ )
+ )
+ and
+ (
+  (
+  ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 0 and 2000  
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 3000 
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 25000 
+  )
+ )
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select sum (ss_quantity)
+ from store_sales, store, customer_demographics, customer_address, date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 1998
+ and  
+ (
+  (
+   cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 100.00 and 150.00  
+   )
+ or
+  (
+  cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 50.00 and 100.00   
+  )
+ or 
+ (
+  cd_demo_sk = ss_cdemo_sk
+  and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 150.00 and 200.00  
+ )
+ )
+ and
+ (
+  (
+  ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 0 and 2000  
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 3000 
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 25000 
+  )
+ )
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 7 <- Reducer 11 (BROADCAST_EDGE), Reducer 6 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 10 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_102]
+        Group By Operator [GBY_101] (rows=1 width=8)
+          Output:["_col0"],aggregations:["sum(VALUE._col0)"]
+        <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+          PARTITION_ONLY_SHUFFLE [RS_24]
+            Group By Operator [GBY_23] (rows=1 width=8)
+              Output:["_col0"],aggregations:["sum(_col4)"]
+              Select Operator [SEL_22] (rows=20247 width=24)
+                Output:["_col4"]
+                Filter Operator [FIL_21] (rows=20247 width=24)
+                  predicate:((_col10 and _col5) or (_col11 and _col6) or (_col12 and _col7))
+                  Merge Join Operator [MERGEJOIN_73] (rows=26999 width=24)
+                    Conds:RS_18._col3=RS_92._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col10","_col11","_col12"]
+                  <-Map 10 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_92]
+                      PartitionCols:_col0
+                      Select Operator [SEL_91] (rows=3529412 width=16)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Filter Operator [FIL_90] (rows=3529412 width=187)
+                          predicate:((ca_country = 'United States') and (ca_state) IN ('KY', 'GA', 'NM', 'MT', 'OR', 'IN', 'WI', 'MO', 'WV'))
+                          TableScan [TS_9] (rows=40000000 width=187)
+                            default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state","ca_country"]
+                  <-Reducer 3 [SIMPLE_EDGE]
+                    SHUFFLE [RS_18]
+                      PartitionCols:_col3
+                      Merge Join Operator [MERGEJOIN_72] (rows=305980 width=12)
+                        Conds:RS_15._col1=RS_84._col0(Inner),Output:["_col3","_col4","_col5","_col6","_col7"]
+                      <-Map 8 [SIMPLE_EDGE] vectorized
+                        PARTITION_ONLY_SHUFFLE [RS_84]
+                          PartitionCols:_col0
+                          Select Operator [SEL_83] (rows=652 width=4)
+                            Output:["_col0"]
+                            Filter Operator [FIL_82] (rows=652 width=8)
+                              predicate:(d_year = 1998)
+                              TableScan [TS_6] (rows=73049 width=8)
+                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_15]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_71] (rows=856943 width=12)
+                            Conds:RS_76._col0=RS_100._col1(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_76]
+                              PartitionCols:_col0
+                              Select Operator [SEL_75] (rows=29552 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_74] (rows=29552 width=183)
+                                  predicate:((cd_education_status = '4 yr Degree') and (cd_marital_status = 'M'))
+                                  TableScan [TS_0] (rows=1861800 width=183)
+                                    default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_marital_status","cd_education_status"]
+                          <-Map 7 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_100]
+                              PartitionCols:_col1
+                              Select Operator [SEL_99] (rows=53235296 width=27)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                Filter Operator [FIL_98] (rows=53235296 width=233)
+                                  predicate:((ss_addr_sk BETWEEN DynamicValue(RS_19_customer_address_ca_address_sk_min) AND DynamicValue(RS_19_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_19_customer_address_ca_address_sk_bloom_filter))) and (ss_cdemo_sk BETWEEN DynamicValue(RS_12_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_12_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_12_customer_demographics_cd_demo_sk_bloom_filter))) and (ss_net_profit BETWEEN 0 AND 2000 or ss_net_profit BETWEEN 150 AND 3000 or ss_net_profit BETWEEN 50 AND 25000) and (ss_sales_price BETWEEN 100 AND 150 or ss_sales_price BETWEEN 50 AND 100 or ss_sales_price BETWEEN 150 AND 200) and (ss_sold_date_sk BETWEEN DynamicValue(RS_16_date_dim_d_date_sk_min) AND DynamicValue(RS_16_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_16_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_c
 demo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                  TableScan [TS_3] (rows=575995635 width=233)
+                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_cdemo_sk","ss_addr_sk","ss_store_sk","ss_quantity","ss_sales_price","ss_net_profit"]
+                                  <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_97]
+                                      Group By Operator [GBY_96] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=3529412)"]
+                                      <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_95]
+                                          Group By Operator [GBY_94] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=3529412)"]
+                                            Select Operator [SEL_93] (rows=3529412 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_91]
+                                  <-Reducer 6 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_81]
+                                      Group By Operator [GBY_80] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 1 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_79]
+                                          Group By Operator [GBY_78] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_77] (rows=29552 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_75]
+                                  <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_89]
+                                      Group By Operator [GBY_88] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_87]
+                                          Group By Operator [GBY_86] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_85] (rows=652 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_83]
+


[35/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query20.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query20.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query20.q.out
new file mode 100644
index 0000000..29382b3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query20.q.out
@@ -0,0 +1,81 @@
+PREHOOK: query: explain cbo
+select  i_item_desc 
+       ,i_category 
+       ,i_class 
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue 
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from	catalog_sales
+     ,item 
+     ,date_dim
+ where cs_item_sk = i_item_sk 
+   and i_category in ('Jewelry', 'Sports', 'Books')
+   and cs_sold_date_sk = d_date_sk
+ and d_date between cast('2001-01-12' as date) 
+ 				and (cast('2001-01-12' as date) + 30 days)
+ group by i_item_id
+         ,i_item_desc 
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_desc 
+       ,i_category 
+       ,i_class 
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue 
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from	catalog_sales
+     ,item 
+     ,date_dim
+ where cs_item_sk = i_item_sk 
+   and i_category in ('Jewelry', 'Sports', 'Books')
+   and cs_sold_date_sk = d_date_sk
+ and d_date between cast('2001-01-12' as date) 
+ 				and (cast('2001-01-12' as date) + 30 days)
+ group by i_item_id
+         ,i_item_desc 
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3], itemrevenue=[$4], revenueratio=[$5])
+  HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$6], sort3=[$0], sort4=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+    HiveProject(i_item_desc=[$1], i_category=[$4], i_class=[$3], i_current_price=[$2], itemrevenue=[$5], revenueratio=[/(*($5, CAST(100):DECIMAL(10, 0)), sum($5) OVER (PARTITION BY $3 ORDER BY $3 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING))], (tok_table_or_col i_item_id)=[$0])
+      HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
+            HiveFilter(condition=[IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books')])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-01-12 00:00:00, 2001-02-11 00:00:00)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query21.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query21.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query21.q.out
new file mode 100644
index 0000000..f304762
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query21.q.out
@@ -0,0 +1,88 @@
+PREHOOK: query: explain cbo
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
+	                then inv_quantity_on_hand 
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
+                      then inv_quantity_on_hand 
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0 
+             then inv_after / inv_before 
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
+	                then inv_quantity_on_hand 
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
+                      then inv_quantity_on_hand 
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0 
+             then inv_after / inv_before 
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+    HiveFilter(condition=[CASE(>($2, 0), BETWEEN(false, /(CAST($3):DOUBLE, CAST($2):DOUBLE), 6.66667E-1, 1.5E0), null)])
+      HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)])
+        HiveProject($f0=[$1], $f1=[$10], $f2=[CASE($7, $5, 0)], $f3=[CASE($8, $5, 0)])
+          HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+              HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+            HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3])
+                  HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                HiveProject(d_date_sk=[$0], <=[<(CAST($2):DATE, 1998-04-08)], >==[>=(CAST($2):DATE, 1998-04-08)])
+                  HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-09 00:00:00, 1998-05-08 00:00:00)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                HiveFilter(condition=[BETWEEN(false, $5, 0.99, 1.49)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query22.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query22.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query22.q.out
new file mode 100644
index 0000000..77f91f6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query22.q.out
@@ -0,0 +1,66 @@
+PREHOOK: query: explain cbo
+select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,avg(inv_quantity_on_hand) qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1212 and 1212 + 11
+       group by rollup(i_product_name
+                       ,i_brand
+                       ,i_class
+                       ,i_category)
+order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,avg(inv_quantity_on_hand) qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1212 and 1212 + 11
+       group by rollup(i_product_name
+                       ,i_brand
+                       ,i_class
+                       ,i_category)
+order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$4], sort1=[$0], sort2=[$1], sort3=[$2], sort4=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject($f0=[$3], $f1=[$0], $f2=[$1], $f3=[$2], $f4=[/(CAST($4):DOUBLE, $5)])
+    HiveAggregate(group=[{1, 2, 3, 4}], groups=[[{1, 2, 3, 4}, {1, 2, 4}, {1, 4}, {4}, {}]], agg#0=[sum($7)], agg#1=[count($7)])
+      HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12], i_product_name=[$21])
+          HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_quantity_on_hand=[$3])
+            HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+          HiveProject(d_date_sk=[$0])
+            HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query23.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query23.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query23.q.out
new file mode 100644
index 0000000..9629a71
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query23.q.out
@@ -0,0 +1,245 @@
+Warning: Shuffle Join MERGEJOIN[445][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 19' is a cross product
+Warning: Shuffle Join MERGEJOIN[446][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 20' is a cross product
+Warning: Shuffle Join MERGEJOIN[448][tables = [$hdt$_2, $hdt$_3]] in Stage 'Reducer 24' is a cross product
+Warning: Shuffle Join MERGEJOIN[449][tables = [$hdt$_2, $hdt$_3, $hdt$_1]] in Stage 'Reducer 25' is a cross product
+PREHOOK: query: explain cbo
+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
+  *
+from
+ max_store_sales))
+  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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+  *
+from
+ max_store_sales))
+  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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0])
+    HiveAggregate(group=[{}], agg#0=[sum($0)])
+      HiveProject(sales=[$0])
+        HiveUnion(all=[true])
+          HiveProject(sales=[*(CAST($4):DECIMAL(10, 0), $5)])
+            HiveJoin(condition=[=($3, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_customer_sk=[$0])
+                  HiveAggregate(group=[{0}])
+                    HiveJoin(condition=[>($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_customer_sk=[$0], $f1=[$1])
+                        HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                          HiveProject(ss_customer_sk=[CAST($3):INTEGER NOT NULL], *=[*(CAST($10):DECIMAL(10, 0), $13)])
+                            HiveFilter(condition=[IS NOT NULL($3)])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cnt=[$0])
+                          HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                            HiveProject(cnt=[$0])
+                              HiveAggregate(group=[{}], cnt=[COUNT()])
+                                HiveProject
+                                  HiveProject($f0=[$0])
+                                    HiveAggregate(group=[{}], agg#0=[count($0)])
+                                      HiveProject(ss_customer_sk=[$0], $f1=[$1])
+                                        HiveAggregate(group=[{1}], agg#0=[sum($2)])
+                                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[CAST($3):INTEGER NOT NULL], *=[*(CAST($10):DECIMAL(10, 0), $13)])
+                                              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[IN($6, 1999, 2000, 2001, 2002)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(*=[*(0.95, $0)])
+                          HiveAggregate(group=[{}], agg#0=[max($1)])
+                            HiveProject(ss_customer_sk=[$0], $f1=[$1])
+                              HiveAggregate(group=[{1}], agg#0=[sum($2)])
+                                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[CAST($3):INTEGER NOT NULL], *=[*(CAST($10):DECIMAL(10, 0), $13)])
+                                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                  HiveProject(d_date_sk=[$0])
+                                    HiveFilter(condition=[IN($6, 1999, 2000, 2001, 2002)])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_quantity=[$18], cs_list_price=[$20])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($6, 1999), =($8, 1))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(item_sk=[$0])
+                HiveFilter(condition=[>($1, 4)])
+                  HiveAggregate(group=[{4}], agg#0=[count()])
+                    HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject(d_date_sk=[$0], d_date=[$2])
+                          HiveFilter(condition=[IN($6, 1999, 2000, 2001, 2002)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(i_item_sk=[$0], substr=[substr($4, 1, 30)])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveProject(sales=[*(CAST($5):DECIMAL(10, 0), $6)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(item_sk=[$0])
+                HiveFilter(condition=[>($1, 4)])
+                  HiveAggregate(group=[{4}], agg#0=[count()])
+                    HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject(d_date_sk=[$0], d_date=[$2])
+                          HiveFilter(condition=[IN($6, 1999, 2000, 2001, 2002)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(i_item_sk=[$0], substr=[substr($4, 1, 30)])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_customer_sk=[$0])
+                  HiveAggregate(group=[{0}])
+                    HiveJoin(condition=[>($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_customer_sk=[$0], $f1=[$1])
+                        HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                          HiveProject(ss_customer_sk=[CAST($3):INTEGER NOT NULL], *=[*(CAST($10):DECIMAL(10, 0), $13)])
+                            HiveFilter(condition=[IS NOT NULL($3)])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cnt=[$0])
+                          HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                            HiveProject(cnt=[$0])
+                              HiveAggregate(group=[{}], cnt=[COUNT()])
+                                HiveProject
+                                  HiveProject($f0=[$0])
+                                    HiveAggregate(group=[{}], agg#0=[count($0)])
+                                      HiveProject(ss_customer_sk=[$0], $f1=[$1])
+                                        HiveAggregate(group=[{1}], agg#0=[sum($2)])
+                                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[CAST($3):INTEGER NOT NULL], *=[*(CAST($10):DECIMAL(10, 0), $13)])
+                                              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[IN($6, 1999, 2000, 2001, 2002)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(*=[*(0.95, $0)])
+                          HiveAggregate(group=[{}], agg#0=[max($1)])
+                            HiveProject(ss_customer_sk=[$0], $f1=[$1])
+                              HiveAggregate(group=[{1}], agg#0=[sum($2)])
+                                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[CAST($3):INTEGER NOT NULL], *=[*(CAST($10):DECIMAL(10, 0), $13)])
+                                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                  HiveProject(d_date_sk=[$0])
+                                    HiveFilter(condition=[IN($6, 1999, 2000, 2001, 2002)])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_customer_sk=[$4], ws_quantity=[$18], ws_list_price=[$20])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($6, 1999), =($8, 1))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out
new file mode 100644
index 0000000..34cc51b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out
@@ -0,0 +1,168 @@
+Warning: Shuffle Join MERGEJOIN[287][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain cbo
+with ssales as
+(select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,ca_state
+      ,s_state
+      ,i_color
+      ,i_current_price
+      ,i_manager_id
+      ,i_units
+      ,i_size
+      ,sum(ss_sales_price) netpaid
+from store_sales
+    ,store_returns
+    ,store
+    ,item
+    ,customer
+    ,customer_address
+where ss_ticket_number = sr_ticket_number
+  and ss_item_sk = sr_item_sk
+  and ss_customer_sk = c_customer_sk
+  and ss_item_sk = i_item_sk
+  and ss_store_sk = s_store_sk
+  and c_birth_country = upper(ca_country)
+  and s_zip = ca_zip
+and s_market_id=7
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+        ,ca_state
+        ,s_state
+        ,i_color
+        ,i_current_price
+        ,i_manager_id
+        ,i_units
+        ,i_size)
+select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,sum(netpaid) paid
+from ssales
+where i_color = 'orchid'
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+having sum(netpaid) > (select 0.05*avg(netpaid)
+                                 from ssales)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssales as
+(select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,ca_state
+      ,s_state
+      ,i_color
+      ,i_current_price
+      ,i_manager_id
+      ,i_units
+      ,i_size
+      ,sum(ss_sales_price) netpaid
+from store_sales
+    ,store_returns
+    ,store
+    ,item
+    ,customer
+    ,customer_address
+where ss_ticket_number = sr_ticket_number
+  and ss_item_sk = sr_item_sk
+  and ss_customer_sk = c_customer_sk
+  and ss_item_sk = i_item_sk
+  and ss_store_sk = s_store_sk
+  and c_birth_country = upper(ca_country)
+  and s_zip = ca_zip
+and s_market_id=7
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+        ,ca_state
+        ,s_state
+        ,i_color
+        ,i_current_price
+        ,i_manager_id
+        ,i_units
+        ,i_size)
+select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,sum(netpaid) paid
+from ssales
+where i_color = 'orchid'
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+having sum(netpaid) > (select 0.05*avg(netpaid)
+                                 from ssales)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+  HiveJoin(condition=[>($3, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveProject(c_last_name=[$1], c_first_name=[$0], s_store_name=[$2], $f3=[$3])
+      HiveAggregate(group=[{1, 2, 7}], agg#0=[sum($9)])
+        HiveProject(ca_state=[$0], c_first_name=[$1], c_last_name=[$2], i_current_price=[$3], i_size=[$4], i_units=[$5], i_manager_id=[$6], s_store_name=[$7], s_state=[$8], $f9=[$9])
+          HiveAggregate(group=[{0, 6, 7, 15, 16, 17, 18, 20, 21}], agg#0=[sum($13)])
+            HiveJoin(condition=[AND(=($8, $2), =($22, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_state=[$8], ca_zip=[$9], UPPER=[UPPER($10)])
+                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                    HiveFilter(condition=[IS NOT NULL($14)])
+                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                        HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_units=[$18], i_manager_id=[$20])
+                        HiveFilter(condition=[=($17, _UTF-16LE'orchid')])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveProject(s_store_sk=[$0], s_store_name=[$5], s_state=[$24], s_zip=[$25])
+                      HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($25))])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+    HiveProject(_o__c0=[*(0.05, /($0, $1))])
+      HiveAggregate(group=[{}], agg#0=[sum($10)], agg#1=[count($10)])
+        HiveProject(c_first_name=[$0], c_last_name=[$1], s_store_name=[$2], s_state=[$3], i_current_price=[$4], i_size=[$5], i_color=[$6], i_units=[$7], i_manager_id=[$8], ca_state=[$9], $f10=[$10])
+          HiveAggregate(group=[{3, 4, 12, 13, 16, 17, 18, 19, 20, 21}], agg#0=[sum($10)])
+            HiveJoin(condition=[AND(=($5, $23), =($14, $22))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveJoin(condition=[=($4, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                      HiveFilter(condition=[IS NOT NULL($14)])
+                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                    HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                        HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(s_store_sk=[$0], s_store_name=[$5], s_state=[$24], s_zip=[$25])
+                        HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($25))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+                  HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[$17], i_units=[$18], i_manager_id=[$20])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(ca_state=[$8], ca_zip=[$9], UPPER=[UPPER($10)])
+                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query25.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query25.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query25.q.out
new file mode 100644
index 0000000..a39931a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query25.q.out
@@ -0,0 +1,144 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], s_store_id=[$2], s_store_name=[$3], $f4=[$4], $f5=[$5], $f6=[$6])
+    HiveAggregate(group=[{1, 2, 22, 23}], agg#0=[sum($8)], agg#1=[sum($19)], agg#2=[sum($13)])
+      HiveJoin(condition=[=($21, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4])
+            HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[AND(AND(=($2, $14), =($1, $13)), =($4, $15))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_net_profit=[$22])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[AND(=($8, 4), =($6, 2000))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2], cs_net_profit=[$3], d_date_sk=[$4], sr_returned_date_sk=[$5], sr_item_sk=[$6], sr_customer_sk=[$7], sr_ticket_number=[$8], sr_net_loss=[$9], d_date_sk0=[$10])
+              HiveJoin(condition=[AND(=($7, $1), =($6, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_net_profit=[$33])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(BETWEEN(false, $8, 4, 10), =($6, 2000))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$1], sr_customer_sk=[$2], sr_ticket_number=[$3], sr_net_loss=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9], sr_net_loss=[$19])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(BETWEEN(false, $8, 4, 10), =($6, 2000))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+        HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
+          HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query26.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query26.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query26.q.out
new file mode 100644
index 0000000..f893623
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query26.q.out
@@ -0,0 +1,75 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[/(CAST($1):DOUBLE, $2)], $f2=[/($3, $4)], $f3=[/($5, $6)], $f4=[/($7, $8)])
+    HiveAggregate(group=[{1}], agg#0=[sum($6)], agg#1=[count($6)], agg#2=[sum($7)], agg#3=[count($7)], agg#4=[sum($9)], agg#5=[count($9)], agg#6=[sum($8)], agg#7=[count($8)])
+      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_item_id=[$1])
+          HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveJoin(condition=[=($3, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cs_sold_date_sk=[$0], cs_bill_cdemo_sk=[$4], cs_item_sk=[$15], cs_promo_sk=[$16], cs_quantity=[$18], cs_list_price=[$20], cs_sales_price=[$21], cs_coupon_amt=[$27])
+                HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($16))])
+                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+              HiveProject(cd_demo_sk=[$0])
+                HiveFilter(condition=[AND(=($1, _UTF-16LE'F'), =($2, _UTF-16LE'W'), =($3, _UTF-16LE'Primary'))])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[=($6, 1998)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(p_promo_sk=[$0])
+            HiveFilter(condition=[OR(=($9, _UTF-16LE'N'), =($14, _UTF-16LE'N'))])
+              HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query27.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query27.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query27.q.out
new file mode 100644
index 0000000..7fae258
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query27.q.out
@@ -0,0 +1,80 @@
+PREHOOK: query: explain cbo
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], s_state=[$1], g_state=[grouping($10, 0)], agg1=[/(CAST($2):DOUBLE, $3)], agg2=[/($4, $5)], agg3=[/($6, $7)], agg4=[/($8, $9)])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[count($2)], agg#2=[sum($3)], agg#3=[count($3)], agg#4=[sum($4)], agg#5=[count($4)], agg#6=[sum($5)], agg#7=[count($5)], GROUPING__ID=[GROUPING__ID()])
+      HiveProject($f0=[$1], $f1=[$13], $f2=[$6], $f3=[$7], $f4=[$9], $f5=[$8])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1])
+            HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($3, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_cdemo_sk=[$4], ss_store_sk=[$7], ss_quantity=[$10], ss_list_price=[$12], ss_sales_price=[$13], ss_coupon_amt=[$19])
+                  HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(cd_demo_sk=[$0])
+                  HiveFilter(condition=[AND(=($1, _UTF-16LE'M'), =($2, _UTF-16LE'U'), =($3, _UTF-16LE'2 yr Degree'))])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[=($6, 2001)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(s_store_sk=[$0], s_state=[$24])
+              HiveFilter(condition=[IN($24, _UTF-16LE'SD', _UTF-16LE'FL', _UTF-16LE'MI', _UTF-16LE'LA', _UTF-16LE'MO', _UTF-16LE'SC')])
+                HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query28.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query28.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query28.q.out
new file mode 100644
index 0000000..643e5b6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query28.q.out
@@ -0,0 +1,146 @@
+Warning: Shuffle Join MERGEJOIN[102][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[103][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[104][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[105][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[106][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain cbo
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f00=[$15], $f10=[$16], $f20=[$17], $f01=[$12], $f11=[$13], $f21=[$14], $f02=[$9], $f12=[$10], $f22=[$11], $f03=[$6], $f13=[$7], $f23=[$8], $f04=[$3], $f14=[$4], $f24=[$5])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+                  HiveFilter(condition=[AND(BETWEEN(false, $10, 0, 5), OR(BETWEEN(false, $12, 11, 21), BETWEEN(false, $19, 460, 1460), BETWEEN(false, $11, 14, 34)))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+                  HiveFilter(condition=[AND(BETWEEN(false, $10, 26, 30), OR(BETWEEN(false, $12, 28, 38), BETWEEN(false, $19, 2513, 3513), BETWEEN(false, $11, 42, 62)))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+              HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+                HiveFilter(condition=[AND(BETWEEN(false, $10, 21, 25), OR(BETWEEN(false, $12, 135, 145), BETWEEN(false, $19, 14180, 15180), BETWEEN(false, $11, 38, 58)))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+            HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+              HiveFilter(condition=[AND(BETWEEN(false, $10, 16, 20), OR(BETWEEN(false, $12, 142, 152), BETWEEN(false, $19, 3054, 4054), BETWEEN(false, $11, 80, 100)))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+        HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+          HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+            HiveFilter(condition=[AND(BETWEEN(false, $10, 11, 15), OR(BETWEEN(false, $12, 66, 76), BETWEEN(false, $19, 920, 1920), BETWEEN(false, $11, 4, 24)))])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+      HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+        HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+          HiveFilter(condition=[AND(BETWEEN(false, $10, 6, 10), OR(BETWEEN(false, $12, 91, 101), BETWEEN(false, $19, 1430, 2430), BETWEEN(false, $11, 32, 52)))])
+            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query29.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query29.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query29.q.out
new file mode 100644
index 0000000..8134a46
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query29.q.out
@@ -0,0 +1,142 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], s_store_id=[$2], s_store_name=[$3], $f4=[$4], $f5=[$5], $f6=[$6])
+    HiveAggregate(group=[{6, 7, 22, 23}], agg#0=[sum($13)], agg#1=[sum($19)], agg#2=[sum($3)])
+      HiveJoin(condition=[AND(=($17, $1), =($16, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_quantity=[$18])
+            HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+          HiveProject(d_date_sk=[$0])
+            HiveFilter(condition=[IN($6, 1999, 2000, 2001)])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+        HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$2], ss_sold_date_sk=[$3], ss_item_sk=[$4], ss_customer_sk=[$5], ss_store_sk=[$6], ss_ticket_number=[$7], ss_quantity=[$8], d_date_sk=[$9], sr_returned_date_sk=[$10], sr_item_sk=[$11], sr_customer_sk=[$12], sr_ticket_number=[$13], sr_return_quantity=[$14], d_date_sk0=[$15], s_store_sk=[$16], s_store_id=[$17], s_store_name=[$18])
+          HiveJoin(condition=[=($16, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveJoin(condition=[AND(AND(=($2, $9), =($1, $8)), =($4, $10))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_quantity=[$10])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($8, 4), =($6, 1999))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$1], sr_customer_sk=[$2], sr_ticket_number=[$3], sr_return_quantity=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9], sr_return_quantity=[$10])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(BETWEEN(false, $8, 4, 7), =($6, 1999))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+            HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query3.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query3.q.out
new file mode 100644
index 0000000..8f9528c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query3.q.out
@@ -0,0 +1,64 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$1], dir0=[ASC], dir1=[DESC-nulls-last], dir2=[ASC], fetch=[100])
+  HiveProject(d_year=[$2], i_brand_id=[$0], i_brand=[$1], $f3=[$3])
+    HiveAggregate(group=[{4, 5, 7}], agg#0=[sum($2)])
+      HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8])
+            HiveFilter(condition=[=($13, 436)])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(d_date_sk=[$0], d_year=[$6])
+          HiveFilter(condition=[=($8, 12)])
+            HiveTableScan(table=[[default, date_dim]], table:alias=[dt])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query30.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query30.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query30.q.out
new file mode 100644
index 0000000..bd68baa
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query30.q.out
@@ -0,0 +1,112 @@
+PREHOOK: query: explain cbo
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], sort10=[$10], sort11=[$11], sort12=[$12], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], dir10=[ASC], dir11=[ASC], dir12=[ASC], fetch=[100])
+  HiveProject(c_customer_id=[$1], c_salutation=[$3], c_first_name=[$4], c_last_name=[$5], c_preferred_cust_flag=[$6], c_birth_day=[$7], c_birth_month=[$8], c_birth_year=[$9], c_birth_country=[$10], c_login=[$11], c_email_address=[$12], c_last_review_date=[$13], ctr_total_return=[$17])
+    HiveJoin(condition=[=($15, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($14, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_current_addr_sk=[$4], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_day=[$11], c_birth_month=[$12], c_birth_year=[$13], c_birth_country=[$14], c_login=[$15], c_email_address=[$16], c_last_review_date=[$17])
+          HiveFilter(condition=[IS NOT NULL($4)])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ca_address_sk=[$0])
+          HiveFilter(condition=[=($8, _UTF-16LE'IL')])
+            HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+      HiveProject(wr_returning_customer_sk=[$0], ca_state=[$1], $f2=[$2], _o__c0=[$3], ctr_state=[$4])
+        HiveJoin(condition=[AND(=($1, $4), >($2, $3))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(wr_returning_customer_sk=[$1], ca_state=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+              HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                  HiveFilter(condition=[IS NOT NULL($8)])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(wr_returned_date_sk=[$0], wr_returning_customer_sk=[$7], wr_returning_addr_sk=[$10], wr_return_amt=[$15])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[=($6, 2002)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(_o__c0=[*(/($1, $2), 1.2)], ctr_state=[$0])
+            HiveAggregate(group=[{0}], agg#0=[sum($2)], agg#1=[count($2)])
+              HiveProject(ca_state=[$0], wr_returning_customer_sk=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                      HiveFilter(condition=[IS NOT NULL($8)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(wr_returned_date_sk=[$0], wr_returning_customer_sk=[$7], wr_returning_addr_sk=[$10], wr_return_amt=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10))])
+                          HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[=($6, 2002)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[25/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out
new file mode 100644
index 0000000..e8a6eaa
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query14.q.out
@@ -0,0 +1,1400 @@
+Warning: Shuffle Join MERGEJOIN[1431][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[1443][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[1433][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 13' is a cross product
+Warning: Shuffle Join MERGEJOIN[1456][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 14' is a cross product
+Warning: Shuffle Join MERGEJOIN[1435][tables = [$hdt$_2, $hdt$_3]] in Stage 'Reducer 18' is a cross product
+Warning: Shuffle Join MERGEJOIN[1469][tables = [$hdt$_2, $hdt$_3, $hdt$_1]] in Stage 'Reducer 19' is a cross product
+PREHOOK: query: explain
+with  cross_items as
+ (select i_item_sk ss_item_sk
+ from item,
+ (select iss.i_brand_id brand_id
+     ,iss.i_class_id class_id
+     ,iss.i_category_id category_id
+ from store_sales
+     ,item iss
+     ,date_dim d1
+ where ss_item_sk = iss.i_item_sk
+   and ss_sold_date_sk = d1.d_date_sk
+   and d1.d_year between 1999 AND 1999 + 2
+ intersect 
+ select ics.i_brand_id
+     ,ics.i_class_id
+     ,ics.i_category_id
+ from catalog_sales
+     ,item ics
+     ,date_dim d2
+ where cs_item_sk = ics.i_item_sk
+   and cs_sold_date_sk = d2.d_date_sk
+   and d2.d_year between 1999 AND 1999 + 2
+ intersect
+ select iws.i_brand_id
+     ,iws.i_class_id
+     ,iws.i_category_id
+ from web_sales
+     ,item iws
+     ,date_dim d3
+ where ws_item_sk = iws.i_item_sk
+   and ws_sold_date_sk = d3.d_date_sk
+   and d3.d_year between 1999 AND 1999 + 2) x
+ where i_brand_id = brand_id
+      and i_class_id = class_id
+      and i_category_id = category_id
+),
+ avg_sales as
+ (select avg(quantity*list_price) average_sales
+  from (select ss_quantity quantity
+             ,ss_list_price list_price
+       from store_sales
+           ,date_dim
+       where ss_sold_date_sk = d_date_sk
+         and d_year between 1999 and 2001 
+       union all 
+       select cs_quantity quantity 
+             ,cs_list_price list_price
+       from catalog_sales
+           ,date_dim
+       where cs_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2 
+       union all
+       select ws_quantity quantity
+             ,ws_list_price list_price
+       from web_sales
+           ,date_dim
+       where ws_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2) x)
+  select  channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
+ from(
+       select 'store' channel, i_brand_id,i_class_id
+             ,i_category_id,sum(ss_quantity*ss_list_price) sales
+             , count(*) number_sales
+       from store_sales
+           ,item
+           ,date_dim
+       where ss_item_sk in (select ss_item_sk from cross_items)
+         and ss_item_sk = i_item_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
+       from catalog_sales
+           ,item
+           ,date_dim
+       where cs_item_sk in (select ss_item_sk from cross_items)
+         and cs_item_sk = i_item_sk
+         and cs_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
+       from web_sales
+           ,item
+           ,date_dim
+       where ws_item_sk in (select ss_item_sk from cross_items)
+         and ws_item_sk = i_item_sk
+         and ws_sold_date_sk = d_date_sk
+         and d_year = 1998+2
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
+ ) y
+ group by rollup (channel, i_brand_id,i_class_id,i_category_id)
+ order by channel,i_brand_id,i_class_id,i_category_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with  cross_items as
+ (select i_item_sk ss_item_sk
+ from item,
+ (select iss.i_brand_id brand_id
+     ,iss.i_class_id class_id
+     ,iss.i_category_id category_id
+ from store_sales
+     ,item iss
+     ,date_dim d1
+ where ss_item_sk = iss.i_item_sk
+   and ss_sold_date_sk = d1.d_date_sk
+   and d1.d_year between 1999 AND 1999 + 2
+ intersect 
+ select ics.i_brand_id
+     ,ics.i_class_id
+     ,ics.i_category_id
+ from catalog_sales
+     ,item ics
+     ,date_dim d2
+ where cs_item_sk = ics.i_item_sk
+   and cs_sold_date_sk = d2.d_date_sk
+   and d2.d_year between 1999 AND 1999 + 2
+ intersect
+ select iws.i_brand_id
+     ,iws.i_class_id
+     ,iws.i_category_id
+ from web_sales
+     ,item iws
+     ,date_dim d3
+ where ws_item_sk = iws.i_item_sk
+   and ws_sold_date_sk = d3.d_date_sk
+   and d3.d_year between 1999 AND 1999 + 2) x
+ where i_brand_id = brand_id
+      and i_class_id = class_id
+      and i_category_id = category_id
+),
+ avg_sales as
+ (select avg(quantity*list_price) average_sales
+  from (select ss_quantity quantity
+             ,ss_list_price list_price
+       from store_sales
+           ,date_dim
+       where ss_sold_date_sk = d_date_sk
+         and d_year between 1999 and 2001 
+       union all 
+       select cs_quantity quantity 
+             ,cs_list_price list_price
+       from catalog_sales
+           ,date_dim
+       where cs_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2 
+       union all
+       select ws_quantity quantity
+             ,ws_list_price list_price
+       from web_sales
+           ,date_dim
+       where ws_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2) x)
+  select  channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
+ from(
+       select 'store' channel, i_brand_id,i_class_id
+             ,i_category_id,sum(ss_quantity*ss_list_price) sales
+             , count(*) number_sales
+       from store_sales
+           ,item
+           ,date_dim
+       where ss_item_sk in (select ss_item_sk from cross_items)
+         and ss_item_sk = i_item_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
+       from catalog_sales
+           ,item
+           ,date_dim
+       where cs_item_sk in (select ss_item_sk from cross_items)
+         and cs_item_sk = i_item_sk
+         and cs_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
+       from web_sales
+           ,item
+           ,date_dim
+       where ws_item_sk in (select ss_item_sk from cross_items)
+         and ws_item_sk = i_item_sk
+         and ws_sold_date_sk = d_date_sk
+         and d_year = 1998+2
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
+ ) y
+ group by rollup (channel, i_brand_id,i_class_id,i_category_id)
+ order by channel,i_brand_id,i_class_id,i_category_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 105 (BROADCAST_EDGE)
+Map 107 <- Reducer 102 (BROADCAST_EDGE)
+Map 108 <- Reducer 104 (BROADCAST_EDGE)
+Map 109 <- Reducer 63 (BROADCAST_EDGE), Reducer 81 (BROADCAST_EDGE)
+Map 110 <- Reducer 68 (BROADCAST_EDGE), Reducer 90 (BROADCAST_EDGE)
+Map 20 <- Reducer 25 (BROADCAST_EDGE)
+Map 36 <- Reducer 41 (BROADCAST_EDGE)
+Map 46 <- Reducer 106 (BROADCAST_EDGE)
+Map 50 <- Reducer 29 (BROADCAST_EDGE)
+Map 51 <- Reducer 43 (BROADCAST_EDGE)
+Map 52 <- Reducer 58 (BROADCAST_EDGE), Reducer 71 (BROADCAST_EDGE)
+Map 97 <- Reducer 100 (BROADCAST_EDGE)
+Reducer 10 <- Map 1 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE), Union 11 (CONTAINS)
+Reducer 100 <- Map 99 (CUSTOM_SIMPLE_EDGE)
+Reducer 101 <- Map 107 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE)
+Reducer 102 <- Map 99 (CUSTOM_SIMPLE_EDGE)
+Reducer 103 <- Map 108 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE)
+Reducer 104 <- Map 99 (CUSTOM_SIMPLE_EDGE)
+Reducer 105 <- Map 99 (CUSTOM_SIMPLE_EDGE)
+Reducer 106 <- Map 99 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Union 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (CUSTOM_SIMPLE_EDGE), Reducer 32 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (CUSTOM_SIMPLE_EDGE), Reducer 62 (CUSTOM_SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 15 <- Map 1 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE), Union 16 (CONTAINS)
+Reducer 17 <- Union 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (CUSTOM_SIMPLE_EDGE), Reducer 35 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (CUSTOM_SIMPLE_EDGE), Reducer 67 (CUSTOM_SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE), Union 3 (CONTAINS)
+Reducer 21 <- Map 20 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE), Union 3 (CONTAINS)
+Reducer 22 <- Map 20 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE), Union 11 (CONTAINS)
+Reducer 23 <- Map 20 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE), Union 16 (CONTAINS)
+Reducer 25 <- Map 24 (CUSTOM_SIMPLE_EDGE)
+Reducer 26 <- Map 24 (SIMPLE_EDGE), Map 50 (SIMPLE_EDGE), Union 27 (CONTAINS)
+Reducer 28 <- Union 27 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 24 (CUSTOM_SIMPLE_EDGE)
+Reducer 30 <- Map 24 (SIMPLE_EDGE), Map 50 (SIMPLE_EDGE), Union 31 (CONTAINS)
+Reducer 32 <- Union 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 33 <- Map 24 (SIMPLE_EDGE), Map 50 (SIMPLE_EDGE), Union 34 (CONTAINS)
+Reducer 35 <- Union 34 (CUSTOM_SIMPLE_EDGE)
+Reducer 37 <- Map 36 (SIMPLE_EDGE), Map 40 (SIMPLE_EDGE), Union 3 (CONTAINS)
+Reducer 38 <- Map 36 (SIMPLE_EDGE), Map 40 (SIMPLE_EDGE), Union 11 (CONTAINS)
+Reducer 39 <- Map 36 (SIMPLE_EDGE), Map 40 (SIMPLE_EDGE), Union 16 (CONTAINS)
+Reducer 4 <- Union 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 41 <- Map 40 (CUSTOM_SIMPLE_EDGE)
+Reducer 42 <- Map 40 (SIMPLE_EDGE), Map 51 (SIMPLE_EDGE), Union 27 (CONTAINS)
+Reducer 43 <- Map 40 (CUSTOM_SIMPLE_EDGE)
+Reducer 44 <- Map 40 (SIMPLE_EDGE), Map 51 (SIMPLE_EDGE), Union 31 (CONTAINS)
+Reducer 45 <- Map 40 (SIMPLE_EDGE), Map 51 (SIMPLE_EDGE), Union 34 (CONTAINS)
+Reducer 47 <- Map 46 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE), Union 27 (CONTAINS)
+Reducer 48 <- Map 46 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE), Union 31 (CONTAINS)
+Reducer 49 <- Map 46 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE), Union 34 (CONTAINS)
+Reducer 5 <- Reducer 28 (CUSTOM_SIMPLE_EDGE), Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 53 <- Map 52 (SIMPLE_EDGE), Map 57 (SIMPLE_EDGE)
+Reducer 54 <- Map 69 (SIMPLE_EDGE), Reducer 53 (SIMPLE_EDGE)
+Reducer 55 <- Reducer 54 (ONE_TO_ONE_EDGE), Reducer 70 (SIMPLE_EDGE)
+Reducer 56 <- Reducer 55 (SIMPLE_EDGE)
+Reducer 58 <- Map 57 (CUSTOM_SIMPLE_EDGE)
+Reducer 59 <- Map 109 (SIMPLE_EDGE), Map 57 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (CUSTOM_SIMPLE_EDGE), Reducer 56 (CUSTOM_SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 60 <- Map 69 (SIMPLE_EDGE), Reducer 59 (SIMPLE_EDGE)
+Reducer 61 <- Reducer 60 (ONE_TO_ONE_EDGE), Reducer 80 (SIMPLE_EDGE)
+Reducer 62 <- Reducer 61 (SIMPLE_EDGE)
+Reducer 63 <- Map 57 (CUSTOM_SIMPLE_EDGE)
+Reducer 64 <- Map 110 (SIMPLE_EDGE), Map 57 (SIMPLE_EDGE)
+Reducer 65 <- Map 69 (SIMPLE_EDGE), Reducer 64 (SIMPLE_EDGE)
+Reducer 66 <- Reducer 65 (ONE_TO_ONE_EDGE), Reducer 89 (SIMPLE_EDGE)
+Reducer 67 <- Reducer 66 (SIMPLE_EDGE)
+Reducer 68 <- Map 57 (CUSTOM_SIMPLE_EDGE)
+Reducer 70 <- Map 69 (SIMPLE_EDGE), Reducer 75 (ONE_TO_ONE_EDGE)
+Reducer 71 <- Reducer 70 (CUSTOM_SIMPLE_EDGE)
+Reducer 72 <- Map 69 (SIMPLE_EDGE), Reducer 98 (SIMPLE_EDGE)
+Reducer 73 <- Reducer 72 (SIMPLE_EDGE), Union 74 (CONTAINS)
+Reducer 75 <- Union 74 (SIMPLE_EDGE)
+Reducer 76 <- Map 69 (SIMPLE_EDGE), Reducer 101 (SIMPLE_EDGE)
+Reducer 77 <- Reducer 76 (SIMPLE_EDGE), Union 74 (CONTAINS)
+Reducer 78 <- Map 69 (SIMPLE_EDGE), Reducer 103 (SIMPLE_EDGE)
+Reducer 79 <- Reducer 78 (SIMPLE_EDGE), Union 74 (CONTAINS)
+Reducer 8 <- Union 7 (SIMPLE_EDGE)
+Reducer 80 <- Map 69 (SIMPLE_EDGE), Reducer 85 (ONE_TO_ONE_EDGE)
+Reducer 81 <- Reducer 80 (CUSTOM_SIMPLE_EDGE)
+Reducer 82 <- Map 69 (SIMPLE_EDGE), Reducer 98 (SIMPLE_EDGE)
+Reducer 83 <- Reducer 82 (SIMPLE_EDGE), Union 84 (CONTAINS)
+Reducer 85 <- Union 84 (SIMPLE_EDGE)
+Reducer 86 <- Reducer 82 (SIMPLE_EDGE), Union 87 (CONTAINS)
+Reducer 88 <- Union 87 (SIMPLE_EDGE)
+Reducer 89 <- Map 69 (SIMPLE_EDGE), Reducer 88 (ONE_TO_ONE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+Reducer 90 <- Reducer 89 (CUSTOM_SIMPLE_EDGE)
+Reducer 91 <- Map 69 (SIMPLE_EDGE), Reducer 101 (SIMPLE_EDGE)
+Reducer 92 <- Reducer 91 (SIMPLE_EDGE), Union 84 (CONTAINS)
+Reducer 93 <- Reducer 91 (SIMPLE_EDGE), Union 87 (CONTAINS)
+Reducer 94 <- Map 69 (SIMPLE_EDGE), Reducer 103 (SIMPLE_EDGE)
+Reducer 95 <- Reducer 94 (SIMPLE_EDGE), Union 84 (CONTAINS)
+Reducer 96 <- Reducer 94 (SIMPLE_EDGE), Union 87 (CONTAINS)
+Reducer 98 <- Map 97 (SIMPLE_EDGE), Map 99 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 9 vectorized
+      File Output Operator [FS_1703]
+        Limit [LIM_1702] (rows=7 width=192)
+          Number of rows:100
+          Select Operator [SEL_1701] (rows=7 width=192)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          <-Reducer 8 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_1700]
+              Select Operator [SEL_1699] (rows=7 width=192)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                Group By Operator [GBY_1698] (rows=7 width=200)
+                  Output:["_col0","_col1","_col2","_col3","_col5","_col6"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                <-Union 7 [SIMPLE_EDGE]
+                  <-Reducer 14 [CONTAINS]
+                    Reduce Output Operator [RS_1462]
+                      PartitionCols:_col0, _col1, _col2, _col3, _col4
+                      Group By Operator [GBY_1461] (rows=7 width=200)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
+                        Top N Key Operator [TNK_1460] (rows=3 width=221)
+                          keys:_col0, _col1, _col2, _col3, 0L,sort order:+++++,top n:100
+                          Select Operator [SEL_1458] (rows=1 width=223)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                            Filter Operator [FIL_1457] (rows=1 width=244)
+                              predicate:(_col5 > _col1)
+                              Merge Join Operator [MERGEJOIN_1456] (rows=1 width=244)
+                                Conds:(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6"]
+                              <-Reducer 13 [CUSTOM_SIMPLE_EDGE]
+                                PARTITION_ONLY_SHUFFLE [RS_371]
+                                  Merge Join Operator [MERGEJOIN_1433] (rows=1 width=112)
+                                    Conds:(Inner),Output:["_col1"]
+                                  <-Reducer 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_1709]
+                                      Select Operator [SEL_1708] (rows=1 width=8)
+                                        Filter Operator [FIL_1707] (rows=1 width=8)
+                                          predicate:(sq_count_check(_col0) <= 1)
+                                          Group By Operator [GBY_1706] (rows=1 width=8)
+                                            Output:["_col0"],aggregations:["count()"]
+                                            Select Operator [SEL_1705] (rows=1 width=8)
+                                              Group By Operator [GBY_1704] (rows=1 width=8)
+                                                Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                              <-Union 11 [CUSTOM_SIMPLE_EDGE]
+                                                <-Reducer 10 [CONTAINS]
+                                                  Reduce Output Operator [RS_1455]
+                                                    Group By Operator [GBY_1454] (rows=1 width=8)
+                                                      Output:["_col0"],aggregations:["count(_col0)"]
+                                                      Select Operator [SEL_1453] (rows=26270325 width=1)
+                                                        Output:["_col0"]
+                                                        Select Operator [SEL_1451] (rows=14736682 width=0)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_1450] (rows=14736682 width=0)
+                                                            Conds:RS_1633._col0=RS_1614._col0(Inner),Output:["_col1"]
+                                                          <-Map 99 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1614]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_1603] (rows=1957 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_1602] (rows=1957 width=8)
+                                                                  predicate:d_year BETWEEN 1999 AND 2001
+                                                                  TableScan [TS_96] (rows=73049 width=8)
+                                                                    default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                                          <-Map 1 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1633]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_1631] (rows=550076554 width=7)
+                                                                Output:["_col0","_col1"]
+                                                                Filter Operator [FIL_1630] (rows=550076554 width=7)
+                                                                  predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_7_date_dim_d_date_sk_min) AND DynamicValue(RS_7_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_7_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                                  TableScan [TS_0] (rows=575995635 width=7)
+                                                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_quantity"]
+                                                                  <-Reducer 105 [BROADCAST_EDGE] vectorized
+                                                                    BROADCAST [RS_1629]
+                                                                      Group By Operator [GBY_1628] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                      <-Map 99 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                        SHUFFLE [RS_1626]
+                                                                          Group By Operator [GBY_1621] (rows=1 width=12)
+                                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                            Select Operator [SEL_1611] (rows=1957 width=4)
+                                                                              Output:["_col0"]
+                                                                               Please refer to the previous Select Operator [SEL_1603]
+                                                <-Reducer 22 [CONTAINS]
+                                                  Reduce Output Operator [RS_1487]
+                                                    Group By Operator [GBY_1486] (rows=1 width=8)
+                                                      Output:["_col0"],aggregations:["count(_col0)"]
+                                                      Select Operator [SEL_1485] (rows=26270325 width=1)
+                                                        Output:["_col0"]
+                                                        Select Operator [SEL_1483] (rows=7676736 width=3)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_1482] (rows=7676736 width=3)
+                                                            Conds:RS_1767._col0=RS_1754._col0(Inner),Output:["_col1"]
+                                                          <-Map 24 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1754]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_1749] (rows=1957 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_1748] (rows=1957 width=8)
+                                                                  predicate:d_year BETWEEN 1998 AND 2000
+                                                                  TableScan [TS_13] (rows=73049 width=8)
+                                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                                          <-Map 20 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1767]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_1765] (rows=286549727 width=7)
+                                                                Output:["_col0","_col1"]
+                                                                Filter Operator [FIL_1764] (rows=286549727 width=7)
+                                                                  predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_17_date_dim_d_date_sk_min) AND DynamicValue(RS_17_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_17_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                                  TableScan [TS_10] (rows=287989836 width=7)
+                                                                    default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_quantity"]
+                                                                  <-Reducer 25 [BROADCAST_EDGE] vectorized
+                                                                    BROADCAST [RS_1763]
+                                                                      Group By Operator [GBY_1762] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                      <-Map 24 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                        SHUFFLE [RS_1760]
+                                                                          Group By Operator [GBY_1758] (rows=1 width=12)
+                                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                            Select Operator [SEL_1751] (rows=1957 width=4)
+                                                                              Output:["_col0"]
+                                                                               Please refer to the previous Select Operator [SEL_1749]
+                                                <-Reducer 38 [CONTAINS]
+                                                  Reduce Output Operator [RS_1523]
+                                                    Group By Operator [GBY_1522] (rows=1 width=8)
+                                                      Output:["_col0"],aggregations:["count(_col0)"]
+                                                      Select Operator [SEL_1521] (rows=26270325 width=1)
+                                                        Output:["_col0"]
+                                                        Select Operator [SEL_1519] (rows=3856907 width=3)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_1518] (rows=3856907 width=3)
+                                                            Conds:RS_1795._col0=RS_1782._col0(Inner),Output:["_col1"]
+                                                          <-Map 40 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1782]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_1777] (rows=1957 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_1776] (rows=1957 width=8)
+                                                                  predicate:d_year BETWEEN 1998 AND 2000
+                                                                  TableScan [TS_24] (rows=73049 width=8)
+                                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                                          <-Map 36 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1795]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_1793] (rows=143966864 width=7)
+                                                                Output:["_col0","_col1"]
+                                                                Filter Operator [FIL_1792] (rows=143966864 width=7)
+                                                                  predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_28_date_dim_d_date_sk_min) AND DynamicValue(RS_28_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_28_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                                                  TableScan [TS_21] (rows=144002668 width=7)
+                                                                    default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_quantity"]
+                                                                  <-Reducer 41 [BROADCAST_EDGE] vectorized
+                                                                    BROADCAST [RS_1791]
+                                                                      Group By Operator [GBY_1790] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                      <-Map 40 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                        SHUFFLE [RS_1788]
+                                                                          Group By Operator [GBY_1786] (rows=1 width=12)
+                                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                            Select Operator [SEL_1779] (rows=1957 width=4)
+                                                                              Output:["_col0"]
+                                                                               Please refer to the previous Select Operator [SEL_1777]
+                                  <-Reducer 32 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_1712]
+                                      Select Operator [SEL_1711] (rows=1 width=112)
+                                        Output:["_col0"]
+                                        Group By Operator [GBY_1710] (rows=1 width=120)
+                                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"]
+                                        <-Union 31 [CUSTOM_SIMPLE_EDGE]
+                                          <-Reducer 30 [CONTAINS]
+                                            Reduce Output Operator [RS_1505]
+                                              Group By Operator [GBY_1504] (rows=1 width=120)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col0)","count(_col0)"]
+                                                Select Operator [SEL_1503] (rows=26270325 width=44)
+                                                  Output:["_col0"]
+                                                  Select Operator [SEL_1501] (rows=7676736 width=94)
+                                                    Output:["_col0","_col1"]
+                                                    Merge Join Operator [MERGEJOIN_1500] (rows=7676736 width=94)
+                                                      Conds:RS_1774._col0=RS_1755._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 24 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1755]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1749]
+                                                    <-Map 50 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1774]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_1772] (rows=286549727 width=119)
+                                                          Output:["_col0","_col1","_col2"]
+                                                          Filter Operator [FIL_1771] (rows=286549727 width=119)
+                                                            predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_62_date_dim_d_date_sk_min) AND DynamicValue(RS_62_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_62_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                            TableScan [TS_55] (rows=287989836 width=119)
+                                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_quantity","cs_list_price"]
+                                                            <-Reducer 29 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_1770]
+                                                                Group By Operator [GBY_1769] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 24 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_1761]
+                                                                    Group By Operator [GBY_1759] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_1753] (rows=1957 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_1749]
+                                          <-Reducer 44 [CONTAINS]
+                                            Reduce Output Operator [RS_1541]
+                                              Group By Operator [GBY_1540] (rows=1 width=120)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col0)","count(_col0)"]
+                                                Select Operator [SEL_1539] (rows=26270325 width=44)
+                                                  Output:["_col0"]
+                                                  Select Operator [SEL_1537] (rows=3856907 width=114)
+                                                    Output:["_col0","_col1"]
+                                                    Merge Join Operator [MERGEJOIN_1536] (rows=3856907 width=114)
+                                                      Conds:RS_1802._col0=RS_1783._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 40 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1783]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1777]
+                                                    <-Map 51 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1802]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_1800] (rows=143966864 width=119)
+                                                          Output:["_col0","_col1","_col2"]
+                                                          Filter Operator [FIL_1799] (rows=143966864 width=119)
+                                                            predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_73_date_dim_d_date_sk_min) AND DynamicValue(RS_73_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_73_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                                            TableScan [TS_66] (rows=144002668 width=119)
+                                                              default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_quantity","ws_list_price"]
+                                                            <-Reducer 43 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_1798]
+                                                                Group By Operator [GBY_1797] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 40 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_1789]
+                                                                    Group By Operator [GBY_1787] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_1781] (rows=1957 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_1777]
+                                          <-Reducer 48 [CONTAINS]
+                                            Reduce Output Operator [RS_1559]
+                                              Group By Operator [GBY_1558] (rows=1 width=120)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col0)","count(_col0)"]
+                                                Select Operator [SEL_1557] (rows=26270325 width=44)
+                                                  Output:["_col0"]
+                                                  Select Operator [SEL_1555] (rows=14736682 width=0)
+                                                    Output:["_col0","_col1"]
+                                                    Merge Join Operator [MERGEJOIN_1554] (rows=14736682 width=0)
+                                                      Conds:RS_1809._col0=RS_1615._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 99 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1615]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1603]
+                                                    <-Map 46 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1809]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_1807] (rows=550076554 width=114)
+                                                          Output:["_col0","_col1","_col2"]
+                                                          Filter Operator [FIL_1806] (rows=550076554 width=114)
+                                                            predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_52_date_dim_d_date_sk_min) AND DynamicValue(RS_52_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_52_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                            TableScan [TS_45] (rows=575995635 width=114)
+                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_quantity","ss_list_price"]
+                                                            <-Reducer 106 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_1805]
+                                                                Group By Operator [GBY_1804] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 99 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_1627]
+                                                                    Group By Operator [GBY_1622] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_1613] (rows=1957 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_1603]
+                              <-Reducer 62 [CUSTOM_SIMPLE_EDGE] vectorized
+                                PARTITION_ONLY_SHUFFLE [RS_1725]
+                                  Group By Operator [GBY_1724] (rows=1 width=132)
+                                    Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                  <-Reducer 61 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_365]
+                                      PartitionCols:_col0, _col1, _col2
+                                      Group By Operator [GBY_364] (rows=1 width=132)
+                                        Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col3)","count()"],keys:_col0, _col1, _col2
+                                        Select Operator [SEL_362] (rows=1 width=128)
+                                          Output:["_col0","_col1","_col2","_col3"]
+                                          Merge Join Operator [MERGEJOIN_1429] (rows=1 width=128)
+                                            Conds:RS_359._col1=RS_360._col0(Inner),Output:["_col2","_col3","_col6","_col7","_col8"]
+                                          <-Reducer 80 [SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_360]
+                                              PartitionCols:_col0
+                                              Merge Join Operator [MERGEJOIN_1412] (rows=724 width=4)
+                                                Conds:RS_1682._col1, _col2, _col3=RS_1718._col0, _col1, _col2(Inner),Output:["_col0"]
+                                              <-Map 69 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_1682]
+                                                  PartitionCols:_col1, _col2, _col3
+                                                  Select Operator [SEL_1671] (rows=458612 width=15)
+                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                    Filter Operator [FIL_1662] (rows=458612 width=15)
+                                                      predicate:(i_brand_id is not null and i_category_id is not null and i_class_id is not null)
+                                                      TableScan [TS_90] (rows=462000 width=15)
+                                                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand_id","i_class_id","i_category_id"]
+                                              <-Reducer 85 [ONE_TO_ONE_EDGE] vectorized
+                                                FORWARD [RS_1718]
+                                                  PartitionCols:_col0, _col1, _col2
+                                                  Select Operator [SEL_1717] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"]
+                                                    Filter Operator [FIL_1716] (rows=1 width=20)
+                                                      predicate:(_col3 = 3L)
+                                                      Group By Operator [GBY_1715] (rows=121728 width=19)
+                                                        Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                      <-Union 84 [SIMPLE_EDGE]
+                                                        <-Reducer 83 [CONTAINS] vectorized
+                                                          Reduce Output Operator [RS_1837]
+                                                            PartitionCols:_col0, _col1, _col2
+                                                            Group By Operator [GBY_1836] (rows=121728 width=19)
+                                                              Output:["_col0","_col1","_col2","_col3"],aggregations:["count(_col3)"],keys:_col0, _col1, _col2
+                                                              Group By Operator [GBY_1835] (rows=121728 width=19)
+                                                                Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                              <-Reducer 82 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_298]
+                                                                  PartitionCols:_col0, _col1, _col2
+                                                                  Group By Operator [GBY_297] (rows=121728 width=19)
+                                                                    Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col4, _col5, _col6
+                                                                    Merge Join Operator [MERGEJOIN_1407] (rows=14628613 width=11)
+                                                                      Conds:RS_293._col1=RS_1683._col0(Inner),Output:["_col4","_col5","_col6"]
+                                                                    <-Map 69 [SIMPLE_EDGE] vectorized
+                                                                      SHUFFLE [RS_1683]
+                                                                        PartitionCols:_col0
+                                                                        Select Operator [SEL_1672] (rows=458612 width=15)
+                                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                                          Filter Operator [FIL_1663] (rows=458612 width=15)
+                                                                            predicate:(i_brand_id is not null and i_category_id is not null and i_class_id is not null)
+                                                                             Please refer to the previous TableScan [TS_90]
+                                                                    <-Reducer 98 [SIMPLE_EDGE]
+                                                                      SHUFFLE [RS_293]
+                                                                        PartitionCols:_col1
+                                                                        Merge Join Operator [MERGEJOIN_1391] (rows=14736682 width=4)
+                                                                          Conds:RS_1815._col0=RS_1604._col0(Inner),Output:["_col1"]
+                                                                        <-Map 99 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_1604]
+                                                                            PartitionCols:_col0
+                                                                             Please refer to the previous Select Operator [SEL_1603]
+                                                                        <-Map 97 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_1815]
+                                                                            PartitionCols:_col0
+                                                                            Select Operator [SEL_1814] (rows=550076554 width=7)
+                                                                              Output:["_col0","_col1"]
+                                                                              Filter Operator [FIL_1813] (rows=550076554 width=7)
+                                                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_103_d1_d_date_sk_min) AND DynamicValue(RS_103_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_103_d1_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                                                TableScan [TS_93] (rows=575995635 width=7)
+                                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk"]
+                                                                                <-Reducer 100 [BROADCAST_EDGE] vectorized
+                                                                                  BROADCAST [RS_1812]
+                                                                                    Group By Operator [GBY_1811] (rows=1 width=12)
+                                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                    <-Map 99 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                      SHUFFLE [RS_1623]
+                                                                                        Group By Operator [GBY_1618] (rows=1 width=12)
+                                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                          Select Operator [SEL_1605] (rows=1957 width=4)
+                                                                                            Output:["_col0"]
+                                                                                             Please refer to the previous Select Operator [SEL_1603]
+                                                        <-Reducer 92 [CONTAINS] vectorized
+                                                          Reduce Output Operator [RS_1843]
+                                                            PartitionCols:_col0, _col1, _col2
+                                                            Group By Operator [GBY_1842] (rows=121728 width=19)
+                                                              Output:["_col0","_col1","_col2","_col3"],aggregations:["count(_col3)"],keys:_col0, _col1, _col2
+                                                              Group By Operator [GBY_1841] (rows=121728 width=19)
+                                                                Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                              <-Reducer 91 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_318]
+                                                                  PartitionCols:_col0, _col1, _col2
+                                                                  Group By Operator [GBY_317] (rows=121728 width=19)
+                                                                    Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col4, _col5, _col6
+                                                                    Merge Join Operator [MERGEJOIN_1409] (rows=7620440 width=11)
+                                                                      Conds:RS_313._col1=RS_1684._col0(Inner),Output:["_col4","_col5","_col6"]
+                                                                    <-Map 69 [SIMPLE_EDGE] vectorized
+                                                                      SHUFFLE [RS_1684]
+                                                                        PartitionCols:_col0
+                                                                        Select Operator [SEL_1673] (rows=458612 width=15)
+                                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                                          Filter Operator [FIL_1664] (rows=458612 width=15)
+                                                                            predicate:(i_brand_id is not null and i_category_id is not null and i_class_id is not null)
+                                                                             Please refer to the previous TableScan [TS_90]
+                                                                    <-Reducer 101 [SIMPLE_EDGE]
+                                                                      SHUFFLE [RS_313]
+                                                                        PartitionCols:_col1
+                                                                        Merge Join Operator [MERGEJOIN_1393] (rows=7676736 width=4)
+                                                                          Conds:RS_1823._col0=RS_1606._col0(Inner),Output:["_col1"]
+                                                                        <-Map 99 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_1606]
+                                                                            PartitionCols:_col0
+                                                                             Please refer to the previous Select Operator [SEL_1603]
+                                                                        <-Map 107 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_1823]
+                                                                            PartitionCols:_col0
+                                                                            Select Operator [SEL_1822] (rows=286549727 width=7)
+                                                                              Output:["_col0","_col1"]
+                                                                              Filter Operator [FIL_1821] (rows=286549727 width=7)
+                                                                                predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_123_d2_d_date_sk_min) AND DynamicValue(RS_123_d2_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_123_d2_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                                                TableScan [TS_113] (rows=287989836 width=7)
+                                                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk"]
+                                                                                <-Reducer 102 [BROADCAST_EDGE] vectorized
+                                                                                  BROADCAST [RS_1820]
+                                                                                    Group By Operator [GBY_1819] (rows=1 width=12)
+                                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                    <-Map 99 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                      SHUFFLE [RS_1624]
+                                                                                        Group By Operator [GBY_1619] (rows=1 width=12)
+                                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                          Select Operator [SEL_1607] (rows=1957 width=4)
+                                                                                            Output:["_col0"]
+                                                                                             Please refer to the previous Select Operator [SEL_1603]
+                                                        <-Reducer 95 [CONTAINS] vectorized
+                                                          Reduce Output Operator [RS_1849]
+                                                            PartitionCols:_col0, _col1, _col2
+                                                            Group By Operator [GBY_1848] (rows=121728 width=19)
+                                                              Output:["_col0","_col1","_col2","_col3"],aggregations:["count(_col3)"],keys:_col0, _col1, _col2
+                                                              Group By Operator [GBY_1847] (rows=121728 width=19)
+                                                                Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                              <-Reducer 94 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_339]
+                                                                  PartitionCols:_col0, _col1, _col2
+                                                                  Group By Operator [GBY_338] (rows=121728 width=19)
+                                                                    Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col4, _col5, _col6
+                                                                    Merge Join Operator [MERGEJOIN_1411] (rows=3828623 width=11)
+                                                                      Conds:RS_334._col1=RS_1685._col0(Inner),Output:["_col4","_col5","_col6"]
+                                                                    <-Map 69 [SIMPLE_EDGE] vectorized
+                                                                      SHUFFLE [RS_1685]
+                                                                        PartitionCols:_col0
+                                                                        Select Operator [SEL_1674] (rows=458612 width=15)
+                                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                                          Filter Operator [FIL_1665] (rows=458612 width=15)
+                                                                            predicate:(i_brand_id is not null and i_category_id is not null and i_class_id is not null)
+                                                                             Please refer to the previous TableScan [TS_90]
+                                                                    <-Reducer 103 [SIMPLE_EDGE]
+                                                                      SHUFFLE [RS_334]
+                                                                        PartitionCols:_col1
+                                                                        Merge Join Operator [MERGEJOIN_1395] (rows=3856907 width=4)
+                                                                          Conds:RS_1831._col0=RS_1608._col0(Inner),Output:["_col1"]
+                                                                        <-Map 99 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_1608]
+                                                                            PartitionCols:_col0
+                                                                             Please refer to the previous Select Operator [SEL_1603]
+                                                                        <-Map 108 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_1831]
+                                                                            PartitionCols:_col0
+                                                                            Select Operator [SEL_1830] (rows=143966864 width=7)
+                                                                              Output:["_col0","_col1"]
+                                                                              Filter Operator [FIL_1829] (rows=143966864 width=7)
+                                                                                predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_144_d3_d_date_sk_min) AND DynamicValue(RS_144_d3_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_144_d3_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                                                                TableScan [TS_134] (rows=144002668 width=7)
+                                                                                  default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk"]
+                                                                                <-Reducer 104 [BROADCAST_EDGE] vectorized
+                                                                                  BROADCAST [RS_1828]
+                                                                                    Group By Operator [GBY_1827] (rows=1 width=12)
+                                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                    <-Map 99 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                      SHUFFLE [RS_1625]
+                                                                                        Group By Operator [GBY_1620] (rows=1 width=12)
+                                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                          Select Operator [SEL_1609] (rows=1957 width=4)
+                                                                                            Output:["_col0"]
+                                                                                             Please refer to the previous Select Operator [SEL_1603]
+                                          <-Reducer 60 [ONE_TO_ONE_EDGE]
+                                            FORWARD [RS_359]
+                                              PartitionCols:_col1
+                                              Merge Join Operator [MERGEJOIN_1405] (rows=7790806 width=110)
+                                                Conds:RS_356._col1=RS_1675._col0(Inner),Output:["_col1","_col2","_col3","_col6","_col7","_col8"]
+                                              <-Map 69 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_1675]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_1666] (rows=462000 width=15)
+                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                     Please refer to the previous TableScan [TS_90]
+                                              <-Reducer 59 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_356]
+                                                  PartitionCols:_col1
+                                                  Merge Join Operator [MERGEJOIN_1404] (rows=7790806 width=98)
+                                                    Conds:RS_1723._col0=RS_1648._col0(Inner),Output:["_col1","_col2","_col3"]
+                                                  <-Map 57 [SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_1648]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_1645] (rows=50 width=4)
+                                                        Output:["_col0"]
+                                                        Filter Operator [FIL_1644] (rows=50 width=12)
+                                                          predicate:((d_moy = 11) and (d_year = 2000))
+                                                          TableScan [TS_85] (rows=73049 width=12)
+                                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                                  <-Map 109 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_1723]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_1722] (rows=286549727 width=123)
+                                                        Output:["_col0","_col1","_col2","_col3"]
+                                                        Filter Operator [FIL_1721] (rows=286549727 width=123)
+                                                          predicate:((cs_item_sk BETWEEN DynamicValue(RS_360_item_i_item_sk_min) AND DynamicValue(RS_360_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_360_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_354_date_dim_d_date_sk_min) AND DynamicValue(RS_354_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_354_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                          TableScan [TS_270] (rows=287989836 width=123)
+                                                            default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_quantity","cs_list_price"]
+                                                          <-Reducer 63 [BROADCAST_EDGE] vectorized
+                                                            BROADCAST [RS_1714]
+                                                              Group By Operator [GBY_1713] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                              <-Map 57 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                PARTITION_ONLY_SHUFFLE [RS_1656]
+                                                                  Group By Operator [GBY_1653] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                    Select Operator [SEL_1649] (rows=50 width=4)
+                                                                      Output:["_col0"]
+                                                                       Please refer to the previous Select Operator [SEL_1645]
+                                                          <-Reducer 81 [BROADCAST_EDGE] vectorized
+                                                            BROADCAST [RS_1720]
+                                                              Group By Operator [GBY_1719] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                              <-Reducer 80 [CUSTOM_SIMPLE_EDGE]
+                                                                PARTITION_ONLY_SHUFFLE [RS_1077]
+                                                                  Group By Operator [GBY_1076] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                    Select Operator [SEL_1075] (rows=724 width=4)
+                                                                      Output:["_col0"]
+                                                                       Please refer to the previous Merge Join Operator [MERGEJOIN_1412]
+                  <-Reducer 19 [CONTAINS]
+                    Reduce Output Operator [RS_1475]
+                      PartitionCols:_col0, _col1, _col2, _col3, _col4
+                      Group By Operator [GBY_1474] (rows=7 width=200)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3, 0L
+                        Top N Key Operator [TNK_1473] (rows=3 width=221)
+                          keys:_col0, _col1, _col2, _col3, 0L,sort order:+++++,top n:100
+                          Select Operator [SEL_1471] (rows=1 width=219)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                            Filter Operator [FIL_1470] (rows=1 width=244)
+                              predicate:(_col5 > _col1)
+                              Merge Join Operator [MERGEJOIN_1469] (rows=1 width=244)
+                                Conds:(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6"]
+                              <-Reducer 18 [CUSTOM_SIMPLE_EDGE]
+                                PARTITION_ONLY_SHUFFLE [RS_560]
+                                  Merge Join Operator [MERGEJOIN_1435] (rows=1 width=112)
+                                    Conds:(Inner),Output:["_col1"]
+                                  <-Reducer 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_1731]
+                                      Select Operator [SEL_1730] (rows=1 width=8)
+                                        Filter Operator [FIL_1729] (rows=1 width=8)
+                                          predicate:(sq_count_check(_col0) <= 1)
+                                          Group By Operator [GBY_1728] (rows=1 width=8)
+                                            Output:["_col0"],aggregations:["count()"]
+                                            Select Operator [SEL_1727] (rows=1 width=8)
+                                              Group By Operator [GBY_1726] (rows=1 width=8)
+                                                Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                              <-Union 16 [CUSTOM_SIMPLE_EDGE]
+                                                <-Reducer 15 [CONTAINS]
+                                                  Reduce Output Operator [RS_1468]
+                                                    Group By Operator [GBY_1467] (rows=1 width=8)
+                                                      Output:["_col0"],aggregations:["count(_col0)"]
+                                                      Select Operator [SEL_1466] (rows=26270325 width=1)
+                                                        Output:["_col0"]
+                                                        Select Operator [SEL_1464] (rows=14736682 width=0)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_1463] (rows=14736682 width=0)
+                                                            Conds:RS_1634._col0=RS_1616._col0(Inner),Output:["_col1"]
+                                                          <-Map 99 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1616]
+                                                              PartitionCols:_col0
+                                                               Please refer to the previous Select Operator [SEL_1603]
+                                                          <-Map 1 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1634]
+                                                              PartitionCols:_col0
+                                                               Please refer to the previous Select Operator [SEL_1631]
+                                                <-Reducer 23 [CONTAINS]
+                                                  Reduce Output Operator [RS_1493]
+                                                    Group By Operator [GBY_1492] (rows=1 width=8)
+                                                      Output:["_col0"],aggregations:["count(_col0)"]
+                                                      Select Operator [SEL_1491] (rows=26270325 width=1)
+                                                        Output:["_col0"]
+                                                        Select Operator [SEL_1489] (rows=7676736 width=3)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_1488] (rows=7676736 width=3)
+                                                            Conds:RS_1768._col0=RS_1756._col0(Inner),Output:["_col1"]
+                                                          <-Map 24 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1756]
+                                                              PartitionCols:_col0
+                                                               Please refer to the previous Select Operator [SEL_1749]
+                                                          <-Map 20 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1768]
+                                                              PartitionCols:_col0
+                                                               Please refer to the previous Select Operator [SEL_1765]
+                                                <-Reducer 39 [CONTAINS]
+                                                  Reduce Output Operator [RS_1529]
+                                                    Group By Operator [GBY_1528] (rows=1 width=8)
+                                                      Output:["_col0"],aggregations:["count(_col0)"]
+                                                      Select Operator [SEL_1527] (rows=26270325 width=1)
+                                                        Output:["_col0"]
+                                                        Select Operator [SEL_1525] (rows=3856907 width=3)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_1524] (rows=3856907 width=3)
+                                                            Conds:RS_1796._col0=RS_1784._col0(Inner),Output:["_col1"]
+                                                          <-Map 40 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1784]
+                                                              PartitionCols:_col0
+                                                               Please refer to the previous Select Operator [SEL_1777]
+                                                          <-Map 36 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_1796]
+                                                              PartitionCols:_col0
+                                                               Please refer to the previous Select Operator [SEL_1793]
+                                  <-Reducer 35 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_1734]
+                                      Select Operator [SEL_1733] (rows=1 width=112)
+                                        Output:["_col0"]
+                                        Group By Operator [GBY_1732] (rows=1 width=120)
+                                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"]
+                                        <-Union 34 [CUSTOM_SIMPLE_EDGE]
+                                          <-Reducer 33 [CONTAINS]
+                                            Reduce Output Operator [RS_1511]
+                                              Group By Operator [GBY_1510] (rows=1 width=120)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col0)","count(_col0)"]
+                                                Select Operator [SEL_1509] (rows=26270325 width=44)
+                                                  Output:["_col0"]
+                                                  Select Operator [SEL_1507] (rows=7676736 width=94)
+                                                    Output:["_col0","_col1"]
+                                                    Merge Join Operator [MERGEJOIN_1506] (rows=7676736 width=94)
+                                                      Conds:RS_1775._col0=RS_1757._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 24 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1757]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1749]
+                                                    <-Map 50 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1775]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1772]
+                                          <-Reducer 45 [CONTAINS]
+                                            Reduce Output Operator [RS_1547]
+                                              Group By Operator [GBY_1546] (rows=1 width=120)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col0)","count(_col0)"]
+                                                Select Operator [SEL_1545] (rows=26270325 width=44)
+                                                  Output:["_col0"]
+                                                  Select Operator [SEL_1543] (rows=3856907 width=114)
+                                                    Output:["_col0","_col1"]
+                                                    Merge Join Operator [MERGEJOIN_1542] (rows=3856907 width=114)
+                                                      Conds:RS_1803._col0=RS_1785._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 40 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1785]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1777]
+                                                    <-Map 51 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1803]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1800]
+                                          <-Reducer 49 [CONTAINS]
+                                            Reduce Output Operator [RS_1565]
+                                              Group By Operator [GBY_1564] (rows=1 width=120)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col0)","count(_col0)"]
+                                                Select Operator [SEL_1563] (rows=26270325 width=44)
+                                                  Output:["_col0"]
+                                                  Select Operator [SEL_1561] (rows=14736682 width=0)
+                                                    Output:["_col0","_col1"]
+                                                    Merge Join Operator [MERGEJOIN_1560] (rows=14736682 width=0)
+                                                      Conds:RS_1810._col0=RS_1617._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 99 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1617]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1603]
+                                                    <-Map 46 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_1810]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_1807]
+                              <-Reducer 67 [CUSTOM_SIMPLE_EDGE] vectorized
+                                PARTITION_ONLY_SHUFFLE [RS_1747]
+                                  Group By Operator [GBY_1746] (rows=1 width=132)
+                                    Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                  <-Reducer 66 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_554]
+                                      PartitionCols:_col0, _col1, _col2
+                                      Group By Operator [GBY_553] (rows=1 width=132)
+                                        Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col3)","count()"],keys:_col0, _col1, _col2
+                                        Select Operator [SEL_551] (rows=1 width=128)
+                                          Output:["_col0","_col1","_col2","_col3"]
+                                          Merge Join Operator [MERGEJOIN_1430] (rows=1 width=128)
+                                            Conds:RS_548._col1=RS_549._col0(Inner),Output:["_col2","_col3","_col6","_col7","_col8"]
+                                          <-Reducer 89 [SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_549]
+                                              PartitionCols:_col0
+                                              Merge Join Operator [MERGEJOIN_1427] (rows=724 width=4)
+                                                Conds:RS_1686._col1, _col2, _col3=RS_1740._col0, _col1, _col2(Inner),Output:["_col0"]
+                                              <-Map 69 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_1686]
+                                                  PartitionCols:_col1, _col2, _col3
+                                                  Select Operator [SEL_1676] (rows=458612 width=15)
+                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                    Filter Operator [FIL_1667] (rows=458612 width=15)
+                                                      predicate:(i_brand_id is not null and i_category_id is not null and i_class_id is not null)
+                                                       Please refer to the previous TableScan [TS_90]
+                                              <-Reducer 88 [ONE_TO_ONE_EDGE] vectorized
+                                                FORWARD [RS_1740]
+                                                  PartitionCols:_col0, _col1, _col2
+                                                  Select Operator [SEL_1739] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"]
+                                                    Filter Operator [FIL_1738] (rows=1 width=20)
+                                                      predicate:(_col3 = 3L)
+                                                      Group By Operator [GBY_1737] (rows=121728 width=19)
+                                                        Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                      <-Union 87 [SIMPLE_EDGE]
+                                                        <-Reducer 86 [CONTAINS] vectorized
+                                                          Reduce Output Operator [RS_1840]
+                                                            PartitionCols:_col0, _col1, _col2
+                                                            Group By Operator [GBY_1839] (rows=121728 width=19)
+                                                              Output:["_col0","_col1","_col2","_col3"],aggregations:["count(_col3)"],keys:_col0, _col1, _col2
+                                                              Group By Operator [GBY_1838] (rows=121728 width=19)
+                                                                Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                              <-Reducer 82 [SIMPLE_EDGE]
+            

<TRUNCATED>

[20/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query31.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query31.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query31.q.out
new file mode 100644
index 0000000..a01919e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query31.q.out
@@ -0,0 +1,492 @@
+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
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 9 (BROADCAST_EDGE)
+Map 33 <- Reducer 13 (BROADCAST_EDGE)
+Map 34 <- Reducer 17 (BROADCAST_EDGE)
+Map 35 <- Reducer 23 (BROADCAST_EDGE)
+Map 36 <- Reducer 27 (BROADCAST_EDGE)
+Map 37 <- Reducer 31 (BROADCAST_EDGE)
+Reducer 10 <- Map 33 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 11 <- Map 32 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 34 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 15 <- Map 32 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
+Reducer 17 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 35 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 19 <- Map 32 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (SIMPLE_EDGE)
+Reducer 21 <- Reducer 20 (ONE_TO_ONE_EDGE), Reducer 26 (ONE_TO_ONE_EDGE)
+Reducer 22 <- Reducer 21 (ONE_TO_ONE_EDGE), Reducer 30 (ONE_TO_ONE_EDGE)
+Reducer 23 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 24 <- Map 36 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 25 <- Map 32 (SIMPLE_EDGE), Reducer 24 (SIMPLE_EDGE)
+Reducer 26 <- Reducer 25 (SIMPLE_EDGE)
+Reducer 27 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 28 <- Map 37 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 29 <- Map 32 (SIMPLE_EDGE), Reducer 28 (SIMPLE_EDGE)
+Reducer 3 <- Map 32 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Reducer 29 (SIMPLE_EDGE)
+Reducer 31 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 12 (ONE_TO_ONE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 16 (ONE_TO_ONE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 22 (ONE_TO_ONE_EDGE), Reducer 6 (ONE_TO_ONE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 7
+      File Output Operator [FS_139]
+        Select Operator [SEL_138] (rows=110 width=550)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          Filter Operator [FIL_136] (rows=110 width=786)
+            predicate:(CASE WHEN (_col2) THEN (CASE WHEN (_col15) THEN (((_col12 / _col14) > (_col7 / _col1))) ELSE ((null > (_col7 / _col1))) END) ELSE (CASE WHEN (_col15) THEN (((_col12 / _col14) > null)) ELSE (null) END) END and CASE WHEN (_col5) THEN (CASE WHEN (_col10) THEN (((_col14 / _col9) > (_col1 / _col4))) ELSE ((null > (_col1 / _col4))) END) ELSE (CASE WHEN (_col10) THEN (((_col14 / _col9) > null)) ELSE (null) END) END)
+            Merge Join Operator [MERGEJOIN_450] (rows=440 width=786)
+              Conds:RS_133._col0=RS_134._col0(Inner),Output:["_col0","_col1","_col2","_col4","_col5","_col7","_col9","_col10","_col12","_col14","_col15"]
+            <-Reducer 22 [ONE_TO_ONE_EDGE]
+              FORWARD [RS_134]
+                PartitionCols:_col0
+                Merge Join Operator [MERGEJOIN_449] (rows=440 width=442)
+                  Conds:RS_123._col0=RS_540._col0(Inner),Output:["_col0","_col1","_col2","_col4","_col6","_col7"]
+                <-Reducer 21 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_123]
+                    PartitionCols:_col0
+                    Merge Join Operator [MERGEJOIN_448] (rows=440 width=326)
+                      Conds:RS_525._col0=RS_532._col0(Inner),Output:["_col0","_col1","_col2","_col4"]
+                    <-Reducer 20 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_525]
+                        PartitionCols:_col0
+                        Select Operator [SEL_524] (rows=440 width=214)
+                          Output:["_col0","_col1","_col2"]
+                          Group By Operator [GBY_523] (rows=440 width=210)
+                            Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                          <-Reducer 19 [SIMPLE_EDGE]
+                            SHUFFLE [RS_77]
+                              PartitionCols:_col0
+                              Group By Operator [GBY_76] (rows=3960 width=210)
+                                Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col5
+                                Merge Join Operator [MERGEJOIN_441] (rows=10246882 width=209)
+                                  Conds:RS_72._col1=RS_497._col0(Inner),Output:["_col2","_col5"]
+                                <-Map 32 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_497]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_493] (rows=40000000 width=102)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_492] (rows=40000000 width=102)
+                                        predicate:ca_county is not null
+                                        TableScan [TS_6] (rows=40000000 width=102)
+                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_county"]
+                                <-Reducer 18 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_72]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_440] (rows=10246882 width=115)
+                                      Conds:RS_522._col0=RS_469._col0(Inner),Output:["_col1","_col2"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_469]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_460] (rows=130 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_454] (rows=130 width=12)
+                                            predicate:((d_qoy = 1) and (d_year = 2000))
+                                            TableScan [TS_3] (rows=73049 width=12)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                                    <-Map 35 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_522]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_521] (rows=143931246 width=119)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_520] (rows=143931246 width=119)
+                                            predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_70_date_dim_d_date_sk_min) AND DynamicValue(RS_70_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_70_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
+                                            TableScan [TS_60] (rows=144002668 width=119)
+                                              default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                                            <-Reducer 23 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_519]
+                                                Group By Operator [GBY_518] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_484]
+                                                    Group By Operator [GBY_478] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_470] (rows=130 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_460]
+                    <-Reducer 26 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_532]
+                        PartitionCols:_col0
+                        Group By Operator [GBY_531] (rows=440 width=210)
+                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                        <-Reducer 25 [SIMPLE_EDGE]
+                          SHUFFLE [RS_97]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_96] (rows=3960 width=210)
+                              Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col5
+                              Merge Join Operator [MERGEJOIN_443] (rows=10246882 width=209)
+                                Conds:RS_92._col1=RS_498._col0(Inner),Output:["_col2","_col5"]
+                              <-Map 32 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_498]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select Operator [SEL_493]
+                              <-Reducer 24 [SIMPLE_EDGE]
+                                SHUFFLE [RS_92]
+                                  PartitionCols:_col1
+                                  Merge Join Operator [MERGEJOIN_442] (rows=10246882 width=115)
+                                    Conds:RS_530._col0=RS_471._col0(Inner),Output:["_col1","_col2"]
+                                  <-Map 8 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_471]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_461] (rows=130 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_455] (rows=130 width=12)
+                                          predicate:((d_qoy = 3) and (d_year = 2000))
+                                           Please refer to the previous TableScan [TS_3]
+                                  <-Map 36 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_530]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_529] (rows=143931246 width=119)
+                                        Output:["_col0","_col1","_col2"]
+                                        Filter Operator [FIL_528] (rows=143931246 width=119)
+                                          predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_90_date_dim_d_date_sk_min) AND DynamicValue(RS_90_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_90_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
+                                          TableScan [TS_80] (rows=144002668 width=119)
+                                            default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                                          <-Reducer 27 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_527]
+                                              Group By Operator [GBY_526] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_485]
+                                                  Group By Operator [GBY_479] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_472] (rows=130 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_461]
+                <-Reducer 30 [ONE_TO_ONE_EDGE] vectorized
+                  FORWARD [RS_540]
+                    PartitionCols:_col0
+                    Select Operator [SEL_539] (rows=440 width=214)
+                      Output:["_col0","_col1","_col2"]
+                      Group By Operator [GBY_538] (rows=440 width=210)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 29 [SIMPLE_EDGE]
+                        SHUFFLE [RS_117]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_116] (rows=3960 width=210)
+                            Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col5
+                            Merge Join Operator [MERGEJOIN_445] (rows=10246882 width=209)
+                              Conds:RS_112._col1=RS_499._col0(Inner),Output:["_col2","_col5"]
+                            <-Map 32 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_499]
+                                PartitionCols:_col0
+                                 Please refer to the previous Select Operator [SEL_493]
+                            <-Reducer 28 [SIMPLE_EDGE]
+                              SHUFFLE [RS_112]
+                                PartitionCols:_col1
+                                Merge Join Operator [MERGEJOIN_444] (rows=10246882 width=115)
+                                  Conds:RS_537._col0=RS_473._col0(Inner),Output:["_col1","_col2"]
+                                <-Map 8 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_473]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_462] (rows=130 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_456] (rows=130 width=12)
+                                        predicate:((d_qoy = 2) and (d_year = 2000))
+                                         Please refer to the previous TableScan [TS_3]
+                                <-Map 37 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_537]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_536] (rows=143931246 width=119)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_535] (rows=143931246 width=119)
+                                        predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_110_date_dim_d_date_sk_min) AND DynamicValue(RS_110_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_110_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
+                                        TableScan [TS_100] (rows=144002668 width=119)
+                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                                        <-Reducer 31 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_534]
+                                            Group By Operator [GBY_533] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_486]
+                                                Group By Operator [GBY_480] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_474] (rows=130 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_462]
+            <-Reducer 6 [ONE_TO_ONE_EDGE]
+              FORWARD [RS_133]
+                PartitionCols:_col0
+                Merge Join Operator [MERGEJOIN_447] (rows=1605 width=442)
+                  Conds:RS_130._col0=RS_517._col0(Inner),Output:["_col0","_col1","_col2","_col4","_col5","_col7"]
+                <-Reducer 16 [ONE_TO_ONE_EDGE] vectorized
+                  FORWARD [RS_517]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_516] (rows=1605 width=210)
+                      Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                    <-Reducer 15 [SIMPLE_EDGE]
+                      SHUFFLE [RS_57]
+                        PartitionCols:_col0
+                        Group By Operator [GBY_56] (rows=33705 width=210)
+                          Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col5
+                          Merge Join Operator [MERGEJOIN_439] (rows=37399561 width=139)
+                            Conds:RS_52._col1=RS_496._col0(Inner),Output:["_col2","_col5"]
+                          <-Map 32 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_496]
+                              PartitionCols:_col0
+                               Please refer to the previous Select Operator [SEL_493]
+                          <-Reducer 14 [SIMPLE_EDGE]
+                            SHUFFLE [RS_52]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_438] (rows=37399561 width=42)
+                                Conds:RS_515._col0=RS_467._col0(Inner),Output:["_col1","_col2"]
+                              <-Map 8 [SIMPLE_EDGE] vectorized
+                                PARTITION_ONLY_SHUFFLE [RS_467]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_459] (rows=130 width=4)
+                                    Output:["_col0"]
+                                    Filter Operator [FIL_453] (rows=130 width=12)
+                                      predicate:((d_qoy = 3) and (d_year = 2000))
+                                       Please refer to the previous TableScan [TS_3]
+                              <-Map 34 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_515]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_514] (rows=525327191 width=114)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_513] (rows=525327191 width=114)
+                                      predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_50_date_dim_d_date_sk_min) AND DynamicValue(RS_50_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_50_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
+                                      TableScan [TS_40] (rows=575995635 width=114)
+                                        default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_addr_sk","ss_ext_sales_price"]
+                                      <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                        BROADCAST [RS_512]
+                                          Group By Operator [GBY_511] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                          <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_483]
+                                              Group By Operator [GBY_477] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                Select Operator [SEL_468] (rows=130 width=4)
+                                                  Output:["_col0"]
+                                                   Please refer to the previous Select Operator [SEL_459]
+                <-Reducer 5 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_130]
+                    PartitionCols:_col0
+                    Merge Join Operator [MERGEJOIN_446] (rows=1605 width=330)
+                      Conds:RS_502._col0=RS_510._col0(Inner),Output:["_col0","_col1","_col2","_col4","_col5"]
+                    <-Reducer 12 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_510]
+                        PartitionCols:_col0
+                        Select Operator [SEL_509] (rows=1605 width=214)
+                          Output:["_col0","_col1","_col2"]
+                          Group By Operator [GBY_508] (rows=1605 width=210)
+                            Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                          <-Reducer 11 [SIMPLE_EDGE]
+                            SHUFFLE [RS_37]
+                              PartitionCols:_col0
+                              Group By Operator [GBY_36] (rows=33705 width=210)
+                                Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col5
+                                Merge Join Operator [MERGEJOIN_437] (rows=37399561 width=139)
+                                  Conds:RS_32._col1=RS_495._col0(Inner),Output:["_col2","_col5"]
+                                <-Map 32 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_495]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Select Operator [SEL_493]
+                                <-Reducer 10 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_32]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_436] (rows=37399561 width=42)
+                                      Conds:RS_507._col0=RS_465._col0(Inner),Output:["_col1","_col2"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_465]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_458] (rows=130 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_452] (rows=130 width=12)
+                                            predicate:((d_qoy = 1) and (d_year = 2000))
+                                             Please refer to the previous TableScan [TS_3]
+                                    <-Map 33 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_507]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_506] (rows=525327191 width=114)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_505] (rows=525327191 width=114)
+                                            predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_30_date_dim_d_date_sk_min) AND DynamicValue(RS_30_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_30_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
+                                            TableScan [TS_20] (rows=575995635 width=114)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_addr_sk","ss_ext_sales_price"]
+                                            <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_504]
+                                                Group By Operator [GBY_503] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_482]
+                                                    Group By Operator [GBY_476] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_466] (rows=130 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_458]
+                    <-Reducer 4 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_502]
+                        PartitionCols:_col0
+                        Select Operator [SEL_501] (rows=1605 width=214)
+                          Output:["_col0","_col1","_col2"]
+                          Group By Operator [GBY_500] (rows=1605 width=210)
+                            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=33705 width=210)
+                                Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col5
+                                Merge Join Operator [MERGEJOIN_435] (rows=37399561 width=139)
+                                  Conds:RS_12._col1=RS_494._col0(Inner),Output:["_col2","_col5"]
+                                <-Map 32 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_494]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Select Operator [SEL_493]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_12]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_434] (rows=37399561 width=42)
+                                      Conds:RS_491._col0=RS_463._col0(Inner),Output:["_col1","_col2"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_463]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_457] (rows=130 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_451] (rows=130 width=12)
+                                            predicate:((d_qoy = 2) and (d_year = 2000))
+                                             Please refer to the previous TableScan [TS_3]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_491]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_490] (rows=525327191 width=114)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_489] (rows=525327191 width=114)
+                                            predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_10_date_dim_d_date_sk_min) AND DynamicValue(RS_10_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_10_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
+                                            TableScan [TS_0] (rows=575995635 width=114)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_addr_sk","ss_ext_sales_price"]
+                                            <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_488]
+                                                Group By Operator [GBY_487] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_481]
+                                                    Group By Operator [GBY_475] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_464] (rows=130 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_457]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query32.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query32.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query32.q.out
new file mode 100644
index 0000000..d909c02
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query32.q.out
@@ -0,0 +1,210 @@
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 14 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Map 12 <- Reducer 11 (BROADCAST_EDGE), Reducer 14 (BROADCAST_EDGE), Reducer 5 (BROADCAST_EDGE)
+Reducer 10 <- Map 13 (SIMPLE_EDGE), Reducer 9 (ONE_TO_ONE_EDGE)
+Reducer 11 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 10 (ONE_TO_ONE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Map 12 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4 vectorized
+      File Output Operator [FS_141]
+        Limit [LIM_140] (rows=1 width=112)
+          Number of rows:100
+          Group By Operator [GBY_139] (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=2478 width=112)
+                  Output:["_col2"]
+                  Filter Operator [FIL_33] (rows=2478 width=112)
+                    predicate:(_col2 > _col5)
+                    Merge Join Operator [MERGEJOIN_104] (rows=7434 width=112)
+                      Conds:RS_30._col1=RS_31._col2(Inner),Output:["_col2","_col5"]
+                    <-Reducer 2 [SIMPLE_EDGE]
+                      PARTITION_ONLY_SHUFFLE [RS_30]
+                        PartitionCols:_col1
+                        Merge Join Operator [MERGEJOIN_101] (rows=31836679 width=110)
+                          Conds:RS_128._col0=RS_107._col0(Inner),Output:["_col1","_col2"]
+                        <-Map 6 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_107]
+                            PartitionCols:_col0
+                            Select Operator [SEL_106] (rows=8116 width=4)
+                              Output:["_col0"]
+                              Filter Operator [FIL_105] (rows=8116 width=98)
+                                predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-03-18 00:00:00' AND TIMESTAMP'1998-06-16 00:00:00'
+                                TableScan [TS_3] (rows=73049 width=98)
+                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                        <-Map 1 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_128]
+                            PartitionCols:_col0
+                            Select Operator [SEL_127] (rows=286549727 width=119)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_126] (rows=286549727 width=119)
+                                predicate:((cs_item_sk BETWEEN DynamicValue(RS_24_item_i_item_sk_min) AND DynamicValue(RS_24_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_24_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_28_date_dim_d_date_sk_min) AND DynamicValue(RS_28_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_28_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                TableScan [TS_0] (rows=287989836 width=119)
+                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_ext_discount_amt"]
+                                <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                  BROADCAST [RS_124]
+                                    Group By Operator [GBY_123] (rows=1 width=12)
+                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                    <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_122]
+                                        Group By Operator [GBY_121] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                          Select Operator [SEL_120] (rows=669 width=4)
+                                            Output:["_col0"]
+                                            Select Operator [SEL_118] (rows=669 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_117] (rows=669 width=7)
+                                                predicate:(i_manufact_id = 269)
+                                                TableScan [TS_20] (rows=462000 width=7)
+                                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_manufact_id"]
+                                <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                  BROADCAST [RS_116]
+                                    Group By Operator [GBY_115] (rows=1 width=12)
+                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                    <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_113]
+                                        Group By Operator [GBY_111] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                          Select Operator [SEL_108] (rows=8116 width=4)
+                                            Output:["_col0"]
+                                             Please refer to the previous Select Operator [SEL_106]
+                    <-Reducer 10 [ONE_TO_ONE_EDGE]
+                      FORWARD [RS_31]
+                        PartitionCols:_col2
+                        Merge Join Operator [MERGEJOIN_103] (rows=97 width=116)
+                          Conds:RS_138._col0=RS_119._col0(Inner),Output:["_col1","_col2"]
+                        <-Map 13 [SIMPLE_EDGE] vectorized
+                          PARTITION_ONLY_SHUFFLE [RS_119]
+                            PartitionCols:_col0
+                             Please refer to the previous Select Operator [SEL_118]
+                        <-Reducer 9 [ONE_TO_ONE_EDGE] vectorized
+                          FORWARD [RS_138]
+                            PartitionCols:_col0
+                            Select Operator [SEL_137] (rows=6951 width=116)
+                              Output:["_col0","_col1"]
+                              Group By Operator [GBY_136] (rows=6951 width=124)
+                                Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                              <-Reducer 8 [SIMPLE_EDGE]
+                                SHUFFLE [RS_17]
+                                  PartitionCols:_col0
+                                  Group By Operator [GBY_16] (rows=97314 width=124)
+                                    Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","count(_col2)"],keys:_col1
+                                    Merge Join Operator [MERGEJOIN_102] (rows=31836679 width=110)
+                                      Conds:RS_135._col0=RS_109._col0(Inner),Output:["_col1","_col2"]
+                                    <-Map 6 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_109]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_106]
+                                    <-Map 12 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_135]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_134] (rows=286549727 width=119)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_133] (rows=286549727 width=119)
+                                            predicate:((cs_item_sk BETWEEN DynamicValue(RS_24_item_i_item_sk_min) AND DynamicValue(RS_24_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_24_item_i_item_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_30_catalog_sales_cs_item_sk_min) AND DynamicValue(RS_30_catalog_sales_cs_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_30_catalog_sales_cs_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_13_date_dim_d_date_sk_min) AND DynamicValue(RS_13_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_13_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                            TableScan [TS_6] (rows=287989836 width=119)
+                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_ext_discount_amt"]
+                                            <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_125]
+                                                 Please refer to the previous Group By Operator [GBY_123]
+                                            <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_130]
+                                                Group By Operator [GBY_129] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_114]
+                                                    Group By Operator [GBY_112] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_110] (rows=8116 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_106]
+                                            <-Reducer 5 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_132]
+                                                Group By Operator [GBY_131] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                  PARTITION_ONLY_SHUFFLE [RS_91]
+                                                    Group By Operator [GBY_90] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_89] (rows=31836679 width=8)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Merge Join Operator [MERGEJOIN_101]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out
new file mode 100644
index 0000000..c82c415
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out
@@ -0,0 +1,450 @@
+PREHOOK: query: 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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: 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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 14 <- Reducer 18 (BROADCAST_EDGE), Reducer 26 (BROADCAST_EDGE)
+Map 29 <- Reducer 21 (BROADCAST_EDGE), Reducer 27 (BROADCAST_EDGE)
+Map 30 <- Reducer 24 (BROADCAST_EDGE), Reducer 28 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 2 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 13 <- Map 12 (SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Map 17 (SIMPLE_EDGE)
+Reducer 16 <- Map 25 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 18 <- Map 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Map 17 (SIMPLE_EDGE), Map 29 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 13 (ONE_TO_ONE_EDGE)
+Reducer 20 <- Map 25 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
+Reducer 21 <- Map 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 22 <- Map 17 (SIMPLE_EDGE), Map 30 (SIMPLE_EDGE)
+Reducer 23 <- Map 25 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Map 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 26 <- Map 25 (CUSTOM_SIMPLE_EDGE)
+Reducer 27 <- Map 25 (CUSTOM_SIMPLE_EDGE)
+Reducer 28 <- Map 25 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 16 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 2 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE), Union 5 (CONTAINS)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_372]
+        Limit [LIM_371] (rows=59 width=115)
+          Number of rows:100
+          Select Operator [SEL_370] (rows=59 width=115)
+            Output:["_col0","_col1"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_369]
+              Group By Operator [GBY_368] (rows=59 width=115)
+                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Union 5 [SIMPLE_EDGE]
+                <-Reducer 11 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_392]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_391] (rows=59 width=115)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_390] (rows=19 width=115)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 10 [SIMPLE_EDGE]
+                        SHUFFLE [RS_109]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_108] (rows=19 width=115)
+                            Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_308] (rows=11364 width=3)
+                              Conds:RS_104._col0=RS_105._col2(Inner),Output:["_col1","_col7"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_104]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_297] (rows=461514 width=7)
+                                  Conds:RS_323._col1=RS_329._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_323]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_322] (rows=460848 width=7)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_321] (rows=460848 width=7)
+                                        predicate:i_manufact_id is not null
+                                        TableScan [TS_0] (rows=462000 width=7)
+                                          default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_manufact_id"]
+                                <-Reducer 13 [ONE_TO_ONE_EDGE] vectorized
+                                  FORWARD [RS_329]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_328] (rows=692 width=3)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 12 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_327]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_326] (rows=692 width=3)
+                                          Output:["_col0"],keys:i_manufact_id
+                                          Select Operator [SEL_325] (rows=46085 width=93)
+                                            Output:["i_manufact_id"]
+                                            Filter Operator [FIL_324] (rows=46085 width=93)
+                                              predicate:((i_category = 'Books') and i_manufact_id is not null)
+                                              TableScan [TS_3] (rows=462000 width=93)
+                                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_category","i_manufact_id"]
+                            <-Reducer 23 [SIMPLE_EDGE]
+                              SHUFFLE [RS_105]
+                                PartitionCols:_col2
+                                Select Operator [SEL_100] (rows=788222 width=110)
+                                  Output:["_col2","_col4"]
+                                  Merge Join Operator [MERGEJOIN_305] (rows=788222 width=110)
+                                    Conds:RS_97._col2=RS_352._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 25 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_352]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_347] (rows=8000000 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_346] (rows=8000000 width=112)
+                                          predicate:(ca_gmt_offset = -6)
+                                          TableScan [TS_16] (rows=40000000 width=112)
+                                            default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_gmt_offset"]
+                                  <-Reducer 22 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_97]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_304] (rows=3941109 width=118)
+                                        Conds:RS_389._col0=RS_336._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 17 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_336]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_331] (rows=50 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_330] (rows=50 width=12)
+                                              predicate:((d_moy = 3) and (d_year = 1999))
+                                              TableScan [TS_13] (rows=73049 width=12)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                      <-Map 30 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_389]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_388] (rows=143931246 width=123)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_387] (rows=143931246 width=123)
+                                              predicate:((ws_bill_addr_sk BETWEEN DynamicValue(RS_98_customer_address_ca_address_sk_min) AND DynamicValue(RS_98_customer_address_ca_address_sk_max) and in_bloom_filter(ws_bill_addr_sk, DynamicValue(RS_98_customer_address_ca_address_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_95_date_dim_d_date_sk_min) AND DynamicValue(RS_95_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_95_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
+                                              TableScan [TS_85] (rows=144002668 width=123)
+                                                default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                                              <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_384]
+                                                  Group By Operator [GBY_383] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_343]
+                                                      Group By Operator [GBY_340] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_337] (rows=50 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_331]
+                                              <-Reducer 28 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_386]
+                                                  Group By Operator [GBY_385] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                  <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_359]
+                                                      Group By Operator [GBY_356] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                        Select Operator [SEL_353] (rows=8000000 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_347]
+                <-Reducer 4 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_367]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_366] (rows=59 width=115)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_365] (rows=64 width=115)
+                        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=64 width=115)
+                            Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_306] (rows=41476 width=3)
+                              Conds:RS_29._col0=RS_30._col2(Inner),Output:["_col1","_col7"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_29]
+                                PartitionCols:_col0
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_297]
+                            <-Reducer 16 [SIMPLE_EDGE]
+                              SHUFFLE [RS_30]
+                                PartitionCols:_col2
+                                Select Operator [SEL_25] (rows=2876890 width=4)
+                                  Output:["_col2","_col4"]
+                                  Merge Join Operator [MERGEJOIN_299] (rows=2876890 width=4)
+                                    Conds:RS_22._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 25 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_348]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select Operator [SEL_347]
+                                  <-Reducer 15 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_22]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_298] (rows=14384447 width=4)
+                                        Conds:RS_364._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 17 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_332]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_331]
+                                      <-Map 14 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_364]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_363] (rows=525327191 width=118)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_362] (rows=525327191 width=118)
+                                              predicate:((ss_addr_sk BETWEEN DynamicValue(RS_23_customer_address_ca_address_sk_min) AND DynamicValue(RS_23_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_23_customer_address_ca_address_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_20_date_dim_d_date_sk_min) AND DynamicValue(RS_20_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_20_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
+                                              TableScan [TS_10] (rows=575995635 width=118)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
+                                              <-Reducer 18 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_345]
+                                                  Group By Operator [GBY_344] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_341]
+                                                      Group By Operator [GBY_338] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_333] (rows=50 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_331]
+                                              <-Reducer 26 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_361]
+                                                  Group By Operator [GBY_360] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                  <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_357]
+                                                      Group By Operator [GBY_354] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                        Select Operator [SEL_349] (rows=8000000 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_347]
+                <-Reducer 9 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_382]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_381] (rows=59 width=115)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_380] (rows=35 width=115)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 8 [SIMPLE_EDGE]
+                        SHUFFLE [RS_71]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_70] (rows=35 width=115)
+                            Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_307] (rows=22352 width=3)
+                              Conds:RS_66._col0=RS_67._col3(Inner),Output:["_col1","_col7"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_66]
+                                PartitionCols:_col0
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_297]
+                            <-Reducer 20 [SIMPLE_EDGE]
+                              SHUFFLE [RS_67]
+                                PartitionCols:_col3
+                                Select Operator [SEL_62] (rows=1550375 width=13)
+                                  Output:["_col3","_col4"]
+                                  Merge Join Operator [MERGEJOIN_302] (rows=1550375 width=13)
+                                    Conds:RS_59._col1=RS_350._col0(Inner),Output:["_col2","_col3"]
+                                  <-Map 25 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_350]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select Operator [SEL_347]
+                                  <-Reducer 19 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_59]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_301] (rows=7751872 width=98)
+                                        Conds:RS_379._col0=RS_334._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 17 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_334]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_331]
+                                      <-Map 29 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_379]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_378] (rows=285117733 width=123)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_377] (rows=285117733 width=123)
+                                              predicate:((cs_bill_addr_sk BETWEEN DynamicValue(RS_60_customer_address_ca_address_sk_min) AND DynamicValue(RS_60_customer_address_ca_address_sk_max) and in_bloom_filter(cs_bill_addr_sk, DynamicValue(RS_60_customer_address_ca_address_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_57_date_dim_d_date_sk_min) AND DynamicValue(RS_57_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_57_date_dim_d_date_sk_bloom_filter))) and cs_bill_addr_sk is not null and cs_sold_date_sk is not null)
+                                              TableScan [TS_47] (rows=287989836 width=123)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_addr_sk","cs_item_sk","cs_ext_sales_price"]
+                                              <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_374]
+                                                  Group By Operator [GBY_373] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_342]
+                                                      Group By Operator [GBY_339] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_335] (rows=50 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_331]
+                                              <-Reducer 27 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_376]
+                                                  Group By Operator [GBY_375] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                  <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_358]
+                                                      Group By Operator [GBY_355] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                        Select Operator [SEL_351] (rows=8000000 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_347]
+


[62/75] [abbrv] hive git commit: HIVE-18876: Remove Superfluous Logging in Driver (Alice Fan, reviewed by Naveen Gangam)

Posted by se...@apache.org.
HIVE-18876: Remove Superfluous Logging in Driver (Alice Fan, reviewed by Naveen Gangam)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/94d49918
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/94d49918
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/94d49918

Branch: refs/heads/master-tez092
Commit: 94d499183071b0bbaa60b54592758f2c291dd24a
Parents: 36015ea
Author: Naveen Gangam <ng...@apache.org>
Authored: Wed Oct 24 15:46:10 2018 -0400
Committer: Naveen Gangam <ng...@apache.org>
Committed: Wed Oct 24 15:46:10 2018 -0400

----------------------------------------------------------------------
 ql/src/java/org/apache/hadoop/hive/ql/Driver.java | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/94d49918/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
index 84316bc..ff5086a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
@@ -2550,10 +2550,6 @@ public class Driver implements IDriver {
         LOG.info("Completed executing command(queryId=" + queryId + "); Time taken: " + duration + " seconds");
       }
     }
-
-    if (console != null) {
-      console.printInfo("OK");
-    }
   }
 
   private long addWithOverflowCheck(long val1, long val2) {


[31/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query60.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query60.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query60.q.out
new file mode 100644
index 0000000..ea098f7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query60.q.out
@@ -0,0 +1,241 @@
+PREHOOK: query: explain cbo
+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_category in ('Children'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ 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 i_item_id
+      ,total_sales
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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_category in ('Children'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ 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 i_item_id
+      ,total_sales
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(i_item_id=[$0], $f1=[$1])
+        HiveUnion(all=[true])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[=($12, _UTF-16LE'Children')])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_addr_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -6)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 9))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[=($12, _UTF-16LE'Children')])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], cs_sold_date_sk=[$1], cs_bill_addr_sk=[$2], cs_item_sk=[$3], cs_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -6)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 9))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[=($12, _UTF-16LE'Children')])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ws_sold_date_sk=[$1], ws_item_sk=[$2], ws_bill_addr_sk=[$3], ws_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -6)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 9))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query61.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query61.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query61.q.out
new file mode 100644
index 0000000..68d03cb
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query61.q.out
@@ -0,0 +1,164 @@
+Warning: Shuffle Join MERGEJOIN[266][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 5' is a cross product
+PREHOOK: query: explain cbo
+select  promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
+from
+  (select sum(ss_ext_sales_price) promotions
+   from  store_sales
+        ,store
+        ,promotion
+        ,date_dim
+        ,customer
+        ,customer_address 
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_promo_sk = p_promo_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk 
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) promotional_sales,
+  (select sum(ss_ext_sales_price) total
+   from  store_sales
+        ,store
+        ,date_dim
+        ,customer
+        ,customer_address
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) all_sales
+order by promotions, total
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
+from
+  (select sum(ss_ext_sales_price) promotions
+   from  store_sales
+        ,store
+        ,promotion
+        ,date_dim
+        ,customer
+        ,customer_address 
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_promo_sk = p_promo_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk 
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) promotional_sales,
+  (select sum(ss_ext_sales_price) total
+   from  store_sales
+        ,store
+        ,date_dim
+        ,customer
+        ,customer_address
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) all_sales
+order by promotions, total
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(promotions=[$0], total=[$2], _o__c2=[*(/($1, $3), CAST(100):DECIMAL(10, 0))])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(promotions=[$0], CAST=[CAST($0):DECIMAL(15, 4)])
+        HiveAggregate(group=[{}], agg#0=[sum($8)])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                HiveFilter(condition=[IS NOT NULL($4)])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0])
+                HiveFilter(condition=[=($11, -7)])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_promo_sk=[$4], ss_ext_sales_price=[$5], d_date_sk=[$6], i_item_sk=[$7], s_store_sk=[$8], p_promo_sk=[$9])
+              HiveJoin(condition=[=($4, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($3, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($8), IS NOT NULL($0), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 11))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(i_item_sk=[$0])
+                      HiveFilter(condition=[=($12, _UTF-16LE'Electronics')])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(s_store_sk=[$0])
+                    HiveFilter(condition=[=($27, -7)])
+                      HiveTableScan(table=[[default, store]], table:alias=[store])
+                HiveProject(p_promo_sk=[$0])
+                  HiveFilter(condition=[OR(=($8, _UTF-16LE'Y'), =($9, _UTF-16LE'Y'), =($11, _UTF-16LE'Y'))])
+                    HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+      HiveProject(total=[$0], CAST=[CAST($0):DECIMAL(15, 4)])
+        HiveAggregate(group=[{}], agg#0=[sum($7)])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                HiveFilter(condition=[IS NOT NULL($4)])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0])
+                HiveFilter(condition=[=($11, -7)])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5], i_item_sk=[$6], s_store_sk=[$7])
+              HiveJoin(condition=[=($3, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ext_sales_price=[$15])
+                      HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0), IS NOT NULL($3))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($6, 1999), =($8, 11))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(i_item_sk=[$0])
+                    HiveFilter(condition=[=($12, _UTF-16LE'Electronics')])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(s_store_sk=[$0])
+                  HiveFilter(condition=[=($27, -7)])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query63.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query63.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query63.q.out
new file mode 100644
index 0000000..e22d812
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query63.q.out
@@ -0,0 +1,85 @@
+PREHOOK: query: explain cbo
+select  * 
+from (select i_manager_id
+             ,sum(ss_sales_price) sum_sales
+             ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
+      from item
+          ,store_sales
+          ,date_dim
+          ,store
+      where ss_item_sk = i_item_sk
+        and ss_sold_date_sk = d_date_sk
+        and ss_store_sk = s_store_sk
+        and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11)
+        and ((    i_category in ('Books','Children','Electronics')
+              and i_class in ('personal','portable','refernece','self-help')
+              and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		                  'exportiunivamalg #9','scholaramalgamalg #9'))
+           or(    i_category in ('Women','Music','Men')
+              and i_class in ('accessories','classical','fragrances','pants')
+              and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		                 'importoamalg #1')))
+group by i_manager_id, d_moy) tmp1
+where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+order by i_manager_id
+        ,avg_monthly_sales
+        ,sum_sales
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  * 
+from (select i_manager_id
+             ,sum(ss_sales_price) sum_sales
+             ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
+      from item
+          ,store_sales
+          ,date_dim
+          ,store
+      where ss_item_sk = i_item_sk
+        and ss_sold_date_sk = d_date_sk
+        and ss_store_sk = s_store_sk
+        and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11)
+        and ((    i_category in ('Books','Children','Electronics')
+              and i_class in ('personal','portable','refernece','self-help')
+              and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		                  'exportiunivamalg #9','scholaramalgamalg #9'))
+           or(    i_category in ('Women','Music','Men')
+              and i_class in ('accessories','classical','fragrances','pants')
+              and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		                 'importoamalg #1')))
+group by i_manager_id, d_moy) tmp1
+where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+order by i_manager_id
+        ,avg_monthly_sales
+        ,sum_sales
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$2], sort2=[$1], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject((tok_table_or_col i_manager_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$1], avg_window_0=[$2])
+    HiveFilter(condition=[CASE(>($2, 0), >(/(ABS(-($1, $2)), $2), 0.1), null)])
+      HiveProject((tok_table_or_col i_manager_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$2], avg_window_0=[avg($2) OVER (PARTITION BY $0 ORDER BY $0 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+        HiveProject(i_manager_id=[$0], d_moy=[$1], $f2=[$2])
+          HiveAggregate(group=[{4, 6}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_sales_price=[$13])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(i_item_sk=[$0], i_manager_id=[$20])
+                  HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'refernece', _UTF-16LE'self-help', _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9', _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'), IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics', _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), OR(AND(IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics'), IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'refernece', _UTF-16LE'self-help'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9')), AND(IN($12, _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), IN($10, _U
 TF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'))))])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_moy=[$8])
+                HiveFilter(condition=[IN($3, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query64.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query64.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query64.q.out
new file mode 100644
index 0000000..60c4325
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query64.q.out
@@ -0,0 +1,390 @@
+PREHOOK: query: explain cbo
+with cs_ui as
+ (select cs_item_sk
+        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
+  from catalog_sales
+      ,catalog_returns
+  where cs_item_sk = cr_item_sk
+    and cs_order_number = cr_order_number
+  group by cs_item_sk
+  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
+cross_sales as
+ (select i_product_name product_name
+     ,i_item_sk item_sk
+     ,s_store_name store_name
+     ,s_zip store_zip
+     ,ad1.ca_street_number b_street_number
+     ,ad1.ca_street_name b_streen_name
+     ,ad1.ca_city b_city
+     ,ad1.ca_zip b_zip
+     ,ad2.ca_street_number c_street_number
+     ,ad2.ca_street_name c_street_name
+     ,ad2.ca_city c_city
+     ,ad2.ca_zip c_zip
+     ,d1.d_year as syear
+     ,d2.d_year as fsyear
+     ,d3.d_year s2year
+     ,count(*) cnt
+     ,sum(ss_wholesale_cost) s1
+     ,sum(ss_list_price) s2
+     ,sum(ss_coupon_amt) s3
+  FROM   store_sales
+        ,store_returns
+        ,cs_ui
+        ,date_dim d1
+        ,date_dim d2
+        ,date_dim d3
+        ,store
+        ,customer
+        ,customer_demographics cd1
+        ,customer_demographics cd2
+        ,promotion
+        ,household_demographics hd1
+        ,household_demographics hd2
+        ,customer_address ad1
+        ,customer_address ad2
+        ,income_band ib1
+        ,income_band ib2
+        ,item
+  WHERE  ss_store_sk = s_store_sk AND
+         ss_sold_date_sk = d1.d_date_sk AND
+         ss_customer_sk = c_customer_sk AND
+         ss_cdemo_sk= cd1.cd_demo_sk AND
+         ss_hdemo_sk = hd1.hd_demo_sk AND
+         ss_addr_sk = ad1.ca_address_sk and
+         ss_item_sk = i_item_sk and
+         ss_item_sk = sr_item_sk and
+         ss_ticket_number = sr_ticket_number and
+         ss_item_sk = cs_ui.cs_item_sk and
+         c_current_cdemo_sk = cd2.cd_demo_sk AND
+         c_current_hdemo_sk = hd2.hd_demo_sk AND
+         c_current_addr_sk = ad2.ca_address_sk and
+         c_first_sales_date_sk = d2.d_date_sk and
+         c_first_shipto_date_sk = d3.d_date_sk and
+         ss_promo_sk = p_promo_sk and
+         hd1.hd_income_band_sk = ib1.ib_income_band_sk and
+         hd2.hd_income_band_sk = ib2.ib_income_band_sk and
+         cd1.cd_marital_status <> cd2.cd_marital_status and
+         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
+         i_current_price between 35 and 35 + 10 and
+         i_current_price between 35 + 1 and 35 + 15
+group by i_product_name
+       ,i_item_sk
+       ,s_store_name
+       ,s_zip
+       ,ad1.ca_street_number
+       ,ad1.ca_street_name
+       ,ad1.ca_city
+       ,ad1.ca_zip
+       ,ad2.ca_street_number
+       ,ad2.ca_street_name
+       ,ad2.ca_city
+       ,ad2.ca_zip
+       ,d1.d_year
+       ,d2.d_year
+       ,d3.d_year
+)
+select cs1.product_name
+     ,cs1.store_name
+     ,cs1.store_zip
+     ,cs1.b_street_number
+     ,cs1.b_streen_name
+     ,cs1.b_city
+     ,cs1.b_zip
+     ,cs1.c_street_number
+     ,cs1.c_street_name
+     ,cs1.c_city
+     ,cs1.c_zip
+     ,cs1.syear
+     ,cs1.cnt
+     ,cs1.s1
+     ,cs1.s2
+     ,cs1.s3
+     ,cs2.s1
+     ,cs2.s2
+     ,cs2.s3
+     ,cs2.syear
+     ,cs2.cnt
+from cross_sales cs1,cross_sales cs2
+where cs1.item_sk=cs2.item_sk and
+     cs1.syear = 2000 and
+     cs2.syear = 2000 + 1 and
+     cs2.cnt <= cs1.cnt and
+     cs1.store_name = cs2.store_name and
+     cs1.store_zip = cs2.store_zip
+order by cs1.product_name
+       ,cs1.store_name
+       ,cs2.cnt
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@income_band
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with cs_ui as
+ (select cs_item_sk
+        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
+  from catalog_sales
+      ,catalog_returns
+  where cs_item_sk = cr_item_sk
+    and cs_order_number = cr_order_number
+  group by cs_item_sk
+  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
+cross_sales as
+ (select i_product_name product_name
+     ,i_item_sk item_sk
+     ,s_store_name store_name
+     ,s_zip store_zip
+     ,ad1.ca_street_number b_street_number
+     ,ad1.ca_street_name b_streen_name
+     ,ad1.ca_city b_city
+     ,ad1.ca_zip b_zip
+     ,ad2.ca_street_number c_street_number
+     ,ad2.ca_street_name c_street_name
+     ,ad2.ca_city c_city
+     ,ad2.ca_zip c_zip
+     ,d1.d_year as syear
+     ,d2.d_year as fsyear
+     ,d3.d_year s2year
+     ,count(*) cnt
+     ,sum(ss_wholesale_cost) s1
+     ,sum(ss_list_price) s2
+     ,sum(ss_coupon_amt) s3
+  FROM   store_sales
+        ,store_returns
+        ,cs_ui
+        ,date_dim d1
+        ,date_dim d2
+        ,date_dim d3
+        ,store
+        ,customer
+        ,customer_demographics cd1
+        ,customer_demographics cd2
+        ,promotion
+        ,household_demographics hd1
+        ,household_demographics hd2
+        ,customer_address ad1
+        ,customer_address ad2
+        ,income_band ib1
+        ,income_band ib2
+        ,item
+  WHERE  ss_store_sk = s_store_sk AND
+         ss_sold_date_sk = d1.d_date_sk AND
+         ss_customer_sk = c_customer_sk AND
+         ss_cdemo_sk= cd1.cd_demo_sk AND
+         ss_hdemo_sk = hd1.hd_demo_sk AND
+         ss_addr_sk = ad1.ca_address_sk and
+         ss_item_sk = i_item_sk and
+         ss_item_sk = sr_item_sk and
+         ss_ticket_number = sr_ticket_number and
+         ss_item_sk = cs_ui.cs_item_sk and
+         c_current_cdemo_sk = cd2.cd_demo_sk AND
+         c_current_hdemo_sk = hd2.hd_demo_sk AND
+         c_current_addr_sk = ad2.ca_address_sk and
+         c_first_sales_date_sk = d2.d_date_sk and
+         c_first_shipto_date_sk = d3.d_date_sk and
+         ss_promo_sk = p_promo_sk and
+         hd1.hd_income_band_sk = ib1.ib_income_band_sk and
+         hd2.hd_income_band_sk = ib2.ib_income_band_sk and
+         cd1.cd_marital_status <> cd2.cd_marital_status and
+         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
+         i_current_price between 35 and 35 + 10 and
+         i_current_price between 35 + 1 and 35 + 15
+group by i_product_name
+       ,i_item_sk
+       ,s_store_name
+       ,s_zip
+       ,ad1.ca_street_number
+       ,ad1.ca_street_name
+       ,ad1.ca_city
+       ,ad1.ca_zip
+       ,ad2.ca_street_number
+       ,ad2.ca_street_name
+       ,ad2.ca_city
+       ,ad2.ca_zip
+       ,d1.d_year
+       ,d2.d_year
+       ,d3.d_year
+)
+select cs1.product_name
+     ,cs1.store_name
+     ,cs1.store_zip
+     ,cs1.b_street_number
+     ,cs1.b_streen_name
+     ,cs1.b_city
+     ,cs1.b_zip
+     ,cs1.c_street_number
+     ,cs1.c_street_name
+     ,cs1.c_city
+     ,cs1.c_zip
+     ,cs1.syear
+     ,cs1.cnt
+     ,cs1.s1
+     ,cs1.s2
+     ,cs1.s3
+     ,cs2.s1
+     ,cs2.s2
+     ,cs2.s3
+     ,cs2.syear
+     ,cs2.cnt
+from cross_sales cs1,cross_sales cs2
+where cs1.item_sk=cs2.item_sk and
+     cs1.syear = 2000 and
+     cs2.syear = 2000 + 1 and
+     cs2.cnt <= cs1.cnt and
+     cs1.store_name = cs2.store_name and
+     cs1.store_zip = cs2.store_zip
+order by cs1.product_name
+       ,cs1.store_name
+       ,cs2.cnt
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@income_band
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(product_name=[$0], store_name=[$1], store_zip=[$2], b_street_number=[$3], b_streen_name=[$4], b_city=[$5], b_zip=[$6], c_street_number=[$7], c_street_name=[$8], c_city=[$9], c_zip=[$10], syear=[CAST(2000):INTEGER], cnt=[$11], s1=[$12], s2=[$13], s3=[$14], s11=[$15], s21=[$16], s31=[$17], syear1=[CAST(2001):INTEGER], cnt1=[$18])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$18], dir0=[ASC], dir1=[ASC], dir2=[ASC])
+    HiveProject(product_name=[$0], store_name=[$2], store_zip=[$3], b_street_number=[$4], b_streen_name=[$5], b_city=[$6], b_zip=[$7], c_street_number=[$8], c_street_name=[$9], c_city=[$10], c_zip=[$11], cnt=[$12], s1=[$13], s2=[$14], s3=[$15], s11=[$20], s21=[$21], s31=[$22], cnt1=[$19])
+      HiveJoin(condition=[AND(AND(AND(=($1, $16), <=($19, $12)), =($2, $17)), =($3, $18))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject($f0=[$13], $f1=[$12], $f2=[$10], $f3=[$11], $f4=[$6], $f5=[$7], $f6=[$8], $f7=[$9], $f8=[$0], $f9=[$1], $f10=[$2], $f11=[$3], $f15=[$14], $f16=[$15], $f17=[$16], $f18=[$17])
+          HiveAggregate(group=[{9, 10, 11, 12, 15, 17, 23, 24, 25, 26, 28, 29, 42, 43}], agg#0=[count()], agg#1=[sum($39)], agg#2=[sum($40)], agg#3=[sum($41)])
+            HiveJoin(condition=[AND(<>($1, $19), =($34, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+              HiveJoin(condition=[=($31, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $16)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($4, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($5, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4], c_first_shipto_date_sk=[$5], c_first_sales_date_sk=[$6])
+                            HiveFilter(condition=[AND(IS NOT NULL($6), IS NOT NULL($5), IS NOT NULL($2), IS NOT NULL($3), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                            HiveTableScan(table=[[default, customer_address]], table:alias=[ad2])
+                        HiveProject(hd_demo_sk=[$0])
+                          HiveFilter(condition=[IS NOT NULL($1)])
+                            HiveTableScan(table=[[default, household_demographics]], table:alias=[hd2])
+                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                    HiveProject(d_date_sk=[$0], d_year=[$6])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                  HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+                HiveProject(sr_item_sk=[$0], sr_ticket_number=[$1], ca_address_sk=[$2], ca_street_number=[$3], ca_street_name=[$4], ca_city=[$5], ca_zip=[$6], s_store_sk=[$7], s_store_name=[$8], s_zip=[$9], hd_demo_sk=[$10], ss_sold_date_sk=[$11], ss_item_sk=[$12], ss_customer_sk=[$13], ss_cdemo_sk=[$14], ss_hdemo_sk=[$15], ss_addr_sk=[$16], ss_store_sk=[$17], ss_ticket_number=[$18], ss_wholesale_cost=[$19], ss_list_price=[$20], ss_coupon_amt=[$21], i_item_sk=[$22], i_product_name=[$23], d_date_sk=[$24], cs_item_sk=[$25])
+                  HiveJoin(condition=[AND(=($12, $0), =($18, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                      HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveJoin(condition=[=($14, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[ad1])
+                      HiveJoin(condition=[=($10, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(s_store_sk=[$0], s_store_name=[$5], s_zip=[$25])
+                          HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($25))])
+                            HiveTableScan(table=[[default, store]], table:alias=[store])
+                        HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(hd_demo_sk=[$0])
+                            HiveFilter(condition=[IS NOT NULL($1)])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[hd1])
+                          HiveJoin(condition=[=($1, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($0, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveJoin(condition=[=($1, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_wholesale_cost=[$11], ss_list_price=[$12], ss_coupon_amt=[$19])
+                                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3), IS NOT NULL($4), IS NOT NULL($8), IS NOT NULL($5), IS NOT NULL($6))])
+                                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                HiveProject(i_item_sk=[$0], i_product_name=[$21])
+                                  HiveFilter(condition=[AND(IN($17, _UTF-16LE'maroon', _UTF-16LE'burnished', _UTF-16LE'dim', _UTF-16LE'steel', _UTF-16LE'navajo', _UTF-16LE'chocolate'), BETWEEN(false, $5, 35, 45), BETWEEN(false, $5, 36, 50))])
+                                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                              HiveProject(d_date_sk=[$0])
+                                HiveFilter(condition=[=($6, 2000)])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                            HiveProject(cs_item_sk=[$0])
+                              HiveFilter(condition=[>($1, *(2, $2))])
+                                HiveAggregate(group=[{0}], agg#0=[sum($2)], agg#1=[sum($5)])
+                                  HiveJoin(condition=[AND(=($0, $3), =($1, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_item_sk=[$15], cs_order_number=[$17], cs_ext_list_price=[$25])
+                                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(cr_item_sk=[$2], cr_order_number=[$16], +=[+(+($23, $24), $25)])
+                                      HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+        HiveProject($f1=[$12], $f2=[$10], $f3=[$11], $f15=[$14], $f16=[$15], $f17=[$16], $f18=[$17])
+          HiveAggregate(group=[{9, 10, 11, 12, 15, 17, 23, 24, 25, 26, 28, 29, 42, 43}], agg#0=[count()], agg#1=[sum($39)], agg#2=[sum($40)], agg#3=[sum($41)])
+            HiveJoin(condition=[AND(<>($1, $19), =($34, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+              HiveJoin(condition=[=($31, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $16)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($4, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($5, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4], c_first_shipto_date_sk=[$5], c_first_sales_date_sk=[$6])
+                            HiveFilter(condition=[AND(IS NOT NULL($6), IS NOT NULL($5), IS NOT NULL($2), IS NOT NULL($3), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                            HiveTableScan(table=[[default, customer_address]], table:alias=[ad2])
+                        HiveProject(hd_demo_sk=[$0])
+                          HiveFilter(condition=[IS NOT NULL($1)])
+                            HiveTableScan(table=[[default, household_demographics]], table:alias=[hd2])
+                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                    HiveProject(d_date_sk=[$0], d_year=[$6])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                  HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+                HiveProject(sr_item_sk=[$0], sr_ticket_number=[$1], ca_address_sk=[$2], ca_street_number=[$3], ca_street_name=[$4], ca_city=[$5], ca_zip=[$6], s_store_sk=[$7], s_store_name=[$8], s_zip=[$9], hd_demo_sk=[$10], ss_sold_date_sk=[$11], ss_item_sk=[$12], ss_customer_sk=[$13], ss_cdemo_sk=[$14], ss_hdemo_sk=[$15], ss_addr_sk=[$16], ss_store_sk=[$17], ss_ticket_number=[$18], ss_wholesale_cost=[$19], ss_list_price=[$20], ss_coupon_amt=[$21], i_item_sk=[$22], i_product_name=[$23], d_date_sk=[$24], cs_item_sk=[$25])
+                  HiveJoin(condition=[AND(=($12, $0), =($18, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                      HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveJoin(condition=[=($14, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[ad1])
+                      HiveJoin(condition=[=($10, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(s_store_sk=[$0], s_store_name=[$5], s_zip=[$25])
+                          HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($25))])
+                            HiveTableScan(table=[[default, store]], table:alias=[store])
+                        HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(hd_demo_sk=[$0])
+                            HiveFilter(condition=[IS NOT NULL($1)])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[hd1])
+                          HiveJoin(condition=[=($1, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($0, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveJoin(condition=[=($1, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_wholesale_cost=[$11], ss_list_price=[$12], ss_coupon_amt=[$19])
+                                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3), IS NOT NULL($4), IS NOT NULL($8), IS NOT NULL($5), IS NOT NULL($6))])
+                                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                HiveProject(i_item_sk=[$0], i_product_name=[$21])
+                                  HiveFilter(condition=[AND(IN($17, _UTF-16LE'maroon', _UTF-16LE'burnished', _UTF-16LE'dim', _UTF-16LE'steel', _UTF-16LE'navajo', _UTF-16LE'chocolate'), BETWEEN(false, $5, 35, 45), BETWEEN(false, $5, 36, 50))])
+                                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                              HiveProject(d_date_sk=[$0])
+                                HiveFilter(condition=[=($6, 2001)])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                            HiveProject(cs_item_sk=[$0])
+                              HiveFilter(condition=[>($1, *(2, $2))])
+                                HiveAggregate(group=[{0}], agg#0=[sum($2)], agg#1=[sum($5)])
+                                  HiveJoin(condition=[AND(=($0, $3), =($1, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_item_sk=[$15], cs_order_number=[$17], cs_ext_list_price=[$25])
+                                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(cr_item_sk=[$2], cr_order_number=[$16], +=[+(+($23, $24), $25)])
+                                      HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query65.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query65.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query65.q.out
new file mode 100644
index 0000000..3e906b7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query65.q.out
@@ -0,0 +1,97 @@
+PREHOOK: query: explain cbo
+select 
+	s_store_name,
+	i_item_desc,
+	sc.revenue,
+	i_current_price,
+	i_wholesale_cost,
+	i_brand
+ from store, item,
+     (select ss_store_sk, avg(revenue) as ave
+ 	from
+ 	    (select  ss_store_sk, ss_item_sk, 
+ 		     sum(ss_sales_price) as revenue
+ 		from store_sales, date_dim
+ 		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 		group by ss_store_sk, ss_item_sk) sa
+ 	group by ss_store_sk) sb,
+     (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
+ 	from store_sales, date_dim
+ 	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 	group by ss_store_sk, ss_item_sk) sc
+ where sb.ss_store_sk = sc.ss_store_sk and 
+       sc.revenue <= 0.1 * sb.ave and
+       s_store_sk = sc.ss_store_sk and
+       i_item_sk = sc.ss_item_sk
+ order by s_store_name, i_item_desc
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select 
+	s_store_name,
+	i_item_desc,
+	sc.revenue,
+	i_current_price,
+	i_wholesale_cost,
+	i_brand
+ from store, item,
+     (select ss_store_sk, avg(revenue) as ave
+ 	from
+ 	    (select  ss_store_sk, ss_item_sk, 
+ 		     sum(ss_sales_price) as revenue
+ 		from store_sales, date_dim
+ 		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 		group by ss_store_sk, ss_item_sk) sa
+ 	group by ss_store_sk) sb,
+     (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
+ 	from store_sales, date_dim
+ 	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 	group by ss_store_sk, ss_item_sk) sc
+ where sb.ss_store_sk = sc.ss_store_sk and 
+       sc.revenue <= 0.1 * sb.ave and
+       s_store_sk = sc.ss_store_sk and
+       i_item_sk = sc.ss_item_sk
+ order by s_store_name, i_item_desc
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(s_store_name=[$11], i_item_desc=[$1], revenue=[$7], i_current_price=[$2], i_wholesale_cost=[$3], i_brand=[$4])
+    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(i_item_sk=[$0], i_item_desc=[$4], i_current_price=[$5], i_wholesale_cost=[$6], i_brand=[$8])
+        HiveTableScan(table=[[default, item]], table:alias=[item])
+      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[AND(=($3, $0), <=($2, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_store_sk=[$1], ss_item_sk=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject($f0=[$0], *=[*(0.1, /($1, $2))])
+            HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+              HiveProject(ss_item_sk=[$0], ss_store_sk=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(s_store_sk=[$0], s_store_name=[$5])
+          HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out
new file mode 100644
index 0000000..77256a3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query66.q.out
@@ -0,0 +1,506 @@
+PREHOOK: query: explain cbo
+select   
+         w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+        ,ship_carriers
+        ,year
+ 	,sum(jan_sales) as jan_sales
+ 	,sum(feb_sales) as feb_sales
+ 	,sum(mar_sales) as mar_sales
+ 	,sum(apr_sales) as apr_sales
+ 	,sum(may_sales) as may_sales
+ 	,sum(jun_sales) as jun_sales
+ 	,sum(jul_sales) as jul_sales
+ 	,sum(aug_sales) as aug_sales
+ 	,sum(sep_sales) as sep_sales
+ 	,sum(oct_sales) as oct_sales
+ 	,sum(nov_sales) as nov_sales
+ 	,sum(dec_sales) as dec_sales
+ 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
+ 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
+ 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
+ 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
+ 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
+ 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
+ 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
+ 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
+ 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
+ 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
+ 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
+ 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
+ 	,sum(jan_net) as jan_net
+ 	,sum(feb_net) as feb_net
+ 	,sum(mar_net) as mar_net
+ 	,sum(apr_net) as apr_net
+ 	,sum(may_net) as may_net
+ 	,sum(jun_net) as jun_net
+ 	,sum(jul_net) as jul_net
+ 	,sum(aug_net) as aug_net
+ 	,sum(sep_net) as sep_net
+ 	,sum(oct_net) as oct_net
+ 	,sum(nov_net) as nov_net
+ 	,sum(dec_net) as dec_net
+ from (
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then ws_sales_price* ws_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
+     from
+          web_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	  ,ship_mode
+     where
+            ws_warehouse_sk =  w_warehouse_sk
+        and ws_sold_date_sk = d_date_sk
+        and ws_sold_time_sk = t_time_sk
+ 	and ws_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 and 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+ 	)
+ union all
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
+     from
+          catalog_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	 ,ship_mode
+     where
+            cs_warehouse_sk =  w_warehouse_sk
+        and cs_sold_date_sk = d_date_sk
+        and cs_sold_time_sk = t_time_sk
+ 	and cs_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 AND 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+     ) 
+ ) x
+ group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,ship_carriers
+       ,year
+ order by w_warehouse_name
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@ship_mode
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@warehouse
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select   
+         w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+        ,ship_carriers
+        ,year
+ 	,sum(jan_sales) as jan_sales
+ 	,sum(feb_sales) as feb_sales
+ 	,sum(mar_sales) as mar_sales
+ 	,sum(apr_sales) as apr_sales
+ 	,sum(may_sales) as may_sales
+ 	,sum(jun_sales) as jun_sales
+ 	,sum(jul_sales) as jul_sales
+ 	,sum(aug_sales) as aug_sales
+ 	,sum(sep_sales) as sep_sales
+ 	,sum(oct_sales) as oct_sales
+ 	,sum(nov_sales) as nov_sales
+ 	,sum(dec_sales) as dec_sales
+ 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
+ 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
+ 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
+ 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
+ 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
+ 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
+ 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
+ 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
+ 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
+ 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
+ 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
+ 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
+ 	,sum(jan_net) as jan_net
+ 	,sum(feb_net) as feb_net
+ 	,sum(mar_net) as mar_net
+ 	,sum(apr_net) as apr_net
+ 	,sum(may_net) as may_net
+ 	,sum(jun_net) as jun_net
+ 	,sum(jul_net) as jul_net
+ 	,sum(aug_net) as aug_net
+ 	,sum(sep_net) as sep_net
+ 	,sum(oct_net) as oct_net
+ 	,sum(nov_net) as nov_net
+ 	,sum(dec_net) as dec_net
+ from (
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then ws_sales_price* ws_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
+     from
+          web_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	  ,ship_mode
+     where
+            ws_warehouse_sk =  w_warehouse_sk
+        and ws_sold_date_sk = d_date_sk
+        and ws_sold_time_sk = t_time_sk
+ 	and ws_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 and 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+ 	)
+ union all
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
+     from
+          catalog_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	 ,ship_mode
+     where
+            cs_warehouse_sk =  w_warehouse_sk
+        and cs_sold_date_sk = d_date_sk
+        and cs_sold_time_sk = t_time_sk
+ 	and cs_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 AND 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+     ) 
+ ) x
+ group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,ship_carriers
+       ,year
+ order by w_warehouse_name
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@ship_mode
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county=[$3], w_state=[$4], w_country=[$5], ship_carriers=[CAST(_UTF-16LE'DIAMOND,AIRBORNE'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], year=[CAST(2002):INTEGER], jan_sales=[$6], feb_sales=[$7], mar_sales=[$8], apr_sales=[$9], may_sales=[$10], jun_sales=[$11], jul_sales=[$12], aug_sales=[$13], sep_sales=[$14], oct_sales=[$15], nov_sales=[$16], dec_sales=[$17], jan_sales_per_sq_foot=[$18], feb_sales_per_sq_foot=[$19], mar_sales_per_sq_foot=[$20], apr_sales_per_sq_foot=[$21], may_sales_per_sq_foot=[$22], jun_sales_per_sq_foot=[$23], jul_sales_per_sq_foot=[$24], aug_sales_per_sq_foot=[$25], sep_sales_per_sq_foot=[$26], oct_sales_per_sq_foot=[$27], nov_sales_per_sq_foot=[$28], dec_sales_per_sq_foot=[$29], jan_net=[$30], feb_net=[$31], mar_net=[$32], apr_net=[$33], may_net=[$34], jun_net=[$35], jul_net=[$36], aug_net=[$37], sep_net=[$38], oct_net=[$39], nov_net=[$40], dec_net=[
 $41])
+  HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+    HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29], $f30=[$30], $f31=[$31], $f32=[$32], $f33=[$33], $f34=[$34], $f35=[$35], $f36=[$36], $f37=[$37], $f38=[$38], $f39=[$39], $f40=[$40], $f41=[$41])
+      HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)], agg#24=[sum($30)], agg#25=[sum($31)], agg#26=[sum($32)], agg#27=[sum($33)], agg#28=[sum($34)], agg#29=[sum($35)], agg#30=[sum($36)], agg#31=[sum($37)], agg#32=[sum($38)], agg#33=[sum($39)], agg#34=[sum($40)], agg#35=[sum($41)])
+        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f8=[$6], $f9=[$7], $f10=[$8], $f11=[$9], $f12=[$10], $f13=[$11], $f14=[$12], $f15=[$13], $f16=[$14], $f17=[$15], $f18=[$16], $f19=[$17], $f20=[/($6, CAST($1):DECIMAL(10, 0))], $f21=[/($7, CAST($1):DECIMAL(10, 0))], $f22=[/($8, CAST($1):DECIMAL(10, 0))], $f23=[/($9, CAST($1):DECIMAL(10, 0))], $f24=[/($10, CAST($1):DECIMAL(10, 0))], $f25=[/($11, CAST($1):DECIMAL(10, 0))], $f26=[/($12, CAST($1):DECIMAL(10, 0))], $f27=[/($13, CAST($1):DECIMAL(10, 0))], $f28=[/($14, CAST($1):DECIMAL(10, 0))], $f29=[/($15, CAST($1):DECIMAL(10, 0))], $f30=[/($16, CAST($1):DECIMAL(10, 0))], $f31=[/($17, CAST($1):DECIMAL(10, 0))], $f32=[$18], $f33=[$19], $f34=[$20], $f35=[$21], $f36=[$22], $f37=[$23], $f38=[$24], $f39=[$25], $f40=[$26], $f41=[$27], $f42=[$28], $f43=[$29])
+          HiveUnion(all=[true])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
+                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f7=[CASE($15, $11, 0)], $f8=[CASE($16, $11, 0)], $f9=[CASE($17, $11, 0)], $f10=[CASE($18, $11, 0)], $f11=[CASE($19, $11, 0)], $f12=[CASE($20, $11, 0)], $f13=[CASE($21, $11, 0)], $f14=[CASE($22, $11, 0)], $f15=[CASE($23, $11, 0)], $f16=[CASE($24, $11, 0)], $f17=[CASE($25, $11, 0)], $f18=[CASE($26, $11, 0)], $f19=[CASE($15, $12, 0)], $f20=[CASE($16, $12, 0)], $f21=[CASE($17, $12, 0)], $f22=[CASE($18, $12, 0)], $f23=[CASE($19, $12, 0)], $f24=[CASE($20, $12, 0)], $f25=[CASE($21, $12, 0)], $f26=[CASE($22, $12, 0)], $f27=[CASE($23, $12, 0)], $f28=[CASE($24, $12, 0)], $f29=[CASE($25, $12, 0)], $f30=[CASE($26, $12, 0)])
+                  HiveJoin(condition=[=($10, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2], w_warehouse_sq_ft=[$3], w_city=[$8], w_county=[$9], w_state=[$10], w_country=[$12])
+                      HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+                    HiveJoin(condition=[=($2, $20)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ws_sold_date_sk=[$0], ws_sold_time_sk=[$1], ws_ship_mode_sk=[$14], ws_warehouse_sk=[$15], *=[*($21, CAST($18):DECIMAL(10, 0))], *5=[*($30, CAST($18):DECIMAL(10, 0))])
+                            HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0), IS NOT NULL($1), IS NOT NULL($14))])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(t_time_sk=[$0])
+                            HiveFilter(condition=[BETWEEN(false, $2, 49530, 78330)])
+                              HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                        HiveProject(d_date_sk=[$0], ==[=($8, 1)], =2=[=($8, 2)], =3=[=($8, 3)], =4=[=($8, 4)], =5=[=($8, 5)], =6=[=($8, 6)], =7=[=($8, 7)], =8=[=($8, 8)], =9=[=($8, 9)], =10=[=($8, 10)], =11=[=($8, 11)], =12=[=($8, 12)])
+                          HiveFilter(condition=[=($6, 2002)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(sm_ship_mode_sk=[$0])
+                        HiveFilter(condition=[IN($4, _UTF-16LE'DIAMOND', _UTF-16LE'AIRBORNE')])
+                          HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
+                HiveProject($f0=[$22], $f1=[$23], $f2=[$24], $f3=[$25], $f4=[$26], $f5=[$27], $f7=[CASE($8, $4, 0)], $f8=[CASE($9, $4, 0)], $f9=[CASE($10, $4, 0)], $f10=[CASE($11, $4, 0)], $f11=[CASE($12, $4, 0)], $f12=[CASE($13, $4, 0)], $f13=[CASE($14, $4, 0)], $f14=[CASE($15, $4, 0)], $f15=[CASE($16, $4, 0)], $f16=[CASE($17, $4, 0)], $f17=[CASE($18, $4, 0)], $f18=[CASE($19, $4, 0)], $f19=[CASE($8, $5, 0)], $f20=[CASE($9, $5, 0)], $f21=[CASE($10, $5, 0)], $f22=[CASE($11, $5, 0)], $f23=[CASE($12, $5, 0)], $f24=[CASE($13, $5, 0)], $f25=[CASE($14, $5, 0)], $f26=[CASE($15, $5, 0)], $f27=[CASE($16, $5, 0)], $f28=[CASE($17, $5, 0)], $f29=[CASE($18, $5, 0)], $f30=[CASE($19, $5, 0)])
+                  HiveJoin(condition=[=($3, $21)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($2, $20)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_sold_time_sk=[$1], cs_ship_mode_sk=[$13], cs_warehouse_sk=[$14], *=[*($23, CAST($18):DECIMAL(10, 0))], *5=[*($32, CAST($18):DECIMAL(10, 0))])
+                            HiveFilter(condition=[AND(IS NOT NULL($14), IS NOT NULL($0), IS NOT NULL($1), IS NOT NULL($13))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(t_time_sk=[$0])
+                            HiveFilter(condition=[BETWEEN(false, $2, 49530, 78330)])
+                              HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                        HiveProject(d_date_sk=[$0], ==[=($8, 1)], =2=[=($8, 2)], =3=[=($8, 3)], =4=[=($8, 4)], =5=[=($8, 5)], =6=[=($8, 6)], =7=[=($8, 7)], =8=[=($8, 8)], =9=[=($8, 9)], =10=[=($8, 10)], =11=[=($8, 11)], =12=[=($8, 12)])
+                          HiveFilter(condition=[=($6, 2002)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(sm_ship_mode_sk=[$0])
+                        HiveFilter(condition=[IN($4, _UTF-16LE'DIAMOND', _UTF-16LE'AIRBORNE')])
+                          HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
+                    HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2], w_warehouse_sq_ft=[$3], w_city=[$8], w_county=[$9], w_state=[$10], w_country=[$12])
+                      HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query67.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query67.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query67.q.out
new file mode 100644
index 0000000..41a3896
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query67.q.out
@@ -0,0 +1,118 @@
+PREHOOK: query: explain cbo
+select  *
+from (select i_category
+            ,i_class
+            ,i_brand
+            ,i_product_name
+            ,d_year
+            ,d_qoy
+            ,d_moy
+            ,s_store_id
+            ,sumsales
+            ,rank() over (partition by i_category order by sumsales desc) rk
+      from (select i_category
+                  ,i_class
+                  ,i_brand
+                  ,i_product_name
+                  ,d_year
+                  ,d_qoy
+                  ,d_moy
+                  ,s_store_id
+                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
+            from store_sales
+                ,date_dim
+                ,store
+                ,item
+       where  ss_sold_date_sk=d_date_sk
+          and ss_item_sk=i_item_sk
+          and ss_store_sk = s_store_sk
+          and d_month_seq between 1212 and 1212+11
+       group by  rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
+where rk <= 100
+order by i_category
+        ,i_class
+        ,i_brand
+        ,i_product_name
+        ,d_year
+        ,d_qoy
+        ,d_moy
+        ,s_store_id
+        ,sumsales
+        ,rk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from (select i_category
+            ,i_class
+            ,i_brand
+            ,i_product_name
+            ,d_year
+            ,d_qoy
+            ,d_moy
+            ,s_store_id
+            ,sumsales
+            ,rank() over (partition by i_category order by sumsales desc) rk
+      from (select i_category
+                  ,i_class
+                  ,i_brand
+                  ,i_product_name
+                  ,d_year
+                  ,d_qoy
+                  ,d_moy
+                  ,s_store_id
+                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
+            from store_sales
+                ,date_dim
+                ,store
+                ,item
+       where  ss_sold_date_sk=d_date_sk
+          and ss_item_sk=i_item_sk
+          and ss_store_sk = s_store_sk
+          and d_month_seq between 1212 and 1212+11
+       group by  rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
+where rk <= 100
+order by i_category
+        ,i_class
+        ,i_brand
+        ,i_product_name
+        ,d_year
+        ,d_qoy
+        ,d_moy
+        ,s_store_id
+        ,sumsales
+        ,rk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], fetch=[100])
+  HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], i_product_name=[$3], d_year=[$4], d_qoy=[$5], d_moy=[$6], s_store_id=[$7], sumsales=[$8], rank_window_0=[$9])
+    HiveFilter(condition=[<=($9, 100)])
+      HiveProject(i_category=[$2], i_class=[$1], i_brand=[$0], i_product_name=[$3], d_year=[$4], d_qoy=[$6], d_moy=[$5], s_store_id=[$7], sumsales=[$8], rank_window_0=[rank() OVER (PARTITION BY $2 ORDER BY $8 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+        HiveProject(i_brand=[$0], i_class=[$1], i_category=[$2], i_product_name=[$3], d_year=[$4], d_moy=[$5], d_qoy=[$6], s_store_id=[$7], $f8=[$8])
+          HiveAggregate(group=[{1, 2, 3, 4, 6, 7, 8, 9}], groups=[[{1, 2, 3, 4, 6, 7, 8, 9}, {1, 2, 3, 4, 6, 7, 8}, {1, 2, 3, 4, 6, 8}, {1, 2, 3, 4, 6}, {1, 2, 3, 4}, {1, 2, 3}, {2, 3}, {3}, {}]], agg#0=[sum($10)])
+            HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12], i_product_name=[$21])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(ss_item_sk=[$1], d_year=[$5], d_moy=[$6], d_qoy=[$7], s_store_id=[$9], CASE=[$3])
+                HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], CASE=[CASE(AND(IS NOT NULL($13), IS NOT NULL($10)), *($13, CAST($10):DECIMAL(10, 0)), 0)])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8], d_qoy=[$10])
+                      HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(s_store_sk=[$0], s_store_id=[$1])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+


[15/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query51.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query51.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query51.q.out
new file mode 100644
index 0000000..9862559
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query51.q.out
@@ -0,0 +1,222 @@
+PREHOOK: query: explain
+WITH web_v1 as (
+select
+  ws_item_sk item_sk, d_date,
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from web_sales
+    ,date_dim
+where ws_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ws_item_sk is not NULL
+group by ws_item_sk, d_date),
+store_v1 as (
+select
+  ss_item_sk item_sk, d_date,
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from store_sales
+    ,date_dim
+where ss_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ss_item_sk is not NULL
+group by ss_item_sk, d_date)
+ select  *
+from (select item_sk
+     ,d_date
+     ,web_sales
+     ,store_sales
+     ,max(web_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
+     ,max(store_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
+     from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
+                 ,case when web.d_date is not null then web.d_date else store.d_date end d_date
+                 ,web.cume_sales web_sales
+                 ,store.cume_sales store_sales
+           from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
+                                                          and web.d_date = store.d_date)
+          )x )y
+where web_cumulative > store_cumulative
+order by item_sk
+        ,d_date
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+WITH web_v1 as (
+select
+  ws_item_sk item_sk, d_date,
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from web_sales
+    ,date_dim
+where ws_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ws_item_sk is not NULL
+group by ws_item_sk, d_date),
+store_v1 as (
+select
+  ss_item_sk item_sk, d_date,
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from store_sales
+    ,date_dim
+where ss_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ss_item_sk is not NULL
+group by ss_item_sk, d_date)
+ select  *
+from (select item_sk
+     ,d_date
+     ,web_sales
+     ,store_sales
+     ,max(web_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
+     ,max(store_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
+     from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
+                 ,case when web.d_date is not null then web.d_date else store.d_date end d_date
+                 ,web.cume_sales web_sales
+                 ,store.cume_sales store_sales
+           from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
+                                                          and web.d_date = store.d_date)
+          )x )y
+where web_cumulative > store_cumulative
+order by item_sk
+        ,d_date
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 8 (BROADCAST_EDGE)
+Map 12 <- Reducer 11 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 10 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 8 <- Map 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 12 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_117]
+        Limit [LIM_116] (rows=100 width=636)
+          Number of rows:100
+          Select Operator [SEL_115] (rows=363803676 width=636)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_114]
+              Select Operator [SEL_113] (rows=363803676 width=636)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                Filter Operator [FIL_112] (rows=363803676 width=420)
+                  predicate:(max_window_0 > max_window_1)
+                  PTF Operator [PTF_111] (rows=1091411029 width=420)
+                    Function definitions:[{},{"name:":"windowingtablefunction","order by:":"CASE WHEN (_col4 is not null) THEN (_col4) ELSE (_col1) END ASC NULLS LAST","partition by:":"CASE WHEN (_col3 is not null) THEN (_col3) ELSE (_col0) END"}]
+                    Select Operator [SEL_110] (rows=1091411029 width=420)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                    <-Reducer 4 [SIMPLE_EDGE]
+                      SHUFFLE [RS_43]
+                        PartitionCols:CASE WHEN (_col3 is not null) THEN (_col3) ELSE (_col0) END
+                        Merge Join Operator [MERGEJOIN_87] (rows=1091411029 width=420)
+                          Conds:RS_40._col0, _col1=RS_41._col0, _col1(Outer),Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                        <-Reducer 10 [SIMPLE_EDGE]
+                          SHUFFLE [RS_41]
+                            PartitionCols:_col0, _col1
+                            Select Operator [SEL_37] (rows=3442937 width=210)
+                              Output:["_col0","_col1","_col2"]
+                              PTF Operator [PTF_36] (rows=3442937 width=210)
+                                Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 ASC NULLS LAST","partition by:":"_col0"}]
+                                Group By Operator [GBY_32] (rows=3442937 width=210)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                <-Reducer 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_31]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_30] (rows=24992810 width=210)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col1, _col4
+                                      Merge Join Operator [MERGEJOIN_86] (rows=24992810 width=209)
+                                        Conds:RS_108._col0=RS_92._col0(Inner),Output:["_col1","_col2","_col4"]
+                                      <-Map 7 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_92]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_89] (rows=317 width=98)
+                                            Output:["_col0","_col1"]
+                                            Filter Operator [FIL_88] (rows=317 width=102)
+                                              predicate:d_month_seq BETWEEN 1212 AND 1223
+                                              TableScan [TS_3] (rows=73049 width=102)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date","d_month_seq"]
+                                      <-Map 12 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_108]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_107] (rows=143966864 width=119)
+                                            Output:["_col0","_col1","_col2"]
+                                            Filter Operator [FIL_106] (rows=143966864 width=119)
+                                              predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_27_date_dim_d_date_sk_min) AND DynamicValue(RS_27_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_27_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                              TableScan [TS_20] (rows=144002668 width=119)
+                                                default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_sales_price"]
+                                              <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_105]
+                                                  Group By Operator [GBY_104] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_97]
+                                                      Group By Operator [GBY_95] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_93] (rows=317 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_89]
+                        <-Reducer 3 [SIMPLE_EDGE]
+                          SHUFFLE [RS_40]
+                            PartitionCols:_col0, _col1
+                            Select Operator [SEL_17] (rows=3442937 width=210)
+                              Output:["_col0","_col1","_col2"]
+                              PTF Operator [PTF_16] (rows=3442937 width=210)
+                                Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 ASC NULLS LAST","partition by:":"_col0"}]
+                                Group By Operator [GBY_12] (rows=3442937 width=210)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_11]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_10] (rows=95493908 width=210)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col1, _col4
+                                      Merge Join Operator [MERGEJOIN_85] (rows=95493908 width=180)
+                                        Conds:RS_102._col0=RS_90._col0(Inner),Output:["_col1","_col2","_col4"]
+                                      <-Map 7 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_90]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_89]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_102]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_101] (rows=550076554 width=114)
+                                            Output:["_col0","_col1","_col2"]
+                                            Filter Operator [FIL_100] (rows=550076554 width=114)
+                                              predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_7_date_dim_d_date_sk_min) AND DynamicValue(RS_7_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_7_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                              TableScan [TS_0] (rows=575995635 width=114)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_sales_price"]
+                                              <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_99]
+                                                  Group By Operator [GBY_98] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_96]
+                                                      Group By Operator [GBY_94] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_91] (rows=317 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_89]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query52.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query52.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query52.q.out
new file mode 100644
index 0000000..72f9151
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query52.q.out
@@ -0,0 +1,139 @@
+PREHOOK: query: explain
+select  dt.d_year
+ 	,item.i_brand_id brand_id
+ 	,item.i_brand brand
+ 	,sum(ss_ext_sales_price) ext_price
+ 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_manager_id = 1
+    and dt.d_moy=12
+    and dt.d_year=1998
+ group by dt.d_year
+ 	,item.i_brand
+ 	,item.i_brand_id
+ order by dt.d_year
+ 	,ext_price desc
+ 	,brand_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  dt.d_year
+ 	,item.i_brand_id brand_id
+ 	,item.i_brand brand
+ 	,sum(ss_ext_sales_price) ext_price
+ 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_manager_id = 1
+    and dt.d_moy=12
+    and dt.d_year=1998
+ group by dt.d_year
+ 	,item.i_brand
+ 	,item.i_brand_id
+ order by dt.d_year
+ 	,ext_price desc
+ 	,brand_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 7 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_79]
+        Select Operator [SEL_78] (rows=100 width=220)
+          Output:["_col0","_col1","_col2","_col3"]
+          Limit [LIM_77] (rows=100 width=216)
+            Number of rows:100
+            Select Operator [SEL_76] (rows=7333 width=216)
+              Output:["_col0","_col1","_col2"]
+            <-Reducer 4 [SIMPLE_EDGE] vectorized
+              SHUFFLE [RS_75]
+                Group By Operator [GBY_74] (rows=7333 width=216)
+                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                <-Reducer 3 [SIMPLE_EDGE]
+                  SHUFFLE [RS_17]
+                    PartitionCols:_col0, _col1
+                    Group By Operator [GBY_16] (rows=7333 width=216)
+                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col5, _col6
+                      Merge Join Operator [MERGEJOIN_54] (rows=2301098 width=104)
+                        Conds:RS_12._col1=RS_65._col0(Inner),Output:["_col2","_col5","_col6"]
+                      <-Map 8 [SIMPLE_EDGE] vectorized
+                        PARTITION_ONLY_SHUFFLE [RS_65]
+                          PartitionCols:_col0
+                          Select Operator [SEL_64] (rows=7333 width=107)
+                            Output:["_col0","_col1","_col2"]
+                            Filter Operator [FIL_63] (rows=7333 width=111)
+                              predicate:(i_manager_id = 1)
+                              TableScan [TS_6] (rows=462000 width=111)
+                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand_id","i_brand","i_manager_id"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_12]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_53] (rows=15062131 width=4)
+                            Conds:RS_73._col0=RS_57._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_57]
+                              PartitionCols:_col0
+                              Select Operator [SEL_56] (rows=50 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_55] (rows=50 width=12)
+                                  predicate:((d_moy = 12) and (d_year = 1998))
+                                  TableScan [TS_3] (rows=73049 width=12)
+                                    default@date_dim,dt,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_73]
+                              PartitionCols:_col0
+                              Select Operator [SEL_72] (rows=550076554 width=114)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_71] (rows=550076554 width=114)
+                                  predicate:((ss_item_sk BETWEEN DynamicValue(RS_13_item_i_item_sk_min) AND DynamicValue(RS_13_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_13_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_10_dt_d_date_sk_min) AND DynamicValue(RS_10_dt_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_10_dt_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                  TableScan [TS_0] (rows=575995635 width=114)
+                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
+                                  <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_62]
+                                      Group By Operator [GBY_61] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_60]
+                                          Group By Operator [GBY_59] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_58] (rows=50 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_56]
+                                  <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_70]
+                                      Group By Operator [GBY_69] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_68]
+                                          Group By Operator [GBY_67] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_66] (rows=7333 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_64]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query53.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query53.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query53.q.out
new file mode 100644
index 0000000..27adc6e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query53.q.out
@@ -0,0 +1,161 @@
+PREHOOK: query: explain
+select  * from 
+(select i_manufact_id,
+sum(ss_sales_price) sum_sales,
+avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+ss_sold_date_sk = d_date_sk and
+ss_store_sk = s_store_sk and
+d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
+((i_category in ('Books','Children','Electronics') and
+i_class in ('personal','portable','reference','self-help') and
+i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		'exportiunivamalg #9','scholaramalgamalg #9'))
+or(i_category in ('Women','Music','Men') and
+i_class in ('accessories','classical','fragrances','pants') and
+i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		'importoamalg #1')))
+group by i_manufact_id, d_qoy ) tmp1
+where case when avg_quarterly_sales > 0 
+	then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales 
+	else null end > 0.1
+order by avg_quarterly_sales,
+	 sum_sales,
+	 i_manufact_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  * from 
+(select i_manufact_id,
+sum(ss_sales_price) sum_sales,
+avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+ss_sold_date_sk = d_date_sk and
+ss_store_sk = s_store_sk and
+d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
+((i_category in ('Books','Children','Electronics') and
+i_class in ('personal','portable','reference','self-help') and
+i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		'exportiunivamalg #9','scholaramalgamalg #9'))
+or(i_category in ('Women','Music','Men') and
+i_class in ('accessories','classical','fragrances','pants') and
+i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		'importoamalg #1')))
+group by i_manufact_id, d_qoy ) tmp1
+where case when avg_quarterly_sales > 0 
+	then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales 
+	else null end > 0.1
+order by avg_quarterly_sales,
+	 sum_sales,
+	 i_manufact_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 7 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_86]
+        Limit [LIM_85] (rows=30 width=228)
+          Number of rows:100
+          Select Operator [SEL_84] (rows=30 width=228)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 4 [SIMPLE_EDGE]
+            SHUFFLE [RS_27]
+              Select Operator [SEL_24] (rows=30 width=228)
+                Output:["_col0","_col1","_col2"]
+                Filter Operator [FIL_36] (rows=30 width=228)
+                  predicate:CASE WHEN ((avg_window_0 > 0)) THEN (((abs((_col2 - avg_window_0)) / avg_window_0) > 0.1)) ELSE (null) END
+                  Select Operator [SEL_23] (rows=60 width=116)
+                    Output:["avg_window_0","_col0","_col2"]
+                    PTF Operator [PTF_22] (rows=60 width=116)
+                      Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col0 ASC NULLS FIRST","partition by:":"_col0"}]
+                      Select Operator [SEL_19] (rows=60 width=116)
+                        Output:["_col0","_col2"]
+                        Group By Operator [GBY_18] (rows=60 width=120)
+                          Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                        <-Reducer 3 [SIMPLE_EDGE]
+                          SHUFFLE [RS_17]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_16] (rows=60 width=120)
+                              Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col4, _col6
+                              Merge Join Operator [MERGEJOIN_62] (rows=129200 width=8)
+                                Conds:RS_12._col0=RS_73._col0(Inner),Output:["_col2","_col4","_col6"]
+                              <-Map 8 [SIMPLE_EDGE] vectorized
+                                PARTITION_ONLY_SHUFFLE [RS_73]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_72] (rows=317 width=8)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_71] (rows=317 width=12)
+                                      predicate:(d_month_seq) IN (1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223)
+                                      TableScan [TS_6] (rows=73049 width=12)
+                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq","d_qoy"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_12]
+                                  PartitionCols:_col0
+                                  Merge Join Operator [MERGEJOIN_61] (rows=744232 width=4)
+                                    Conds:RS_81._col1=RS_65._col0(Inner),Output:["_col0","_col2","_col4"]
+                                  <-Map 6 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_65]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_64] (rows=68 width=8)
+                                        Output:["_col0","_col1"]
+                                        Filter Operator [FIL_63] (rows=68 width=290)
+                                          predicate:((((i_category) IN ('Books', 'Children', 'Electronics') and (i_class) IN ('personal', 'portable', 'reference', 'self-help') and (i_brand) IN ('scholaramalgamalg #14', 'scholaramalgamalg #7', 'exportiunivamalg #9', 'scholaramalgamalg #9')) or ((i_category) IN ('Women', 'Music', 'Men') and (i_class) IN ('accessories', 'classical', 'fragrances', 'pants') and (i_brand) IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1'))) and (i_brand) IN ('scholaramalgamalg #14', 'scholaramalgamalg #7', 'exportiunivamalg #9', 'scholaramalgamalg #9', 'amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1') and (i_category) IN ('Books', 'Children', 'Electronics', 'Women', 'Music', 'Men') and (i_class) IN ('personal', 'portable', 'reference', 'self-help', 'accessories', 'classical', 'fragrances', 'pants'))
+                                          TableScan [TS_3] (rows=462000 width=289)
+                                            default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand","i_class","i_category","i_manufact_id"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_81]
+                                      PartitionCols:_col1
+                                      Select Operator [SEL_80] (rows=525329897 width=114)
+                                        Output:["_col0","_col1","_col2"]
+                                        Filter Operator [FIL_79] (rows=525329897 width=118)
+                                          predicate:((ss_item_sk BETWEEN DynamicValue(RS_10_item_i_item_sk_min) AND DynamicValue(RS_10_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_10_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_13_date_dim_d_date_sk_min) AND DynamicValue(RS_13_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_13_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                          TableScan [TS_0] (rows=575995635 width=118)
+                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_sales_price"]
+                                          <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_70]
+                                              Group By Operator [GBY_69] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_68]
+                                                  Group By Operator [GBY_67] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_66] (rows=68 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_64]
+                                          <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_78]
+                                              Group By Operator [GBY_77] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_76]
+                                                  Group By Operator [GBY_75] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_74] (rows=317 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_72]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query54.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query54.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query54.q.out
new file mode 100644
index 0000000..0210163
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query54.q.out
@@ -0,0 +1,439 @@
+Warning: Shuffle Join MERGEJOIN[270][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[271][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[269][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 32' is a cross product
+Warning: Shuffle Join MERGEJOIN[272][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 6' is a cross product
+PREHOOK: query: explain
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 14 (BROADCAST_EDGE)
+Map 16 <- Reducer 24 (BROADCAST_EDGE), Reducer 26 (BROADCAST_EDGE), Union 17 (CONTAINS)
+Map 22 <- Reducer 24 (BROADCAST_EDGE), Reducer 26 (BROADCAST_EDGE), Union 17 (CONTAINS)
+Reducer 12 <- Map 11 (SIMPLE_EDGE), Map 15 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE), Reducer 21 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 23 (SIMPLE_EDGE), Union 17 (SIMPLE_EDGE)
+Reducer 19 <- Map 25 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 20 <- Map 27 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
+Reducer 21 <- Reducer 20 (SIMPLE_EDGE)
+Reducer 24 <- Map 23 (CUSTOM_SIMPLE_EDGE)
+Reducer 26 <- Map 25 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 28 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 13 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Reducer 29 (CUSTOM_SIMPLE_EDGE)
+Reducer 31 <- Map 28 (SIMPLE_EDGE)
+Reducer 32 <- Reducer 31 (CUSTOM_SIMPLE_EDGE), Reducer 34 (CUSTOM_SIMPLE_EDGE)
+Reducer 33 <- Map 28 (SIMPLE_EDGE)
+Reducer 34 <- Reducer 33 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (CUSTOM_SIMPLE_EDGE), Reducer 30 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Reducer 29 (CUSTOM_SIMPLE_EDGE), Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Reducer 32 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 9 vectorized
+      File Output Operator [FS_352]
+        Limit [LIM_351] (rows=1 width=16)
+          Number of rows:100
+          Select Operator [SEL_350] (rows=1 width=16)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 8 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_349]
+              Select Operator [SEL_348] (rows=1 width=16)
+                Output:["_col0","_col1","_col2"]
+                Group By Operator [GBY_347] (rows=1 width=12)
+                  Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                <-Reducer 7 [SIMPLE_EDGE] vectorized
+                  SHUFFLE [RS_346]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_345] (rows=1 width=12)
+                      Output:["_col0","_col1"],aggregations:["count()"],keys:_col0
+                      Select Operator [SEL_344] (rows=1 width=116)
+                        Output:["_col0"]
+                        Group By Operator [GBY_343] (rows=1 width=116)
+                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                        <-Reducer 6 [SIMPLE_EDGE]
+                          SHUFFLE [RS_118]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_117] (rows=312 width=116)
+                              Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                              Select Operator [SEL_116] (rows=624257222 width=127)
+                                Output:["_col0","_col1"]
+                                Filter Operator [FIL_115] (rows=624257222 width=127)
+                                  predicate:_col2 BETWEEN _col3 AND _col4
+                                  Select Operator [SEL_114] (rows=5618315000 width=127)
+                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                    Merge Join Operator [MERGEJOIN_272] (rows=5618315000 width=127)
+                                      Conds:(Inner),Output:["_col0","_col2","_col6","_col13","_col15"]
+                                    <-Reducer 32 [CUSTOM_SIMPLE_EDGE]
+                                      PARTITION_ONLY_SHUFFLE [RS_111]
+                                        Merge Join Operator [MERGEJOIN_269] (rows=25 width=4)
+                                          Conds:(Right Outer),Output:["_col0"]
+                                        <-Reducer 31 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_334]
+                                            Group By Operator [GBY_333] (rows=25 width=4)
+                                              Output:["_col0"],keys:KEY._col0
+                                            <-Map 28 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_322]
+                                                PartitionCols:_col0
+                                                Group By Operator [GBY_319] (rows=25 width=4)
+                                                  Output:["_col0"],keys:_col0
+                                                  Select Operator [SEL_316] (rows=50 width=12)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_314] (rows=50 width=12)
+                                                      predicate:((d_moy = 3) and (d_year = 1999))
+                                                      TableScan [TS_72] (rows=73049 width=12)
+                                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_month_seq","d_year","d_moy"]
+                                        <-Reducer 34 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_342]
+                                            Select Operator [SEL_341] (rows=1 width=8)
+                                              Filter Operator [FIL_340] (rows=1 width=8)
+                                                predicate:(sq_count_check(_col0) <= 1)
+                                                Group By Operator [GBY_339] (rows=1 width=8)
+                                                  Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                <-Reducer 33 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_338]
+                                                    Group By Operator [GBY_337] (rows=1 width=8)
+                                                      Output:["_col0"],aggregations:["count()"]
+                                                      Select Operator [SEL_336] (rows=25 width=4)
+                                                        Group By Operator [GBY_335] (rows=25 width=4)
+                                                          Output:["_col0"],keys:KEY._col0
+                                                        <-Map 28 [SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_323]
+                                                            PartitionCols:_col0
+                                                            Group By Operator [GBY_320] (rows=25 width=4)
+                                                              Output:["_col0"],keys:_col0
+                                                              Select Operator [SEL_317] (rows=50 width=12)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Filter Operator [FIL_314]
+                                    <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                                      PARTITION_ONLY_SHUFFLE [RS_112]
+                                        Select Operator [SEL_107] (rows=224732600 width=119)
+                                          Output:["_col0","_col4","_col11","_col13"]
+                                          Merge Join Operator [MERGEJOIN_271] (rows=224732600 width=119)
+                                            Conds:(Left Outer),Output:["_col2","_col4","_col10","_col13"]
+                                          <-Reducer 29 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_326]
+                                              Group By Operator [GBY_324] (rows=25 width=4)
+                                                Output:["_col0"],keys:KEY._col0
+                                              <-Map 28 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_321]
+                                                  PartitionCols:_col0
+                                                  Group By Operator [GBY_318] (rows=25 width=4)
+                                                    Output:["_col0"],keys:_col0
+                                                    Select Operator [SEL_315] (rows=50 width=12)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Filter Operator [FIL_314]
+                                          <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                            PARTITION_ONLY_SHUFFLE [RS_104]
+                                              Merge Join Operator [MERGEJOIN_270] (rows=8989304 width=8)
+                                                Conds:(Inner),Output:["_col2","_col4","_col10"]
+                                              <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_101]
+                                                  Merge Join Operator [MERGEJOIN_268] (rows=8989304 width=8)
+                                                    Conds:RS_98._col1=RS_99._col5(Inner),Output:["_col2","_col4","_col10"]
+                                                  <-Reducer 13 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_99]
+                                                      PartitionCols:_col5
+                                                      Merge Join Operator [MERGEJOIN_267] (rows=55046 width=4)
+                                                        Conds:RS_68._col0=RS_306._col1(Inner),Output:["_col5"]
+                                                      <-Reducer 12 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_68]
+                                                          PartitionCols:_col0
+                                                          Merge Join Operator [MERGEJOIN_263] (rows=39720279 width=4)
+                                                            Conds:RS_285._col1, _col2=RS_288._col0, _col1(Inner),Output:["_col0"]
+                                                          <-Map 11 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_285]
+                                                              PartitionCols:_col1, _col2
+                                                              Select Operator [SEL_284] (rows=40000000 width=188)
+                                                                Output:["_col0","_col1","_col2"]
+                                                                Filter Operator [FIL_283] (rows=40000000 width=188)
+                                                                  predicate:(ca_county is not null and ca_state is not null)
+                                                                  TableScan [TS_28] (rows=40000000 width=188)
+                                                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_county","ca_state"]
+                                                          <-Map 15 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_288]
+                                                              PartitionCols:_col0, _col1
+                                                              Select Operator [SEL_287] (rows=1704 width=184)
+                                                                Output:["_col0","_col1"]
+                                                                Filter Operator [FIL_286] (rows=1704 width=184)
+                                                                  predicate:(s_county is not null and s_state is not null)
+                                                                  TableScan [TS_31] (rows=1704 width=184)
+                                                                    default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_county","s_state"]
+                                                      <-Reducer 21 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_306]
+                                                          PartitionCols:_col1
+                                                          Select Operator [SEL_305] (rows=55046 width=8)
+                                                            Output:["_col0","_col1"]
+                                                            Group By Operator [GBY_304] (rows=55046 width=8)
+                                                              Output:["_col0","_col1"],keys:KEY._col0, KEY._col1
+                                                            <-Reducer 20 [SIMPLE_EDGE]
+                                                              SHUFFLE [RS_62]
+                                                                PartitionCols:_col0, _col1
+                                                                Group By Operator [GBY_61] (rows=55046 width=8)
+                                                                  Output:["_col0","_col1"],keys:_col6, _col5
+                                                                  Merge Join Operator [MERGEJOIN_266] (rows=110092 width=8)
+                                                                    Conds:RS_57._col1=RS_303._col0(Inner),Output:["_col5","_col6"]
+                                                                  <-Map 27 [SIMPLE_EDGE] vectorized
+                                                                    SHUFFLE [RS_303]
+                                                                      PartitionCols:_col0
+                                                                      Select Operator [SEL_302] (rows=80000000 width=8)
+                                                                        Output:["_col0","_col1"]
+                                                                        Filter Operator [FIL_301] (rows=80000000 width=8)
+                                                                          predicate:c_current_addr_sk is not null
+                                                                          TableScan [TS_48] (rows=80000000 width=8)
+                                                                            default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk"]
+                                                                  <-Reducer 19 [SIMPLE_EDGE]
+                                                                    SHUFFLE [RS_57]
+                                                                      PartitionCols:_col1
+                                                                      Merge Join Operator [MERGEJOIN_265] (rows=110092 width=0)
+                                                                        Conds:RS_54._col2=RS_297._col0(Inner),Output:["_col1"]
+                                                                      <-Map 25 [SIMPLE_EDGE] vectorized
+                                                                        PARTITION_ONLY_SHUFFLE [RS_297]
+                                                                          PartitionCols:_col0
+                                                                          Select Operator [SEL_296] (rows=453 width=4)
+                                                                            Output:["_col0"]
+                                                                            Filter Operator [FIL_295] (rows=453 width=186)
+                                                                              predicate:((i_category = 'Jewelry') and (i_class = 'consignment'))
+                                                                              TableScan [TS_45] (rows=462000 width=186)
+                                                                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_class","i_category"]
+                                                                      <-Reducer 18 [SIMPLE_EDGE]
+                                                                        SHUFFLE [RS_54]
+                                                                          PartitionCols:_col2
+                                                                          Merge Join Operator [MERGEJOIN_264] (rows=11665117 width=7)
+                                                                            Conds:Union 17._col0=RS_291._col0(Inner),Output:["_col1","_col2"]
+                                                                          <-Map 23 [SIMPLE_EDGE] vectorized
+                                                                            PARTITION_ONLY_SHUFFLE [RS_291]
+                                                                              PartitionCols:_col0
+                                                                              Select Operator [SEL_290] (rows=50 width=4)
+                                                                                Output:["_col0"]
+                                                                                Filter Operator [FIL_289] (rows=50 width=12)
+                                                                                  predicate:((d_moy = 3) and (d_year = 1999))
+                                                                                  TableScan [TS_42] (rows=73049 width=12)
+                                                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                                                          <-Union 17 [SIMPLE_EDGE]
+                                                                            <-Map 16 [CONTAINS] vectorized
+                                                                              Reduce Output Operator [RS_361]
+                                                                                PartitionCols:_col0
+                                                                                Select Operator [SEL_360] (rows=285117831 width=11)
+                                                                                  Output:["_col0","_col1","_col2"]
+                                                                                  Filter Operator [FIL_359] (rows=285117831 width=11)
+                                                                                    predicate:((cs_item_sk BETWEEN DynamicValue(RS_55_item_i_item_sk_min) AND DynamicValue(RS_55_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_55_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_52_date_dim_d_date_sk_min) AND DynamicValue(RS_52_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_52_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                                                                    TableScan [TS_273] (rows=287989836 width=11)
+                                                                                      Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk"]
+                                                                                    <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                                                      BROADCAST [RS_354]
+                                                                                        Group By Operator [GBY_353] (rows=1 width=12)
+                                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                        <-Map 23 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                          PARTITION_ONLY_SHUFFLE [RS_294]
+                                                                                            Group By Operator [GBY_293] (rows=1 width=12)
+                                                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                              Select Operator [SEL_292] (rows=50 width=4)
+                                                                                                Output:["_col0"]
+                                                                                                 Please refer to the previous Select Operator [SEL_290]
+                                                                                    <-Reducer 26 [BROADCAST_EDGE] vectorized
+                                                                                      BROADCAST [RS_357]
+                                                                                        Group By Operator [GBY_356] (rows=1 width=12)
+                                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                        <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                          PARTITION_ONLY_SHUFFLE [RS_300]
+                                                                                            Group By Operator [GBY_299] (rows=1 width=12)
+                                                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                              Select Operator [SEL_298] (rows=453 width=4)
+                                                                                                Output:["_col0"]
+                                                                                                 Please refer to the previous Select Operator [SEL_296]
+                                                                            <-Map 22 [CONTAINS] vectorized
+                                                                              Reduce Output Operator [RS_364]
+                                                                                PartitionCols:_col0
+                                                                                Select Operator [SEL_363] (rows=143930993 width=11)
+                                                                                  Output:["_col0","_col1","_col2"]
+                                                                                  Filter Operator [FIL_362] (rows=143930993 width=11)
+                                                                                    predicate:((ws_item_sk BETWEEN DynamicValue(RS_55_item_i_item_sk_min) AND DynamicValue(RS_55_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_55_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_52_date_dim_d_date_sk_min) AND DynamicValue(RS_52_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_52_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                                                    TableScan [TS_278] (rows=144002668 width=11)
+                                                                                      Output:["ws_sold_date_sk","ws_item_sk","ws_bill_customer_sk"]
+                                                                                    <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                                                      BROADCAST [RS_355]
+                                                                                         Please refer to the previous Group By Operator [GBY_353]
+                                                                                    <-Reducer 26 [BROADCAST_EDGE] vectorized
+                                                                                      BROADCAST [RS_358]
+                                                                                         Please refer to the previous Group By Operator [GBY_356]
+                                                  <-Reducer 2 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_98]
+                                                      PartitionCols:_col1
+                                                      Merge Join Operator [MERGEJOIN_262] (rows=525327388 width=114)
+                                                        Conds:RS_311._col0=RS_313._col0(Inner),Output:["_col1","_col2","_col4"]
+                                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_311]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_310] (rows=525327388 width=114)
+                                                            Output:["_col0","_col1","_col2"]
+                                                            Filter Operator [FIL_309] (rows=525327388 width=114)
+                                                              predicate:((ss_customer_sk BETWEEN DynamicValue(RS_99_customer_c_customer_sk_min) AND DynamicValue(RS_99_customer_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_99_customer_c_customer_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                              TableScan [TS_23] (rows=575995635 width=114)
+                                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_ext_sales_price"]
+                                                              <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_308]
+                                                                  Group By Operator [GBY_307] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Reducer 13 [CUSTOM_SIMPLE_EDGE]
+                                                                    SHUFFLE [RS_182]
+                                                                      Group By Operator [GBY_181] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_180] (rows=55046 width=8)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_267]
+                                                      <-Map 10 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_313]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_312] (rows=73049 width=8)
+                                                            Output:["_col0","_col1"]
+                                                            TableScan [TS_26] (rows=73049 width=8)
+                                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq"]
+                                              <-Reducer 30 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_332]
+                                                  Select Operator [SEL_331] (rows=1 width=8)
+                                                    Filter Operator [FIL_330] (rows=1 width=8)
+                                                      predicate:(sq_count_check(_col0) <= 1)
+                                                      Group By Operator [GBY_329] (rows=1 width=8)
+                                                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                      <-Reducer 29 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_328]
+                                                          Group By Operator [GBY_327] (rows=1 width=8)
+                                                            Output:["_col0"],aggregations:["count()"]
+                                                            Select Operator [SEL_325] (rows=25 width=4)
+                                                               Please refer to the previous Group By Operator [GBY_324]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query55.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query55.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query55.q.out
new file mode 100644
index 0000000..eb6b84f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query55.q.out
@@ -0,0 +1,123 @@
+PREHOOK: query: explain
+select  i_brand_id brand_id, i_brand brand,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+ 	and ss_item_sk = i_item_sk
+ 	and i_manager_id=36
+ 	and d_moy=12
+ 	and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_brand_id brand_id, i_brand brand,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+ 	and ss_item_sk = i_item_sk
+ 	and i_manager_id=36
+ 	and d_moy=12
+ 	and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 7 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_79]
+        Limit [LIM_78] (rows=100 width=220)
+          Number of rows:100
+          Select Operator [SEL_77] (rows=7333 width=220)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_76]
+              Select Operator [SEL_75] (rows=7333 width=220)
+                Output:["_col1","_col2","_col3"]
+                Group By Operator [GBY_74] (rows=7333 width=216)
+                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                <-Reducer 3 [SIMPLE_EDGE]
+                  SHUFFLE [RS_17]
+                    PartitionCols:_col0, _col1
+                    Group By Operator [GBY_16] (rows=7333 width=216)
+                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col5, _col6
+                      Merge Join Operator [MERGEJOIN_54] (rows=2301098 width=104)
+                        Conds:RS_12._col1=RS_65._col0(Inner),Output:["_col2","_col5","_col6"]
+                      <-Map 8 [SIMPLE_EDGE] vectorized
+                        PARTITION_ONLY_SHUFFLE [RS_65]
+                          PartitionCols:_col0
+                          Select Operator [SEL_64] (rows=7333 width=107)
+                            Output:["_col0","_col1","_col2"]
+                            Filter Operator [FIL_63] (rows=7333 width=111)
+                              predicate:(i_manager_id = 36)
+                              TableScan [TS_6] (rows=462000 width=111)
+                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand_id","i_brand","i_manager_id"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_12]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_53] (rows=15062131 width=4)
+                            Conds:RS_73._col0=RS_57._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_57]
+                              PartitionCols:_col0
+                              Select Operator [SEL_56] (rows=50 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_55] (rows=50 width=12)
+                                  predicate:((d_moy = 12) and (d_year = 2001))
+                                  TableScan [TS_3] (rows=73049 width=12)
+                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_73]
+                              PartitionCols:_col0
+                              Select Operator [SEL_72] (rows=550076554 width=114)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_71] (rows=550076554 width=114)
+                                  predicate:((ss_item_sk BETWEEN DynamicValue(RS_13_item_i_item_sk_min) AND DynamicValue(RS_13_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_13_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_10_date_dim_d_date_sk_min) AND DynamicValue(RS_10_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_10_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                  TableScan [TS_0] (rows=575995635 width=114)
+                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
+                                  <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_62]
+                                      Group By Operator [GBY_61] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_60]
+                                          Group By Operator [GBY_59] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_58] (rows=50 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_56]
+                                  <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_70]
+                                      Group By Operator [GBY_69] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_68]
+                                          Group By Operator [GBY_67] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_66] (rows=7333 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_64]
+


[37/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query93.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query93.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query93.q.out
new file mode 100644
index 0000000..60b7557
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query93.q.out
@@ -0,0 +1,59 @@
+PREHOOK: query: explain cbo
+select  ss_customer_sk
+            ,sum(act_sales) sumsales
+      from (select ss_item_sk
+                  ,ss_ticket_number
+                  ,ss_customer_sk
+                  ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price
+                                                            else (ss_quantity*ss_sales_price) end act_sales
+            from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk
+                                                               and sr_ticket_number = ss_ticket_number)
+                ,reason
+            where sr_reason_sk = r_reason_sk
+              and r_reason_desc = 'Did not like the warranty') t
+      group by ss_customer_sk
+      order by sumsales, ss_customer_sk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@reason
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  ss_customer_sk
+            ,sum(act_sales) sumsales
+      from (select ss_item_sk
+                  ,ss_ticket_number
+                  ,ss_customer_sk
+                  ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price
+                                                            else (ss_quantity*ss_sales_price) end act_sales
+            from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk
+                                                               and sr_ticket_number = ss_ticket_number)
+                ,reason
+            where sr_reason_sk = r_reason_sk
+              and r_reason_desc = 'Did not like the warranty') t
+      group by ss_customer_sk
+      order by sumsales, ss_customer_sk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@reason
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], sort1=[$0], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(ss_customer_sk=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(ss_customer_sk=[$1], act_sales=[CASE(IS NOT NULL($8), *(CAST(-($3, $8)):DECIMAL(10, 0), $4), *(CAST($3):DECIMAL(10, 0), $4))])
+        HiveJoin(condition=[AND(=($5, $0), =($7, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_ticket_number=[$9], ss_quantity=[$10], ss_sales_price=[$13])
+            HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($9))])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(sr_item_sk=[$2], sr_reason_sk=[$8], sr_ticket_number=[$9], sr_return_quantity=[$10])
+              HiveFilter(condition=[AND(IS NOT NULL($8), IS NOT NULL($2), IS NOT NULL($9))])
+                HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+            HiveProject(r_reason_sk=[$0], r_reason_desc=[CAST(_UTF-16LE'Did not like the warranty'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+              HiveFilter(condition=[AND(=($2, _UTF-16LE'Did not like the warranty'), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, reason]], table:alias=[reason])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query94.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query94.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query94.q.out
new file mode 100644
index 0000000..4f97a67
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query94.q.out
@@ -0,0 +1,100 @@
+PREHOOK: query: explain cbo
+select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and exists (select *
+            from web_sales ws2
+            where ws1.ws_order_number = ws2.ws_order_number
+              and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+and not exists(select *
+               from web_returns wr1
+               where ws1.ws_order_number = wr1.wr_order_number)
+order by count(distinct ws_order_number)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and exists (select *
+            from web_sales ws2
+            where ws1.ws_order_number = ws2.ws_order_number
+              and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+and not exists(select *
+               from web_returns wr1
+               where ws1.ws_order_number = wr1.wr_order_number)
+order by count(distinct ws_order_number)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2])
+  HiveSortLimit(sort0=[$3], dir0=[ASC], fetch=[100])
+    HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2], (tok_functiondi count (tok_table_or_col ws_order_number))=[$0])
+      HiveAggregate(group=[{}], agg#0=[count(DISTINCT $4)], agg#1=[sum($5)], agg#2=[sum($6)])
+        HiveFilter(condition=[IS NULL($14)])
+          HiveJoin(condition=[=($4, $13)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveSemiJoin(condition=[AND(<>($3, $13), =($4, $14))], joinType=[inner])
+              HiveProject(ws_ship_date_sk=[$2], ws_ship_addr_sk=[$3], ws_web_site_sk=[$4], ws_warehouse_sk=[$5], ws_order_number=[$6], ws_ext_ship_cost=[$7], ws_net_profit=[$8], d_date_sk=[$9], d_date=[$10], ca_address_sk=[$0], ca_state=[$1], web_site_sk=[$11], web_company_name=[$12])
+                HiveJoin(condition=[=($4, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_state=[CAST(_UTF-16LE'TX'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(=($8, _UTF-16LE'TX'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_ship_date_sk=[$2], ws_ship_addr_sk=[$11], ws_web_site_sk=[$13], ws_warehouse_sk=[$15], ws_order_number=[$17], ws_ext_ship_cost=[$28], ws_net_profit=[$33])
+                        HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($11), IS NOT NULL($13), IS NOT NULL($17))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1999-05-01 00:00:00, 1999-06-30 00:00:00), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(web_site_sk=[$0], web_company_name=[CAST(_UTF-16LE'pri'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                    HiveFilter(condition=[AND(=($14, _UTF-16LE'pri'), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+              HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                HiveFilter(condition=[AND(IS NOT NULL($17), IS NOT NULL($15))])
+                  HiveTableScan(table=[[default, web_sales]], table:alias=[ws2])
+            HiveProject(wr_order_number0=[$0], $f1=[true])
+              HiveAggregate(group=[{13}])
+                HiveFilter(condition=[IS NOT NULL($13)])
+                  HiveTableScan(table=[[default, web_returns]], table:alias=[wr1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query95.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query95.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query95.q.out
new file mode 100644
index 0000000..c248890
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query95.q.out
@@ -0,0 +1,120 @@
+PREHOOK: query: explain cbo
+with ws_wh as
+(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2
+ from web_sales ws1,web_sales ws2
+ where ws1.ws_order_number = ws2.ws_order_number
+   and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+ select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and ws1.ws_order_number in (select ws_order_number
+                            from ws_wh)
+and ws1.ws_order_number in (select wr_order_number
+                            from web_returns,ws_wh
+                            where wr_order_number = ws_wh.ws_order_number)
+order by count(distinct ws_order_number)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ws_wh as
+(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2
+ from web_sales ws1,web_sales ws2
+ where ws1.ws_order_number = ws2.ws_order_number
+   and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+ select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and ws1.ws_order_number in (select ws_order_number
+                            from ws_wh)
+and ws1.ws_order_number in (select wr_order_number
+                            from web_returns,ws_wh
+                            where wr_order_number = ws_wh.ws_order_number)
+order by count(distinct ws_order_number)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2])
+  HiveSortLimit(sort0=[$3], dir0=[ASC], fetch=[100])
+    HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2], (tok_functiondi count (tok_table_or_col ws_order_number))=[$0])
+      HiveAggregate(group=[{}], agg#0=[count(DISTINCT $7)], agg#1=[sum($8)], agg#2=[sum($9)])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(wr_order_number=[$0])
+            HiveAggregate(group=[{14}])
+              HiveJoin(condition=[=($14, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_order_number=[$1])
+                  HiveJoin(condition=[AND(=($1, $3), <>($0, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                      HiveFilter(condition=[IS NOT NULL($17)])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                    HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                      HiveFilter(condition=[IS NOT NULL($17)])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[ws2])
+                HiveProject(wr_returned_date_sk=[$0], wr_returned_time_sk=[$1], wr_item_sk=[$2], wr_refunded_customer_sk=[$3], wr_refunded_cdemo_sk=[$4], wr_refunded_hdemo_sk=[$5], wr_refunded_addr_sk=[$6], wr_returning_customer_sk=[$7], wr_returning_cdemo_sk=[$8], wr_returning_hdemo_sk=[$9], wr_returning_addr_sk=[$10], wr_web_page_sk=[$11], wr_reason_sk=[$12], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15], wr_return_tax=[$16], wr_return_amt_inc_tax=[$17], wr_fee=[$18], wr_return_ship_cost=[$19], wr_refunded_cash=[$20], wr_reversed_charge=[$21], wr_account_credit=[$22], wr_net_loss=[$23], BLOCK__OFFSET__INSIDE__FILE=[$24], INPUT__FILE__NAME=[$25], ROW__ID=[$26])
+                  HiveFilter(condition=[IS NOT NULL($13)])
+                    HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+          HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ws_order_number=[$0])
+              HiveAggregate(group=[{1}])
+                HiveJoin(condition=[AND(=($1, $3), <>($0, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                    HiveFilter(condition=[IS NOT NULL($17)])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                  HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                    HiveFilter(condition=[IS NOT NULL($17)])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[ws2])
+            HiveJoin(condition=[=($4, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0], ca_state=[CAST(_UTF-16LE'TX'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                  HiveFilter(condition=[AND(=($8, _UTF-16LE'TX'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_ship_date_sk=[$2], ws_ship_addr_sk=[$11], ws_web_site_sk=[$13], ws_order_number=[$17], ws_ext_ship_cost=[$28], ws_net_profit=[$33])
+                    HiveFilter(condition=[AND(IS NOT NULL($17), IS NOT NULL($2), IS NOT NULL($11), IS NOT NULL($13))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1999-05-01 00:00:00, 1999-06-30 00:00:00), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(web_site_sk=[$0], web_company_name=[CAST(_UTF-16LE'pri'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                HiveFilter(condition=[AND(=($14, _UTF-16LE'pri'), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query96.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query96.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query96.q.out
new file mode 100644
index 0000000..6367e98
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query96.q.out
@@ -0,0 +1,61 @@
+PREHOOK: query: explain cbo
+select  count(*) 
+from store_sales
+    ,household_demographics 
+    ,time_dim, store
+where ss_sold_time_sk = time_dim.t_time_sk   
+    and ss_hdemo_sk = household_demographics.hd_demo_sk 
+    and ss_store_sk = s_store_sk
+    and time_dim.t_hour = 8
+    and time_dim.t_minute >= 30
+    and household_demographics.hd_dep_count = 5
+    and store.s_store_name = 'ese'
+order by count(*)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  count(*) 
+from store_sales
+    ,household_demographics 
+    ,time_dim, store
+where ss_sold_time_sk = time_dim.t_time_sk   
+    and ss_hdemo_sk = household_demographics.hd_demo_sk 
+    and ss_store_sk = s_store_sk
+    and time_dim.t_hour = 8
+    and time_dim.t_minute >= 30
+    and household_demographics.hd_dep_count = 5
+    and store.s_store_name = 'ese'
+order by count(*)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(_o__c0=[$0])
+  HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+    HiveProject(_o__c0=[$0], (tok_functionstar count)=[$0])
+      HiveAggregate(group=[{}], agg#0=[count()])
+        HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(t_time_sk=[$0], t_hour=[CAST(8):INTEGER], t_minute=[$4])
+                HiveFilter(condition=[AND(=($3, 8), >=($4, 30), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(hd_demo_sk=[$0], hd_dep_count=[CAST(5):INTEGER])
+              HiveFilter(condition=[AND(=($3, 5), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+          HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+            HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query97.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query97.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query97.q.out
new file mode 100644
index 0000000..5cd8582
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query97.q.out
@@ -0,0 +1,81 @@
+PREHOOK: query: explain cbo
+with ssci as (
+select ss_customer_sk customer_sk
+      ,ss_item_sk item_sk
+from store_sales,date_dim
+where ss_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by ss_customer_sk
+        ,ss_item_sk),
+csci as(
+ select cs_bill_customer_sk customer_sk
+      ,cs_item_sk item_sk
+from catalog_sales,date_dim
+where cs_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by cs_bill_customer_sk
+        ,cs_item_sk)
+ select  sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
+      ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
+      ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
+from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk
+                               and ssci.item_sk = csci.item_sk)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssci as (
+select ss_customer_sk customer_sk
+      ,ss_item_sk item_sk
+from store_sales,date_dim
+where ss_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by ss_customer_sk
+        ,ss_item_sk),
+csci as(
+ select cs_bill_customer_sk customer_sk
+      ,cs_item_sk item_sk
+from catalog_sales,date_dim
+where cs_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by cs_bill_customer_sk
+        ,cs_item_sk)
+ select  sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
+      ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
+      ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
+from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk
+                               and ssci.item_sk = csci.item_sk)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+    HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[sum($1)], agg#2=[sum($2)])
+      HiveProject($f0=[CASE(AND(IS NOT NULL($0), IS NULL($2)), 1, 0)], $f1=[CASE(AND(IS NULL($0), IS NOT NULL($2)), 1, 0)], $f2=[CASE(AND(IS NOT NULL($0), IS NOT NULL($2)), 1, 0)])
+        HiveJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[full], algorithm=[none], cost=[not available])
+          HiveProject(ss_customer_sk=[$1], ss_item_sk=[$0])
+            HiveAggregate(group=[{1, 2}])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                  HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(cs_bill_customer_sk=[$0], cs_item_sk=[$1])
+            HiveAggregate(group=[{1, 2}])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                  HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out
new file mode 100644
index 0000000..804885c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query98.q.out
@@ -0,0 +1,87 @@
+PREHOOK: query: explain cbo
+select i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ss_ext_sales_price) as itemrevenue 
+      ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	store_sales
+    	,item 
+    	,date_dim
+where 
+	ss_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ss_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ss_ext_sales_price) as itemrevenue 
+      ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	store_sales
+    	,item 
+    	,date_dim
+where 
+	ss_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ss_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3], itemrevenue=[$4], revenueratio=[$5])
+  HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$6], sort3=[$0], sort4=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC])
+    HiveProject(i_item_desc=[$1], i_category=[$4], i_class=[$3], i_current_price=[$2], itemrevenue=[$5], revenueratio=[/(*($5, CAST(100):DECIMAL(10, 0)), sum($5) OVER (PARTITION BY $3 ORDER BY $3 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING))], (tok_table_or_col i_item_id)=[$0])
+      HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
+            HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+              HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0], d_date=[$2])
+              HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-01-12 00:00:00, 2001-02-11 00:00:00), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query99.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query99.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query99.q.out
new file mode 100644
index 0000000..75d0e60
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query99.q.out
@@ -0,0 +1,106 @@
+PREHOOK: query: explain cbo
+select  
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and
+                 (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   catalog_sales
+  ,warehouse
+  ,ship_mode
+  ,call_center
+  ,date_dim
+where
+    d_month_seq between 1212 and 1212 + 11
+and cs_ship_date_sk   = d_date_sk
+and cs_warehouse_sk   = w_warehouse_sk
+and cs_ship_mode_sk   = sm_ship_mode_sk
+and cs_call_center_sk = cc_call_center_sk
+group by
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+order by substr(w_warehouse_name,1,20)
+        ,sm_type
+        ,cc_name
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@ship_mode
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and
+                 (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   catalog_sales
+  ,warehouse
+  ,ship_mode
+  ,call_center
+  ,date_dim
+where
+    d_month_seq between 1212 and 1212 + 11
+and cs_ship_date_sk   = d_date_sk
+and cs_warehouse_sk   = w_warehouse_sk
+and cs_ship_mode_sk   = sm_ship_mode_sk
+and cs_call_center_sk = cc_call_center_sk
+group by
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+order by substr(w_warehouse_name,1,20)
+        ,sm_type
+        ,cc_name
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@ship_mode
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(_o__c0=[$0], sm_type=[$1], cc_name=[$2], 30 days=[$3], 31-60 days=[$4], 61-90 days=[$5], 91-120 days=[$6], >120 days=[$7])
+  HiveSortLimit(sort0=[$8], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(_o__c0=[$0], sm_type=[$1], cc_name=[$2], 30 days=[$3], 31-60 days=[$4], 61-90 days=[$5], 91-120 days=[$6], >120 days=[$7], (tok_function substr (tok_table_or_col w_warehouse_name) 1 20)=[$0])
+      HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[sum($4)], agg#2=[sum($5)], agg#3=[sum($6)], agg#4=[sum($7)])
+        HiveProject($f0=[substr($10, 1, 20)], $f1=[$12], $f2=[$8], $f3=[CASE(<=(-($1, $0), 30), 1, 0)], $f4=[CASE(AND(>(-($1, $0), 30), <=(-($1, $0), 60)), 1, 0)], $f5=[CASE(AND(>(-($1, $0), 60), <=(-($1, $0), 90)), 1, 0)], $f6=[CASE(AND(>(-($1, $0), 90), <=(-($1, $0), 120)), 1, 0)], $f7=[CASE(>(-($1, $0), 120), 1, 0)])
+          HiveJoin(condition=[=($3, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($4, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_ship_date_sk=[$2], cs_call_center_sk=[$11], cs_ship_mode_sk=[$13], cs_warehouse_sk=[$14])
+                    HiveFilter(condition=[AND(IS NOT NULL($14), IS NOT NULL($13), IS NOT NULL($11), IS NOT NULL($2))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                    HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+              HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+            HiveProject(sm_ship_mode_sk=[$0], sm_type=[$2])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query1.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query1.q.out
new file mode 100644
index 0000000..13801ff
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query1.q.out
@@ -0,0 +1,90 @@
+PREHOOK: query: explain cbo
+with customer_total_return as
+(select sr_customer_sk as ctr_customer_sk
+,sr_store_sk as ctr_store_sk
+,sum(SR_FEE) as ctr_total_return
+from store_returns
+,date_dim
+where sr_returned_date_sk = d_date_sk
+and d_year =2000
+group by sr_customer_sk
+,sr_store_sk)
+ select  c_customer_id
+from customer_total_return ctr1
+,store
+,customer
+where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+from customer_total_return ctr2
+where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
+and s_store_sk = ctr1.ctr_store_sk
+and s_state = 'NM'
+and ctr1.ctr_customer_sk = c_customer_sk
+order by c_customer_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with customer_total_return as
+(select sr_customer_sk as ctr_customer_sk
+,sr_store_sk as ctr_store_sk
+,sum(SR_FEE) as ctr_total_return
+from store_returns
+,date_dim
+where sr_returned_date_sk = d_date_sk
+and d_year =2000
+group by sr_customer_sk
+,sr_store_sk)
+ select  c_customer_id
+from customer_total_return ctr1
+,store
+,customer
+where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+from customer_total_return ctr2
+where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
+and s_store_sk = ctr1.ctr_store_sk
+and s_state = 'NM'
+and ctr1.ctr_customer_sk = c_customer_sk
+order by c_customer_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(c_customer_id=[$1])
+    HiveJoin(condition=[AND(=($3, $7), >($4, $6))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_customer_id=[$1])
+          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveJoin(condition=[=($3, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(sr_customer_sk=[$0], sr_store_sk=[$1], $f2=[$2])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_returned_date_sk=[$0], sr_customer_sk=[$3], sr_store_sk=[$7], sr_fee=[$14])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[=($6, 2000)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(s_store_sk=[$0])
+            HiveFilter(condition=[=($24, _UTF-16LE'NM')])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+      HiveProject(_o__c0=[*(/($1, $2), 1.2)], ctr_store_sk=[$0])
+        HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+          HiveProject(sr_customer_sk=[$0], sr_store_sk=[$1], $f2=[$2])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_returned_date_sk=[$0], sr_customer_sk=[$3], sr_store_sk=[$7], sr_fee=[$14])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[=($6, 2000)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out
new file mode 100644
index 0000000..42e3df0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query10.q.out
@@ -0,0 +1,177 @@
+PREHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2002 and
+                d_moy between 4 and 4+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 ANd 4+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 and 4+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2002 and
+                d_moy between 4 and 4+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 ANd 4+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 and 4+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$4], sort4=[$6], sort5=[$8], sort6=[$10], sort7=[$12], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], fetch=[100])
+  HiveProject(cd_gender=[$0], cd_marital_status=[$1], cd_education_status=[$2], cnt1=[$8], cd_purchase_estimate=[$3], cnt2=[$8], cd_credit_rating=[$4], cnt3=[$8], cd_dep_count=[$5], cnt4=[$8], cd_dep_employed_count=[$6], cnt5=[$8], cd_dep_college_count=[$7], cnt6=[$8])
+    HiveAggregate(group=[{6, 7, 8, 9, 10, 11, 12, 13}], agg#0=[count()])
+      HiveFilter(condition=[OR(IS NOT NULL($15), IS NOT NULL($17))])
+        HiveJoin(condition=[=($0, $16)], joinType=[left], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $14)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveSemiJoin(condition=[=($0, $14)], joinType=[inner])
+              HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                      HiveTableScan(table=[[default, customer]], table:alias=[c])
+                  HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                    HiveFilter(condition=[IN($7, _UTF-16LE'Walker County', _UTF-16LE'Richland County', _UTF-16LE'Gaines County', _UTF-16LE'Douglas County', _UTF-16LE'Dona Ana County')])
+                      HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
+                HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_education_status=[$3], cd_purchase_estimate=[$4], cd_credit_rating=[$5], cd_dep_count=[$6], cd_dep_employed_count=[$7], cd_dep_college_count=[$8])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+              HiveProject(ss_customer_sk0=[$1])
+                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($6, 2002), BETWEEN(false, $8, 4, 7))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(ws_bill_customer_sk0=[$0], $f1=[true])
+              HiveAggregate(group=[{1}])
+                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($6, 2002), BETWEEN(false, $8, 4, 7))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(cs_ship_customer_sk0=[$0], $f1=[true])
+            HiveAggregate(group=[{1}])
+              HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_ship_customer_sk=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[AND(=($6, 2002), BETWEEN(false, $8, 4, 7))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out
new file mode 100644
index 0000000..cd1eb71
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query11.q.out
@@ -0,0 +1,215 @@
+PREHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year 
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.c_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.dyear = 2001
+         and t_s_secyear.dyear = 2001+1
+         and t_w_firstyear.dyear = 2001
+         and t_w_secyear.dyear = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+             > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by t_s_secyear.c_preferred_cust_flag
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year 
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.c_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.dyear = 2001
+         and t_s_secyear.dyear = 2001+1
+         and t_w_firstyear.dyear = 2001
+         and t_w_secyear.dyear = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+             > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by t_s_secyear.c_preferred_cust_flag
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(c_preferred_cust_flag=[$1])
+    HiveJoin(condition=[AND(=($0, $5), CASE($7, CASE($10, >(/($4, $9), /($2, $6)), >(null, /($2, $6))), CASE($10, >(/($4, $9), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject($f0=[$0], $f4=[$3], $f9=[$7])
+        HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+          HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], -=[-($17, $14)])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[=($6, 2002)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f8=[$7])
+            HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+              HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], -=[-($25, $22)])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[=($6, 2002)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
+            HiveFilter(condition=[>($7, 0)])
+              HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+                HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], -=[-($17, $14)])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[=($6, 2001)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
+          HiveFilter(condition=[>($7, 0)])
+            HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+              HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], -=[-($25, $22)])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[=($6, 2001)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out
new file mode 100644
index 0000000..ab4a837
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query12.q.out
@@ -0,0 +1,89 @@
+PREHOOK: query: explain cbo
+select  i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ws_ext_sales_price) as itemrevenue 
+      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	web_sales
+    	,item 
+    	,date_dim
+where 
+	ws_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ws_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ws_ext_sales_price) as itemrevenue 
+      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	web_sales
+    	,item 
+    	,date_dim
+where 
+	ws_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ws_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3], itemrevenue=[$4], revenueratio=[$5])
+  HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$6], sort3=[$0], sort4=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+    HiveProject(i_item_desc=[$1], i_category=[$4], i_class=[$3], i_current_price=[$2], itemrevenue=[$5], revenueratio=[/(*($5, CAST(100):DECIMAL(10, 0)), sum($5) OVER (PARTITION BY $3 ORDER BY $3 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING))], (tok_table_or_col i_item_id)=[$0])
+      HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
+            HiveFilter(condition=[IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books')])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_sales_price=[$23])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-01-12 00:00:00, 2001-02-11 00:00:00)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query13.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query13.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query13.q.out
new file mode 100644
index 0000000..811a518
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query13.q.out
@@ -0,0 +1,137 @@
+PREHOOK: query: explain cbo
+select avg(ss_quantity)
+       ,avg(ss_ext_sales_price)
+       ,avg(ss_ext_wholesale_cost)
+       ,sum(ss_ext_wholesale_cost)
+ from store_sales
+     ,store
+     ,customer_demographics
+     ,household_demographics
+     ,customer_address
+     ,date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 2001
+ and((ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'M'
+  and cd_education_status = '4 yr Degree'
+  and ss_sales_price between 100.00 and 150.00
+  and hd_dep_count = 3   
+     )or
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'D'
+  and cd_education_status = 'Primary'
+  and ss_sales_price between 50.00 and 100.00   
+  and hd_dep_count = 1
+     ) or 
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'U'
+  and cd_education_status = 'Advanced Degree'
+  and ss_sales_price between 150.00 and 200.00 
+  and hd_dep_count = 1  
+     ))
+ and((ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 100 and 200  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 300  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 250  
+     ))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select avg(ss_quantity)
+       ,avg(ss_ext_sales_price)
+       ,avg(ss_ext_wholesale_cost)
+       ,sum(ss_ext_wholesale_cost)
+ from store_sales
+     ,store
+     ,customer_demographics
+     ,household_demographics
+     ,customer_address
+     ,date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 2001
+ and((ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'M'
+  and cd_education_status = '4 yr Degree'
+  and ss_sales_price between 100.00 and 150.00
+  and hd_dep_count = 3   
+     )or
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'D'
+  and cd_education_status = 'Primary'
+  and ss_sales_price between 50.00 and 100.00   
+  and hd_dep_count = 1
+     ) or 
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'U'
+  and cd_education_status = 'Advanced Degree'
+  and ss_sales_price between 150.00 and 200.00 
+  and hd_dep_count = 1  
+     ))
+ and((ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 100 and 200  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 300  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 250  
+     ))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject($f0=[/(CAST($0):DOUBLE, $1)], $f1=[/($2, $3)], $f2=[/($4, $5)], $f3=[CAST($4):DECIMAL(17, 2)])
+  HiveAggregate(group=[{}], agg#0=[sum($19)], agg#1=[count($19)], agg#2=[sum($20)], agg#3=[count($20)], agg#4=[sum($21)], agg#5=[count($21)])
+    HiveJoin(condition=[AND(=($0, $16), OR(AND($1, $2, $25, $12), AND($3, $4, $26, $13), AND($5, $6, $27, $13)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(cd_demo_sk=[$0], ==[=($2, _UTF-16LE'M')], =2=[=($3, _UTF-16LE'4 yr Degree')], =3=[=($2, _UTF-16LE'D')], =4=[=($3, _UTF-16LE'Primary')], =5=[=($2, _UTF-16LE'U')], =6=[=($3, _UTF-16LE'Advanced Degree')])
+        HiveFilter(condition=[AND(IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'), IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'))])
+          HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+      HiveJoin(condition=[AND(=($11, $0), OR(AND($1, $15), AND($2, $16), AND($3, $17)))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM')], IN2=[IN($8, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN')], IN3=[IN($8, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV')])
+          HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'))])
+            HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+        HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(hd_demo_sk=[$0], ==[=($3, 3)], =2=[=($3, 1)])
+            HiveFilter(condition=[IN($3, 3, 1)])
+              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+          HiveJoin(condition=[=($1, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[=($6, 2001)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(ss_sold_date_sk=[$0], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_quantity=[$10], ss_ext_sales_price=[$15], ss_ext_wholesale_cost=[$16], BETWEEN=[BETWEEN(false, $22, 100, 200)], BETWEEN9=[BETWEEN(false, $22, 150, 300)], BETWEEN10=[BETWEEN(false, $22, 50, 250)], BETWEEN11=[BETWEEN(false, $13, 100, 150)], BETWEEN12=[BETWEEN(false, $13, 50, 100)], BETWEEN13=[BETWEEN(false, $13, 150, 200)])
+              HiveFilter(condition=[AND(OR(BETWEEN(false, $13, 100, 150), BETWEEN(false, $13, 50, 100), BETWEEN(false, $13, 150, 200)), OR(BETWEEN(false, $22, 100, 200), BETWEEN(false, $22, 150, 300), BETWEEN(false, $22, 50, 250)), IS NOT NULL($7), IS NOT NULL($4), IS NOT NULL($5), IS NOT NULL($6), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+


[29/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out
new file mode 100644
index 0000000..0ac295b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query77.q.out
@@ -0,0 +1,304 @@
+Warning: Shuffle Join MERGEJOIN[225][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 14' is a cross product
+PREHOOK: query: explain cbo
+with ss as
+ (select s_store_sk,
+         sum(ss_ext_sales_price) as sales,
+         sum(ss_net_profit) as profit
+ from store_sales,
+      date_dim,
+      store
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days) 
+       and ss_store_sk = s_store_sk
+ group by s_store_sk)
+ ,
+ sr as
+ (select s_store_sk,
+         sum(sr_return_amt) as returns,
+         sum(sr_net_loss) as profit_loss
+ from store_returns,
+      date_dim,
+      store
+ where sr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and sr_store_sk = s_store_sk
+ group by s_store_sk), 
+ cs as
+ (select cs_call_center_sk,
+        sum(cs_ext_sales_price) as sales,
+        sum(cs_net_profit) as profit
+ from catalog_sales,
+      date_dim
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ group by cs_call_center_sk 
+ ), 
+ cr as
+ (select
+        sum(cr_return_amount) as returns,
+        sum(cr_net_loss) as profit_loss
+ from catalog_returns,
+      date_dim
+ where cr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ ), 
+ ws as
+ ( select wp_web_page_sk,
+        sum(ws_ext_sales_price) as sales,
+        sum(ws_net_profit) as profit
+ from web_sales,
+      date_dim,
+      web_page
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ws_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk), 
+ wr as
+ (select wp_web_page_sk,
+        sum(wr_return_amt) as returns,
+        sum(wr_net_loss) as profit_loss
+ from web_returns,
+      date_dim,
+      web_page
+ where wr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and wr_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , ss.s_store_sk as id
+        , sales
+        , coalesce(returns, 0) as returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ss left join sr
+        on  ss.s_store_sk = sr.s_store_sk
+ union all
+ select 'catalog channel' as channel
+        , cs_call_center_sk as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  cs
+       , cr
+ union all
+ select 'web channel' as channel
+        , ws.wp_web_page_sk as id
+        , sales
+        , coalesce(returns, 0) returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ws left join wr
+        on  ws.wp_web_page_sk = wr.wp_web_page_sk
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ss as
+ (select s_store_sk,
+         sum(ss_ext_sales_price) as sales,
+         sum(ss_net_profit) as profit
+ from store_sales,
+      date_dim,
+      store
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days) 
+       and ss_store_sk = s_store_sk
+ group by s_store_sk)
+ ,
+ sr as
+ (select s_store_sk,
+         sum(sr_return_amt) as returns,
+         sum(sr_net_loss) as profit_loss
+ from store_returns,
+      date_dim,
+      store
+ where sr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and sr_store_sk = s_store_sk
+ group by s_store_sk), 
+ cs as
+ (select cs_call_center_sk,
+        sum(cs_ext_sales_price) as sales,
+        sum(cs_net_profit) as profit
+ from catalog_sales,
+      date_dim
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ group by cs_call_center_sk 
+ ), 
+ cr as
+ (select
+        sum(cr_return_amount) as returns,
+        sum(cr_net_loss) as profit_loss
+ from catalog_returns,
+      date_dim
+ where cr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ ), 
+ ws as
+ ( select wp_web_page_sk,
+        sum(ws_ext_sales_price) as sales,
+        sum(ws_net_profit) as profit
+ from web_sales,
+      date_dim,
+      web_page
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ws_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk), 
+ wr as
+ (select wp_web_page_sk,
+        sum(wr_return_amt) as returns,
+        sum(wr_net_loss) as profit_loss
+ from web_returns,
+      date_dim,
+      web_page
+ where wr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and wr_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , ss.s_store_sk as id
+        , sales
+        , coalesce(returns, 0) as returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ss left join sr
+        on  ss.s_store_sk = sr.s_store_sk
+ union all
+ select 'catalog channel' as channel
+        , cs_call_center_sk as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  cs
+       , cr
+ union all
+ select 'web channel' as channel
+        , ws.wp_web_page_sk as id
+        , sales
+        , coalesce(returns, 0) returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ws left join wr
+        on  ws.wp_web_page_sk = wr.wp_web_page_sk
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(channel=[$0], id=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
+      HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store channel'], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+            HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
+              HiveProject(ss_store_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
+                  HiveProject(ss_store_sk=[CAST($1):INTEGER NOT NULL], ss_ext_sales_price=[$2], ss_net_profit=[$3])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_ext_sales_price=[$15], ss_net_profit=[$22])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(sr_store_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
+                  HiveProject(sr_store_sk=[CAST($1):INTEGER NOT NULL], sr_return_amt=[$2], sr_net_loss=[$3])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(sr_returned_date_sk=[$0], sr_store_sk=[$7], sr_return_amt=[$11], sr_net_loss=[$19])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'catalog channel'], id=[$0], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cs_call_center_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[sum($3)])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_ext_sales_price=[$23], cs_net_profit=[$33])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject($f0=[$0], $f1=[$1])
+                HiveAggregate(group=[{}], agg#0=[sum($1)], agg#1=[sum($2)])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cr_returned_date_sk=[$0], cr_return_amount=[$18], cr_net_loss=[$26])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'web channel'], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+            HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
+              HiveProject(ws_web_page_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
+                  HiveProject(ws_web_page_sk=[CAST($1):INTEGER NOT NULL], ws_ext_sales_price=[$2], ws_net_profit=[$3])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_web_page_sk=[$12], ws_ext_sales_price=[$23], ws_net_profit=[$33])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(wr_web_page_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
+                  HiveProject(wr_web_page_sk=[CAST($1):INTEGER NOT NULL], wr_return_amt=[$2], wr_net_loss=[$3])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(wr_returned_date_sk=[$0], wr_web_page_sk=[$11], wr_return_amt=[$15], wr_net_loss=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($11))])
+                          HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out
new file mode 100644
index 0000000..de1b133
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query78.q.out
@@ -0,0 +1,183 @@
+PREHOOK: query: explain cbo
+with ws as
+  (select d_year AS ws_sold_year, ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+   from web_sales
+   left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk
+   join date_dim on ws_sold_date_sk = d_date_sk
+   where wr_order_number is null
+   group by d_year, ws_item_sk, ws_bill_customer_sk
+   ),
+cs as
+  (select d_year AS cs_sold_year, cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+   from catalog_sales
+   left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk
+   join date_dim on cs_sold_date_sk = d_date_sk
+   where cr_order_number is null
+   group by d_year, cs_item_sk, cs_bill_customer_sk
+   ),
+ss as
+  (select d_year AS ss_sold_year, ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+   from store_sales
+   left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk
+   join date_dim on ss_sold_date_sk = d_date_sk
+   where sr_ticket_number is null
+   group by d_year, ss_item_sk, ss_customer_sk
+   )
+ select 
+ss_sold_year, ss_item_sk, ss_customer_sk,
+round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
+ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
+coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
+coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
+coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
+from ss
+left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
+order by 
+  ss_sold_year, ss_item_sk, ss_customer_sk,
+  ss_qty desc, ss_wc desc, ss_sp desc,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ws as
+  (select d_year AS ws_sold_year, ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+   from web_sales
+   left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk
+   join date_dim on ws_sold_date_sk = d_date_sk
+   where wr_order_number is null
+   group by d_year, ws_item_sk, ws_bill_customer_sk
+   ),
+cs as
+  (select d_year AS cs_sold_year, cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+   from catalog_sales
+   left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk
+   join date_dim on cs_sold_date_sk = d_date_sk
+   where cr_order_number is null
+   group by d_year, cs_item_sk, cs_bill_customer_sk
+   ),
+ss as
+  (select d_year AS ss_sold_year, ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+   from store_sales
+   left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk
+   join date_dim on ss_sold_date_sk = d_date_sk
+   where sr_ticket_number is null
+   group by d_year, ss_item_sk, ss_customer_sk
+   )
+ select 
+ss_sold_year, ss_item_sk, ss_customer_sk,
+round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
+ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
+coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
+coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
+coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
+from ss
+left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
+order by 
+  ss_sold_year, ss_item_sk, ss_customer_sk,
+  ss_qty desc, ss_wc desc, ss_sp desc,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject(ss_sold_year=[CAST(2000):INTEGER], ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[$2], store_qty=[$3], store_wholesale_cost=[$4], store_sales_price=[$5], other_chan_qty=[$6], other_chan_wholesale_cost=[$7], other_chan_sales_price=[$8])
+    HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$9], sort3=[$10], sort4=[$11], sort5=[$6], sort6=[$7], sort7=[$8], sort8=[$12], dir0=[ASC], dir1=[ASC], dir2=[DESC-nulls-last], dir3=[DESC-nulls-last], dir4=[DESC-nulls-last], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC])
+      HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[round(/(CAST($2):DOUBLE, CAST(CASE(AND(IS NOT NULL($7), IS NOT NULL($11)), +($7, $11), 1)):DOUBLE), 2)], store_qty=[$2], store_wholesale_cost=[$3], store_sales_price=[$4], other_chan_qty=[+(CASE(IS NOT NULL($7), $7, 0), CASE(IS NOT NULL($11), $11, 0))], other_chan_wholesale_cost=[+(CASE(IS NOT NULL($8), $8, 0), CASE(IS NOT NULL($12), $12, 0))], other_chan_sales_price=[+(CASE(IS NOT NULL($9), $9, 0), CASE(IS NOT NULL($13), $13, 0))], ss_qty=[$2], ss_wc=[$3], ss_sp=[$4], (tok_function round (/ (tok_table_or_col ss_qty) (tok_function coalesce (+ (tok_table_or_col ws_qty) (tok_table_or_col cs_qty)) 1)) 2)=[round(/(CAST($2):DOUBLE, CAST(CASE(AND(IS NOT NULL($7), IS NOT NULL($11)), +($7, $11), 1)):DOUBLE), 2)])
+        HiveFilter(condition=[CASE(IS NOT NULL($11), >($11, 0), false)])
+          HiveJoin(condition=[=($10, $1)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4], ws_item_sk=[$5], ws_bill_customer_sk=[$6], $f20=[$7], $f30=[$8], $f40=[$9])
+              HiveFilter(condition=[CASE(IS NOT NULL($7), >($7, 0), false)])
+                HiveJoin(condition=[AND(=($5, $0), =($6, $1))], joinType=[left], algorithm=[none], cost=[not available])
+                  HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                    HiveAggregate(group=[{2, 3}], agg#0=[sum($4)], agg#1=[sum($5)], agg#2=[sum($6)])
+                      HiveJoin(condition=[=($1, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date_sk=[$0])
+                          HiveFilter(condition=[=($6, 2000)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_quantity=[$4], ss_wholesale_cost=[$5], ss_sales_price=[$6])
+                          HiveFilter(condition=[IS NULL($8)])
+                            HiveJoin(condition=[AND(=($8, $3), =($1, $7))], joinType=[left], algorithm=[none], cost=[not available])
+                              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_ticket_number=[$9], ss_quantity=[$10], ss_wholesale_cost=[$11], ss_sales_price=[$13])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                              HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                                HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                  HiveProject(ws_item_sk=[$0], ws_bill_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                    HiveAggregate(group=[{2, 3}], agg#0=[sum($4)], agg#1=[sum($5)], agg#2=[sum($6)])
+                      HiveJoin(condition=[=($1, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date_sk=[$0])
+                          HiveFilter(condition=[=($6, 2000)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$1], ws_bill_customer_sk=[$2], ws_quantity=[$4], ws_wholesale_cost=[$5], ws_sales_price=[$6])
+                          HiveFilter(condition=[IS NULL($8)])
+                            HiveJoin(condition=[AND(=($8, $3), =($1, $7))], joinType=[left], algorithm=[none], cost=[not available])
+                              HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_customer_sk=[$4], ws_order_number=[$17], ws_quantity=[$18], ws_wholesale_cost=[$19], ws_sales_price=[$21])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                              HiveProject(wr_item_sk=[$2], wr_order_number=[$13])
+                                HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+            HiveProject($f2=[$0], $f3=[$2], $f4=[$3], $f5=[$4])
+              HiveAggregate(group=[{2, 3}], agg#0=[sum($4)], agg#1=[sum($5)], agg#2=[sum($6)])
+                HiveJoin(condition=[=($1, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[=($6, 2000)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2], cs_quantity=[$4], cs_wholesale_cost=[$5], cs_sales_price=[$6])
+                    HiveFilter(condition=[IS NULL($8)])
+                      HiveJoin(condition=[AND(=($8, $3), =($2, $7))], joinType=[left], algorithm=[none], cost=[not available])
+                        HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_wholesale_cost=[$19], cs_sales_price=[$21])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                        HiveProject(cr_item_sk=[$2], cr_order_number=[$16])
+                          HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query79.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query79.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query79.q.out
new file mode 100644
index 0000000..552f96b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query79.q.out
@@ -0,0 +1,81 @@
+PREHOOK: query: explain cbo
+select 
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
+  from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,store.s_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
+    and date_dim.d_dow = 1
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_number_employees between 200 and 295
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
+    where ss_customer_sk = c_customer_sk
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select 
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
+  from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,store.s_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
+    and date_dim.d_dow = 1
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_number_employees between 200 and 295
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
+    where ss_customer_sk = c_customer_sk
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(c_last_name=[$0], c_first_name=[$1], _o__c2=[$2], ss_ticket_number=[$3], amt=[$4], profit=[$5])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$6], sort3=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+    HiveProject(c_last_name=[$2], c_first_name=[$1], _o__c2=[$8], ss_ticket_number=[$3], amt=[$6], profit=[$7], (tok_function substr (tok_table_or_col s_city) 1 30)=[substr($5, 1, 30)])
+      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ss_ticket_number=[$2], ss_customer_sk=[$0], s_city=[$3], amt=[$4], profit=[$5], substr=[substr($3, 1, 30)])
+          HiveAggregate(group=[{1, 3, 5, 10}], agg#0=[sum($6)], agg#1=[sum($7)])
+            HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($4, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_coupon_amt=[$19], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(IN($6, 1998, 1999, 2000), =($7, 1))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_city=[$22])
+                  HiveFilter(condition=[BETWEEN(false, $6, 200, 295)])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(hd_demo_sk=[$0])
+                HiveFilter(condition=[OR(=($3, 8), >($4, 0))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query8.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query8.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query8.q.out
new file mode 100644
index 0000000..fe14ea3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query8.q.out
@@ -0,0 +1,266 @@
+PREHOOK: query: explain cbo
+select  s_store_name
+      ,sum(ss_net_profit)
+ from store_sales
+     ,date_dim
+     ,store,
+     (select ca_zip
+     from (
+     (SELECT substr(ca_zip,1,5) ca_zip
+      FROM customer_address
+      WHERE substr(ca_zip,1,5) IN (
+                          '89436','30868','65085','22977','83927','77557',
+                          '58429','40697','80614','10502','32779',
+                          '91137','61265','98294','17921','18427',
+                          '21203','59362','87291','84093','21505',
+                          '17184','10866','67898','25797','28055',
+                          '18377','80332','74535','21757','29742',
+                          '90885','29898','17819','40811','25990',
+                          '47513','89531','91068','10391','18846',
+                          '99223','82637','41368','83658','86199',
+                          '81625','26696','89338','88425','32200',
+                          '81427','19053','77471','36610','99823',
+                          '43276','41249','48584','83550','82276',
+                          '18842','78890','14090','38123','40936',
+                          '34425','19850','43286','80072','79188',
+                          '54191','11395','50497','84861','90733',
+                          '21068','57666','37119','25004','57835',
+                          '70067','62878','95806','19303','18840',
+                          '19124','29785','16737','16022','49613',
+                          '89977','68310','60069','98360','48649',
+                          '39050','41793','25002','27413','39736',
+                          '47208','16515','94808','57648','15009',
+                          '80015','42961','63982','21744','71853',
+                          '81087','67468','34175','64008','20261',
+                          '11201','51799','48043','45645','61163',
+                          '48375','36447','57042','21218','41100',
+                          '89951','22745','35851','83326','61125',
+                          '78298','80752','49858','52940','96976',
+                          '63792','11376','53582','18717','90226',
+                          '50530','94203','99447','27670','96577',
+                          '57856','56372','16165','23427','54561',
+                          '28806','44439','22926','30123','61451',
+                          '92397','56979','92309','70873','13355',
+                          '21801','46346','37562','56458','28286',
+                          '47306','99555','69399','26234','47546',
+                          '49661','88601','35943','39936','25632',
+                          '24611','44166','56648','30379','59785',
+                          '11110','14329','93815','52226','71381',
+                          '13842','25612','63294','14664','21077',
+                          '82626','18799','60915','81020','56447',
+                          '76619','11433','13414','42548','92713',
+                          '70467','30884','47484','16072','38936',
+                          '13036','88376','45539','35901','19506',
+                          '65690','73957','71850','49231','14276',
+                          '20005','18384','76615','11635','38177',
+                          '55607','41369','95447','58581','58149',
+                          '91946','33790','76232','75692','95464',
+                          '22246','51061','56692','53121','77209',
+                          '15482','10688','14868','45907','73520',
+                          '72666','25734','17959','24677','66446',
+                          '94627','53535','15560','41967','69297',
+                          '11929','59403','33283','52232','57350',
+                          '43933','40921','36635','10827','71286',
+                          '19736','80619','25251','95042','15526',
+                          '36496','55854','49124','81980','35375',
+                          '49157','63512','28944','14946','36503',
+                          '54010','18767','23969','43905','66979',
+                          '33113','21286','58471','59080','13395',
+                          '79144','70373','67031','38360','26705',
+                          '50906','52406','26066','73146','15884',
+                          '31897','30045','61068','45550','92454',
+                          '13376','14354','19770','22928','97790',
+                          '50723','46081','30202','14410','20223',
+                          '88500','67298','13261','14172','81410',
+                          '93578','83583','46047','94167','82564',
+                          '21156','15799','86709','37931','74703',
+                          '83103','23054','70470','72008','49247',
+                          '91911','69998','20961','70070','63197',
+                          '54853','88191','91830','49521','19454',
+                          '81450','89091','62378','25683','61869',
+                          '51744','36580','85778','36871','48121',
+                          '28810','83712','45486','67393','26935',
+                          '42393','20132','55349','86057','21309',
+                          '80218','10094','11357','48819','39734',
+                          '40758','30432','21204','29467','30214',
+                          '61024','55307','74621','11622','68908',
+                          '33032','52868','99194','99900','84936',
+                          '69036','99149','45013','32895','59004',
+                          '32322','14933','32936','33562','72550',
+                          '27385','58049','58200','16808','21360',
+                          '32961','18586','79307','15492'))
+     intersect
+     (select ca_zip
+      from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
+            FROM customer_address, customer
+            WHERE ca_address_sk = c_current_addr_sk and
+                  c_preferred_cust_flag='Y'
+            group by ca_zip
+            having count(*) > 10)A1))A2) V1
+ where ss_store_sk = s_store_sk
+  and ss_sold_date_sk = d_date_sk
+  and d_qoy = 1 and d_year = 2002
+  and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
+ group by s_store_name
+ order by s_store_name
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  s_store_name
+      ,sum(ss_net_profit)
+ from store_sales
+     ,date_dim
+     ,store,
+     (select ca_zip
+     from (
+     (SELECT substr(ca_zip,1,5) ca_zip
+      FROM customer_address
+      WHERE substr(ca_zip,1,5) IN (
+                          '89436','30868','65085','22977','83927','77557',
+                          '58429','40697','80614','10502','32779',
+                          '91137','61265','98294','17921','18427',
+                          '21203','59362','87291','84093','21505',
+                          '17184','10866','67898','25797','28055',
+                          '18377','80332','74535','21757','29742',
+                          '90885','29898','17819','40811','25990',
+                          '47513','89531','91068','10391','18846',
+                          '99223','82637','41368','83658','86199',
+                          '81625','26696','89338','88425','32200',
+                          '81427','19053','77471','36610','99823',
+                          '43276','41249','48584','83550','82276',
+                          '18842','78890','14090','38123','40936',
+                          '34425','19850','43286','80072','79188',
+                          '54191','11395','50497','84861','90733',
+                          '21068','57666','37119','25004','57835',
+                          '70067','62878','95806','19303','18840',
+                          '19124','29785','16737','16022','49613',
+                          '89977','68310','60069','98360','48649',
+                          '39050','41793','25002','27413','39736',
+                          '47208','16515','94808','57648','15009',
+                          '80015','42961','63982','21744','71853',
+                          '81087','67468','34175','64008','20261',
+                          '11201','51799','48043','45645','61163',
+                          '48375','36447','57042','21218','41100',
+                          '89951','22745','35851','83326','61125',
+                          '78298','80752','49858','52940','96976',
+                          '63792','11376','53582','18717','90226',
+                          '50530','94203','99447','27670','96577',
+                          '57856','56372','16165','23427','54561',
+                          '28806','44439','22926','30123','61451',
+                          '92397','56979','92309','70873','13355',
+                          '21801','46346','37562','56458','28286',
+                          '47306','99555','69399','26234','47546',
+                          '49661','88601','35943','39936','25632',
+                          '24611','44166','56648','30379','59785',
+                          '11110','14329','93815','52226','71381',
+                          '13842','25612','63294','14664','21077',
+                          '82626','18799','60915','81020','56447',
+                          '76619','11433','13414','42548','92713',
+                          '70467','30884','47484','16072','38936',
+                          '13036','88376','45539','35901','19506',
+                          '65690','73957','71850','49231','14276',
+                          '20005','18384','76615','11635','38177',
+                          '55607','41369','95447','58581','58149',
+                          '91946','33790','76232','75692','95464',
+                          '22246','51061','56692','53121','77209',
+                          '15482','10688','14868','45907','73520',
+                          '72666','25734','17959','24677','66446',
+                          '94627','53535','15560','41967','69297',
+                          '11929','59403','33283','52232','57350',
+                          '43933','40921','36635','10827','71286',
+                          '19736','80619','25251','95042','15526',
+                          '36496','55854','49124','81980','35375',
+                          '49157','63512','28944','14946','36503',
+                          '54010','18767','23969','43905','66979',
+                          '33113','21286','58471','59080','13395',
+                          '79144','70373','67031','38360','26705',
+                          '50906','52406','26066','73146','15884',
+                          '31897','30045','61068','45550','92454',
+                          '13376','14354','19770','22928','97790',
+                          '50723','46081','30202','14410','20223',
+                          '88500','67298','13261','14172','81410',
+                          '93578','83583','46047','94167','82564',
+                          '21156','15799','86709','37931','74703',
+                          '83103','23054','70470','72008','49247',
+                          '91911','69998','20961','70070','63197',
+                          '54853','88191','91830','49521','19454',
+                          '81450','89091','62378','25683','61869',
+                          '51744','36580','85778','36871','48121',
+                          '28810','83712','45486','67393','26935',
+                          '42393','20132','55349','86057','21309',
+                          '80218','10094','11357','48819','39734',
+                          '40758','30432','21204','29467','30214',
+                          '61024','55307','74621','11622','68908',
+                          '33032','52868','99194','99900','84936',
+                          '69036','99149','45013','32895','59004',
+                          '32322','14933','32936','33562','72550',
+                          '27385','58049','58200','16808','21360',
+                          '32961','18586','79307','15492'))
+     intersect
+     (select ca_zip
+      from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
+            FROM customer_address, customer
+            WHERE ca_address_sk = c_current_addr_sk and
+                  c_preferred_cust_flag='Y'
+            group by ca_zip
+            having count(*) > 10)A1))A2) V1
+ where ss_store_sk = s_store_sk
+  and ss_sold_date_sk = d_date_sk
+  and d_qoy = 1 and d_year = 2002
+  and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
+ group by s_store_name
+ order by s_store_name
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(s_store_name=[$0], $f1=[$1])
+    HiveAggregate(group=[{6}], agg#0=[sum($2)])
+      HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_net_profit=[$22])
+            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(d_date_sk=[$0])
+            HiveFilter(condition=[AND(=($10, 1), =($6, 2002))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(substr=[$0], s_store_sk=[$1], s_store_name=[$2], substr0=[$3])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(substr=[substr($0, 1, 2)])
+              HiveFilter(condition=[=($1, 2)])
+                HiveAggregate(group=[{0}], agg#0=[count($1)])
+                  HiveProject(ca_zip=[$0], $f1=[$1])
+                    HiveUnion(all=[true])
+                      HiveProject(ca_zip=[$0], $f1=[$1])
+                        HiveAggregate(group=[{0}], agg#0=[count()])
+                          HiveProject(ca_zip=[substr($9, 1, 5)])
+                            HiveFilter(condition=[AND(IN(substr($9, 1, 5), _UTF-16LE'89436', _UTF-16LE'30868', _UTF-16LE'65085', _UTF-16LE'22977', _UTF-16LE'83927', _UTF-16LE'77557', _UTF-16LE'58429', _UTF-16LE'40697', _UTF-16LE'80614', _UTF-16LE'10502', _UTF-16LE'32779', _UTF-16LE'91137', _UTF-16LE'61265', _UTF-16LE'98294', _UTF-16LE'17921', _UTF-16LE'18427', _UTF-16LE'21203', _UTF-16LE'59362', _UTF-16LE'87291', _UTF-16LE'84093', _UTF-16LE'21505', _UTF-16LE'17184', _UTF-16LE'10866', _UTF-16LE'67898', _UTF-16LE'25797', _UTF-16LE'28055', _UTF-16LE'18377', _UTF-16LE'80332', _UTF-16LE'74535', _UTF-16LE'21757', _UTF-16LE'29742', _UTF-16LE'90885', _UTF-16LE'29898', _UTF-16LE'17819', _UTF-16LE'40811', _UTF-16LE'25990', _UTF-16LE'47513', _UTF-16LE'89531', _UTF-16LE'91068', _UTF-16LE'10391', _UTF-16LE'18846', _UTF-16LE'99223', _UTF-16LE'82637', _UTF-16LE'41368', _UTF-16LE'83658', _UTF-16LE'86199', _UTF-16LE'81625', _UTF-16LE'26696', _UTF-16LE'89338', _UTF-16LE'88425', _UTF-16LE'32200', _UTF
 -16LE'81427', _UTF-16LE'19053', _UTF-16LE'77471', _UTF-16LE'36610', _UTF-16LE'99823', _UTF-16LE'43276', _UTF-16LE'41249', _UTF-16LE'48584', _UTF-16LE'83550', _UTF-16LE'82276', _UTF-16LE'18842', _UTF-16LE'78890', _UTF-16LE'14090', _UTF-16LE'38123', _UTF-16LE'40936', _UTF-16LE'34425', _UTF-16LE'19850', _UTF-16LE'43286', _UTF-16LE'80072', _UTF-16LE'79188', _UTF-16LE'54191', _UTF-16LE'11395', _UTF-16LE'50497', _UTF-16LE'84861', _UTF-16LE'90733', _UTF-16LE'21068', _UTF-16LE'57666', _UTF-16LE'37119', _UTF-16LE'25004', _UTF-16LE'57835', _UTF-16LE'70067', _UTF-16LE'62878', _UTF-16LE'95806', _UTF-16LE'19303', _UTF-16LE'18840', _UTF-16LE'19124', _UTF-16LE'29785', _UTF-16LE'16737', _UTF-16LE'16022', _UTF-16LE'49613', _UTF-16LE'89977', _UTF-16LE'68310', _UTF-16LE'60069', _UTF-16LE'98360', _UTF-16LE'48649', _UTF-16LE'39050', _UTF-16LE'41793', _UTF-16LE'25002', _UTF-16LE'27413', _UTF-16LE'39736', _UTF-16LE'47208', _UTF-16LE'16515', _UTF-16LE'94808', _UTF-16LE'57648', _UTF-16LE'15009', _UTF-16LE'8
 0015', _UTF-16LE'42961', _UTF-16LE'63982', _UTF-16LE'21744', _UTF-16LE'71853', _UTF-16LE'81087', _UTF-16LE'67468', _UTF-16LE'34175', _UTF-16LE'64008', _UTF-16LE'20261', _UTF-16LE'11201', _UTF-16LE'51799', _UTF-16LE'48043', _UTF-16LE'45645', _UTF-16LE'61163', _UTF-16LE'48375', _UTF-16LE'36447', _UTF-16LE'57042', _UTF-16LE'21218', _UTF-16LE'41100', _UTF-16LE'89951', _UTF-16LE'22745', _UTF-16LE'35851', _UTF-16LE'83326', _UTF-16LE'61125', _UTF-16LE'78298', _UTF-16LE'80752', _UTF-16LE'49858', _UTF-16LE'52940', _UTF-16LE'96976', _UTF-16LE'63792', _UTF-16LE'11376', _UTF-16LE'53582', _UTF-16LE'18717', _UTF-16LE'90226', _UTF-16LE'50530', _UTF-16LE'94203', _UTF-16LE'99447', _UTF-16LE'27670', _UTF-16LE'96577', _UTF-16LE'57856', _UTF-16LE'56372', _UTF-16LE'16165', _UTF-16LE'23427', _UTF-16LE'54561', _UTF-16LE'28806', _UTF-16LE'44439', _UTF-16LE'22926', _UTF-16LE'30123', _UTF-16LE'61451', _UTF-16LE'92397', _UTF-16LE'56979', _UTF-16LE'92309', _UTF-16LE'70873', _UTF-16LE'13355', _UTF-16LE'21801', 
 _UTF-16LE'46346', _UTF-16LE'37562', _UTF-16LE'56458', _UTF-16LE'28286', _UTF-16LE'47306', _UTF-16LE'99555', _UTF-16LE'69399', _UTF-16LE'26234', _UTF-16LE'47546', _UTF-16LE'49661', _UTF-16LE'88601', _UTF-16LE'35943', _UTF-16LE'39936', _UTF-16LE'25632', _UTF-16LE'24611', _UTF-16LE'44166', _UTF-16LE'56648', _UTF-16LE'30379', _UTF-16LE'59785', _UTF-16LE'11110', _UTF-16LE'14329', _UTF-16LE'93815', _UTF-16LE'52226', _UTF-16LE'71381', _UTF-16LE'13842', _UTF-16LE'25612', _UTF-16LE'63294', _UTF-16LE'14664', _UTF-16LE'21077', _UTF-16LE'82626', _UTF-16LE'18799', _UTF-16LE'60915', _UTF-16LE'81020', _UTF-16LE'56447', _UTF-16LE'76619', _UTF-16LE'11433', _UTF-16LE'13414', _UTF-16LE'42548', _UTF-16LE'92713', _UTF-16LE'70467', _UTF-16LE'30884', _UTF-16LE'47484', _UTF-16LE'16072', _UTF-16LE'38936', _UTF-16LE'13036', _UTF-16LE'88376', _UTF-16LE'45539', _UTF-16LE'35901', _UTF-16LE'19506', _UTF-16LE'65690', _UTF-16LE'73957', _UTF-16LE'71850', _UTF-16LE'49231', _UTF-16LE'14276', _UTF-16LE'20005', _UTF-16
 LE'18384', _UTF-16LE'76615', _UTF-16LE'11635', _UTF-16LE'38177', _UTF-16LE'55607', _UTF-16LE'41369', _UTF-16LE'95447', _UTF-16LE'58581', _UTF-16LE'58149', _UTF-16LE'91946', _UTF-16LE'33790', _UTF-16LE'76232', _UTF-16LE'75692', _UTF-16LE'95464', _UTF-16LE'22246', _UTF-16LE'51061', _UTF-16LE'56692', _UTF-16LE'53121', _UTF-16LE'77209', _UTF-16LE'15482', _UTF-16LE'10688', _UTF-16LE'14868', _UTF-16LE'45907', _UTF-16LE'73520', _UTF-16LE'72666', _UTF-16LE'25734', _UTF-16LE'17959', _UTF-16LE'24677', _UTF-16LE'66446', _UTF-16LE'94627', _UTF-16LE'53535', _UTF-16LE'15560', _UTF-16LE'41967', _UTF-16LE'69297', _UTF-16LE'11929', _UTF-16LE'59403', _UTF-16LE'33283', _UTF-16LE'52232', _UTF-16LE'57350', _UTF-16LE'43933', _UTF-16LE'40921', _UTF-16LE'36635', _UTF-16LE'10827', _UTF-16LE'71286', _UTF-16LE'19736', _UTF-16LE'80619', _UTF-16LE'25251', _UTF-16LE'95042', _UTF-16LE'15526', _UTF-16LE'36496', _UTF-16LE'55854', _UTF-16LE'49124', _UTF-16LE'81980', _UTF-16LE'35375', _UTF-16LE'49157', _UTF-16LE'6351
 2', _UTF-16LE'28944', _UTF-16LE'14946', _UTF-16LE'36503', _UTF-16LE'54010', _UTF-16LE'18767', _UTF-16LE'23969', _UTF-16LE'43905', _UTF-16LE'66979', _UTF-16LE'33113', _UTF-16LE'21286', _UTF-16LE'58471', _UTF-16LE'59080', _UTF-16LE'13395', _UTF-16LE'79144', _UTF-16LE'70373', _UTF-16LE'67031', _UTF-16LE'38360', _UTF-16LE'26705', _UTF-16LE'50906', _UTF-16LE'52406', _UTF-16LE'26066', _UTF-16LE'73146', _UTF-16LE'15884', _UTF-16LE'31897', _UTF-16LE'30045', _UTF-16LE'61068', _UTF-16LE'45550', _UTF-16LE'92454', _UTF-16LE'13376', _UTF-16LE'14354', _UTF-16LE'19770', _UTF-16LE'22928', _UTF-16LE'97790', _UTF-16LE'50723', _UTF-16LE'46081', _UTF-16LE'30202', _UTF-16LE'14410', _UTF-16LE'20223', _UTF-16LE'88500', _UTF-16LE'67298', _UTF-16LE'13261', _UTF-16LE'14172', _UTF-16LE'81410', _UTF-16LE'93578', _UTF-16LE'83583', _UTF-16LE'46047', _UTF-16LE'94167', _UTF-16LE'82564', _UTF-16LE'21156', _UTF-16LE'15799', _UTF-16LE'86709', _UTF-16LE'37931', _UTF-16LE'74703', _UTF-16LE'83103', _UTF-16LE'23054', _UT
 F-16LE'70470', _UTF-16LE'72008', _UTF-16LE'49247', _UTF-16LE'91911', _UTF-16LE'69998', _UTF-16LE'20961', _UTF-16LE'70070', _UTF-16LE'63197', _UTF-16LE'54853', _UTF-16LE'88191', _UTF-16LE'91830', _UTF-16LE'49521', _UTF-16LE'19454', _UTF-16LE'81450', _UTF-16LE'89091', _UTF-16LE'62378', _UTF-16LE'25683', _UTF-16LE'61869', _UTF-16LE'51744', _UTF-16LE'36580', _UTF-16LE'85778', _UTF-16LE'36871', _UTF-16LE'48121', _UTF-16LE'28810', _UTF-16LE'83712', _UTF-16LE'45486', _UTF-16LE'67393', _UTF-16LE'26935', _UTF-16LE'42393', _UTF-16LE'20132', _UTF-16LE'55349', _UTF-16LE'86057', _UTF-16LE'21309', _UTF-16LE'80218', _UTF-16LE'10094', _UTF-16LE'11357', _UTF-16LE'48819', _UTF-16LE'39734', _UTF-16LE'40758', _UTF-16LE'30432', _UTF-16LE'21204', _UTF-16LE'29467', _UTF-16LE'30214', _UTF-16LE'61024', _UTF-16LE'55307', _UTF-16LE'74621', _UTF-16LE'11622', _UTF-16LE'68908', _UTF-16LE'33032', _UTF-16LE'52868', _UTF-16LE'99194', _UTF-16LE'99900', _UTF-16LE'84936', _UTF-16LE'69036', _UTF-16LE'99149', _UTF-16LE'
 45013', _UTF-16LE'32895', _UTF-16LE'59004', _UTF-16LE'32322', _UTF-16LE'14933', _UTF-16LE'32936', _UTF-16LE'33562', _UTF-16LE'72550', _UTF-16LE'27385', _UTF-16LE'58049', _UTF-16LE'58200', _UTF-16LE'16808', _UTF-16LE'21360', _UTF-16LE'32961', _UTF-16LE'18586', _UTF-16LE'79307', _UTF-16LE'15492'), IS NOT NULL(substr(substr($9, 1, 5), 1, 2)))])
+                              HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                      HiveProject(ca_zip=[$0], $f1=[$1])
+                        HiveAggregate(group=[{0}], agg#0=[count()])
+                          HiveProject(ca_zip=[substr($0, 1, 5)])
+                            HiveFilter(condition=[>($1, 10)])
+                              HiveAggregate(group=[{1}], agg#0=[count()])
+                                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ca_address_sk=[$0], ca_zip=[$9])
+                                    HiveFilter(condition=[IS NOT NULL(substr(substr($9, 1, 5), 1, 2))])
+                                      HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                                  HiveProject(c_current_addr_sk=[$4])
+                                    HiveFilter(condition=[AND(=($10, _UTF-16LE'Y'), IS NOT NULL($4))])
+                                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+            HiveProject(s_store_sk=[$0], s_store_name=[$5], substr=[substr($25, 1, 2)])
+              HiveFilter(condition=[IS NOT NULL(substr($25, 1, 2))])
+                HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out
new file mode 100644
index 0000000..a4fac0c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query80.q.out
@@ -0,0 +1,295 @@
+PREHOOK: query: explain cbo
+with ssr as
+ (select  s_store_id as store_id,
+          sum(ss_ext_sales_price) as sales,
+          sum(coalesce(sr_return_amt, 0)) as returns,
+          sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit
+  from store_sales left outer join store_returns on
+         (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number),
+     date_dim,
+     store,
+     item,
+     promotion
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ss_store_sk = s_store_sk
+       and ss_item_sk = i_item_sk
+       and i_current_price > 50
+       and ss_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+ group by s_store_id)
+ ,
+ csr as
+ (select  cp_catalog_page_id as catalog_page_id,
+          sum(cs_ext_sales_price) as sales,
+          sum(coalesce(cr_return_amount, 0)) as returns,
+          sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit
+  from catalog_sales left outer join catalog_returns on
+         (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number),
+     date_dim,
+     catalog_page,
+     item,
+     promotion
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and cs_catalog_page_sk = cp_catalog_page_sk
+       and cs_item_sk = i_item_sk
+       and i_current_price > 50
+       and cs_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select  web_site_id,
+          sum(ws_ext_sales_price) as sales,
+          sum(coalesce(wr_return_amt, 0)) as returns,
+          sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit
+  from web_sales left outer join web_returns on
+         (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number),
+     date_dim,
+     web_site,
+     item,
+     promotion
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and ws_web_site_sk = web_site_sk
+       and ws_item_sk = i_item_sk
+       and i_current_price > 50
+       and ws_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || store_id as id
+        , sales
+        , returns
+        , profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || catalog_page_id as id
+        , sales
+        , returns
+        , profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_page
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssr as
+ (select  s_store_id as store_id,
+          sum(ss_ext_sales_price) as sales,
+          sum(coalesce(sr_return_amt, 0)) as returns,
+          sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit
+  from store_sales left outer join store_returns on
+         (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number),
+     date_dim,
+     store,
+     item,
+     promotion
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ss_store_sk = s_store_sk
+       and ss_item_sk = i_item_sk
+       and i_current_price > 50
+       and ss_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+ group by s_store_id)
+ ,
+ csr as
+ (select  cp_catalog_page_id as catalog_page_id,
+          sum(cs_ext_sales_price) as sales,
+          sum(coalesce(cr_return_amount, 0)) as returns,
+          sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit
+  from catalog_sales left outer join catalog_returns on
+         (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number),
+     date_dim,
+     catalog_page,
+     item,
+     promotion
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and cs_catalog_page_sk = cp_catalog_page_sk
+       and cs_item_sk = i_item_sk
+       and i_current_price > 50
+       and cs_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select  web_site_id,
+          sum(ws_ext_sales_price) as sales,
+          sum(coalesce(wr_return_amt, 0)) as returns,
+          sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit
+  from web_sales left outer join web_returns on
+         (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number),
+     date_dim,
+     web_site,
+     item,
+     promotion
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and ws_web_site_sk = web_site_sk
+       and ws_item_sk = i_item_sk
+       and i_current_price > 50
+       and ws_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || store_id as id
+        , sales
+        , returns
+        , profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || catalog_page_id as id
+        , sales
+        , returns
+        , profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_page
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(channel=[$0], id=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
+      HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store channel'], id=[||(_UTF-16LE'store', $0)], sales=[$1], returns=[$2], profit=[$3])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
+              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0)], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0))])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(s_store_sk=[$0], s_store_id=[$1])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+                  HiveJoin(condition=[=($4, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0])
+                        HiveFilter(condition=[>($5, 50)])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[AND(=($1, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ticket_number=[$9], ss_ext_sales_price=[$15], ss_net_profit=[$22])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($8))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_amt=[$11], sr_net_loss=[$19])
+                            HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                        HiveProject(d_date_sk=[$0])
+                          HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(p_promo_sk=[$0])
+                      HiveFilter(condition=[=($11, _UTF-16LE'N')])
+                        HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+          HiveProject(channel=[_UTF-16LE'catalog channel'], id=[||(_UTF-16LE'catalog_page', $0)], sales=[$1], returns=[$2], profit=[$3])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
+              HiveProject($f0=[$1], $f1=[$8], $f2=[CASE(IS NOT NULL($12), $12, 0)], $f3=[-($9, CASE(IS NOT NULL($13), $13, 0))])
+                HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cp_catalog_page_sk=[$0], cp_catalog_page_id=[$1])
+                    HiveTableScan(table=[[default, catalog_page]], table:alias=[catalog_page])
+                  HiveJoin(condition=[=($4, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0])
+                        HiveFilter(condition=[>($5, 50)])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[AND(=($2, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_catalog_page_sk=[$12], cs_item_sk=[$15], cs_promo_sk=[$16], cs_order_number=[$17], cs_ext_sales_price=[$23], cs_net_profit=[$33])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($16))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_amount=[$18], cr_net_loss=[$26])
+                            HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                        HiveProject(d_date_sk=[$0])
+                          HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(p_promo_sk=[$0])
+                      HiveFilter(condition=[=($11, _UTF-16LE'N')])
+                        HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+          HiveProject(channel=[_UTF-16LE'web channel'], id=[||(_UTF-16LE'web_site', $0)], sales=[$1], returns=[$2], profit=[$3])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
+              HiveProject($f0=[$15], $f1=[$7], $f2=[CASE(IS NOT NULL($11), $11, 0)], $f3=[-($8, CASE(IS NOT NULL($12), $12, 0))])
+                HiveJoin(condition=[=($4, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(p_promo_sk=[$0])
+                      HiveFilter(condition=[=($11, _UTF-16LE'N')])
+                        HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+                    HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0])
+                        HiveFilter(condition=[>($5, 50)])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[AND(=($1, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_web_site_sk=[$13], ws_promo_sk=[$16], ws_order_number=[$17], ws_ext_sales_price=[$23], ws_net_profit=[$33])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($13), IS NOT NULL($16))])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_amt=[$15], wr_net_loss=[$23])
+                            HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                        HiveProject(d_date_sk=[$0])
+                          HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(web_site_sk=[$0], web_site_id=[$1])
+                    HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query81.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query81.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query81.q.out
new file mode 100644
index 0000000..9806664
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query81.q.out
@@ -0,0 +1,113 @@
+PREHOOK: query: explain cbo
+with customer_total_return as
+ (select cr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(cr_return_amt_inc_tax) as ctr_total_return
+ from catalog_returns
+     ,date_dim
+     ,customer_address
+ where cr_returned_date_sk = d_date_sk 
+   and d_year =1998
+   and cr_returning_addr_sk = ca_address_sk 
+ group by cr_returning_customer_sk
+         ,ca_state )
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with customer_total_return as
+ (select cr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(cr_return_amt_inc_tax) as ctr_total_return
+ from catalog_returns
+     ,date_dim
+     ,customer_address
+ where cr_returned_date_sk = d_date_sk 
+   and d_year =1998
+   and cr_returning_addr_sk = ca_address_sk 
+ group by cr_returning_customer_sk
+         ,ca_state )
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(c_customer_id=[$0], c_salutation=[$1], c_first_name=[$2], c_last_name=[$3], ca_street_number=[$4], ca_street_name=[$5], ca_street_type=[$6], ca_suite_number=[$7], ca_city=[$8], ca_county=[$9], ca_state=[CAST(_UTF-16LE'IL'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], ca_zip=[$10], ca_country=[$11], ca_gmt_offset=[$12], ca_location_type=[$13], ctr_total_return=[$14])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], sort10=[$10], sort11=[$11], sort12=[$12], sort13=[$13], sort14=[$14], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], dir10=[ASC], dir11=[ASC], dir12=[ASC], dir13=[ASC], dir14=[ASC], fetch=[100])
+    HiveProject(c_customer_id=[$1], c_salutation=[$3], c_first_name=[$4], c_last_name=[$5], ca_street_number=[$7], ca_street_name=[$8], ca_street_type=[$9], ca_suite_number=[$10], ca_city=[$11], ca_county=[$12], ca_zip=[$13], ca_country=[$14], ca_gmt_offset=[$15], ca_location_type=[$16], ctr_total_return=[$19])
+      HiveJoin(condition=[=($17, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($6, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_current_addr_sk=[$4], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9])
+            HiveFilter(condition=[IS NOT NULL($4)])
+              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+          HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_street_type=[$4], ca_suite_number=[$5], ca_city=[$6], ca_county=[$7], ca_zip=[$9], ca_country=[$10], ca_gmt_offset=[$11], ca_location_type=[$12])
+            HiveFilter(condition=[=($8, _UTF-16LE'IL')])
+              HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+        HiveProject(cr_returning_customer_sk=[$0], ca_state=[$1], $f2=[$2], _o__c0=[$3], ctr_state=[$4])
+          HiveJoin(condition=[AND(=($1, $4), >($2, $3))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cr_returning_customer_sk=[$1], ca_state=[$0], $f2=[$2])
+              HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+                HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                    HiveFilter(condition=[IS NOT NULL($8)])
+                      HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$7], cr_returning_addr_sk=[$10], cr_return_amt_inc_tax=[$20])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[=($6, 1998)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(_o__c0=[*(/($1, $2), 1.2)], ctr_state=[$0])
+              HiveAggregate(group=[{0}], agg#0=[sum($2)], agg#1=[count($2)])
+                HiveProject(ca_state=[$0], cr_returning_customer_sk=[$1], $f2=[$2])
+                  HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+                    HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                        HiveFilter(condition=[IS NOT NULL($8)])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$7], cr_returning_addr_sk=[$10], cr_return_amt_inc_tax=[$20])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10))])
+                            HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                        HiveProject(d_date_sk=[$0])
+                          HiveFilter(condition=[=($6, 1998)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query82.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query82.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query82.q.out
new file mode 100644
index 0000000..54c4a99
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query82.q.out
@@ -0,0 +1,62 @@
+PREHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, store_sales
+ where i_current_price between 30 and 30+30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
+ and i_manufact_id in (437,129,727,663)
+ and inv_quantity_on_hand between 100 and 500
+ and ss_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, store_sales
+ where i_current_price between 30 and 30+30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
+ and i_manufact_id in (437,129,727,663)
+ and inv_quantity_on_hand between 100 and 500
+ and ss_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], i_current_price=[$2])
+    HiveAggregate(group=[{2, 3, 4}])
+      HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_item_sk=[$2])
+            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5])
+            HiveFilter(condition=[AND(IN($13, 437, 129, 727, 663), BETWEEN(false, $5, 30, 60))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], d_date_sk=[$2])
+          HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(inv_date_sk=[$0], inv_item_sk=[$1])
+              HiveFilter(condition=[BETWEEN(false, $3, 100, 500)])
+                HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 2002-05-30 00:00:00, 2002-07-29 00:00:00)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[66/75] [abbrv] hive git commit: HIVE-20788: Extended SJ reduction may backtrack columns incorrectly when creating filters (Jesus Camacho Rodriguez, reviewed by Deepak Jaiswal)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out
index c82c415..6d7c620 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query33.q.out
@@ -194,57 +194,57 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_372]
-        Limit [LIM_371] (rows=59 width=115)
+      File Output Operator [FS_368]
+        Limit [LIM_367] (rows=59 width=115)
           Number of rows:100
-          Select Operator [SEL_370] (rows=59 width=115)
+          Select Operator [SEL_366] (rows=59 width=115)
             Output:["_col0","_col1"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_369]
-              Group By Operator [GBY_368] (rows=59 width=115)
+            SHUFFLE [RS_365]
+              Group By Operator [GBY_364] (rows=59 width=115)
                 Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
               <-Union 5 [SIMPLE_EDGE]
                 <-Reducer 11 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_392]
+                  Reduce Output Operator [RS_388]
                     PartitionCols:_col0
-                    Group By Operator [GBY_391] (rows=59 width=115)
+                    Group By Operator [GBY_387] (rows=59 width=115)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Group By Operator [GBY_390] (rows=19 width=115)
+                      Group By Operator [GBY_386] (rows=19 width=115)
                         Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                       <-Reducer 10 [SIMPLE_EDGE]
                         SHUFFLE [RS_109]
                           PartitionCols:_col0
                           Group By Operator [GBY_108] (rows=19 width=115)
                             Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                            Merge Join Operator [MERGEJOIN_308] (rows=11364 width=3)
+                            Merge Join Operator [MERGEJOIN_304] (rows=11364 width=3)
                               Conds:RS_104._col0=RS_105._col2(Inner),Output:["_col1","_col7"]
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_104]
                                 PartitionCols:_col0
-                                Merge Join Operator [MERGEJOIN_297] (rows=461514 width=7)
-                                  Conds:RS_323._col1=RS_329._col0(Inner),Output:["_col0","_col1"]
+                                Merge Join Operator [MERGEJOIN_293] (rows=461514 width=7)
+                                  Conds:RS_319._col1=RS_325._col0(Inner),Output:["_col0","_col1"]
                                 <-Map 1 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_323]
+                                  SHUFFLE [RS_319]
                                     PartitionCols:_col1
-                                    Select Operator [SEL_322] (rows=460848 width=7)
+                                    Select Operator [SEL_318] (rows=460848 width=7)
                                       Output:["_col0","_col1"]
-                                      Filter Operator [FIL_321] (rows=460848 width=7)
+                                      Filter Operator [FIL_317] (rows=460848 width=7)
                                         predicate:i_manufact_id is not null
                                         TableScan [TS_0] (rows=462000 width=7)
                                           default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_manufact_id"]
                                 <-Reducer 13 [ONE_TO_ONE_EDGE] vectorized
-                                  FORWARD [RS_329]
+                                  FORWARD [RS_325]
                                     PartitionCols:_col0
-                                    Group By Operator [GBY_328] (rows=692 width=3)
+                                    Group By Operator [GBY_324] (rows=692 width=3)
                                       Output:["_col0"],keys:KEY._col0
                                     <-Map 12 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_327]
+                                      SHUFFLE [RS_323]
                                         PartitionCols:_col0
-                                        Group By Operator [GBY_326] (rows=692 width=3)
+                                        Group By Operator [GBY_322] (rows=692 width=3)
                                           Output:["_col0"],keys:i_manufact_id
-                                          Select Operator [SEL_325] (rows=46085 width=93)
+                                          Select Operator [SEL_321] (rows=46085 width=93)
                                             Output:["i_manufact_id"]
-                                            Filter Operator [FIL_324] (rows=46085 width=93)
+                                            Filter Operator [FIL_320] (rows=46085 width=93)
                                               predicate:((i_category = 'Books') and i_manufact_id is not null)
                                               TableScan [TS_3] (rows=462000 width=93)
                                                 default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_category","i_manufact_id"]
@@ -253,198 +253,198 @@ Stage-0
                                 PartitionCols:_col2
                                 Select Operator [SEL_100] (rows=788222 width=110)
                                   Output:["_col2","_col4"]
-                                  Merge Join Operator [MERGEJOIN_305] (rows=788222 width=110)
-                                    Conds:RS_97._col2=RS_352._col0(Inner),Output:["_col1","_col3"]
+                                  Merge Join Operator [MERGEJOIN_301] (rows=788222 width=110)
+                                    Conds:RS_97._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
                                   <-Map 25 [SIMPLE_EDGE] vectorized
-                                    PARTITION_ONLY_SHUFFLE [RS_352]
+                                    PARTITION_ONLY_SHUFFLE [RS_348]
                                       PartitionCols:_col0
-                                      Select Operator [SEL_347] (rows=8000000 width=4)
+                                      Select Operator [SEL_343] (rows=8000000 width=4)
                                         Output:["_col0"]
-                                        Filter Operator [FIL_346] (rows=8000000 width=112)
+                                        Filter Operator [FIL_342] (rows=8000000 width=112)
                                           predicate:(ca_gmt_offset = -6)
                                           TableScan [TS_16] (rows=40000000 width=112)
                                             default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_gmt_offset"]
                                   <-Reducer 22 [SIMPLE_EDGE]
                                     SHUFFLE [RS_97]
                                       PartitionCols:_col2
-                                      Merge Join Operator [MERGEJOIN_304] (rows=3941109 width=118)
-                                        Conds:RS_389._col0=RS_336._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      Merge Join Operator [MERGEJOIN_300] (rows=3941109 width=118)
+                                        Conds:RS_385._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 17 [SIMPLE_EDGE] vectorized
-                                        PARTITION_ONLY_SHUFFLE [RS_336]
+                                        PARTITION_ONLY_SHUFFLE [RS_332]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_331] (rows=50 width=4)
+                                          Select Operator [SEL_327] (rows=50 width=4)
                                             Output:["_col0"]
-                                            Filter Operator [FIL_330] (rows=50 width=12)
+                                            Filter Operator [FIL_326] (rows=50 width=12)
                                               predicate:((d_moy = 3) and (d_year = 1999))
                                               TableScan [TS_13] (rows=73049 width=12)
                                                 default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
                                       <-Map 30 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_389]
+                                        SHUFFLE [RS_385]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_388] (rows=143931246 width=123)
+                                          Select Operator [SEL_384] (rows=143931246 width=123)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_387] (rows=143931246 width=123)
+                                            Filter Operator [FIL_383] (rows=143931246 width=123)
                                               predicate:((ws_bill_addr_sk BETWEEN DynamicValue(RS_98_customer_address_ca_address_sk_min) AND DynamicValue(RS_98_customer_address_ca_address_sk_max) and in_bloom_filter(ws_bill_addr_sk, DynamicValue(RS_98_customer_address_ca_address_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_95_date_dim_d_date_sk_min) AND DynamicValue(RS_95_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_95_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
                                               TableScan [TS_85] (rows=144002668 width=123)
                                                 default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_addr_sk","ws_ext_sales_price"]
                                               <-Reducer 24 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_384]
-                                                  Group By Operator [GBY_383] (rows=1 width=12)
+                                                BROADCAST [RS_380]
+                                                  Group By Operator [GBY_379] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_343]
-                                                      Group By Operator [GBY_340] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_339]
+                                                      Group By Operator [GBY_336] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_337] (rows=50 width=4)
+                                                        Select Operator [SEL_333] (rows=50 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_331]
+                                                           Please refer to the previous Select Operator [SEL_327]
                                               <-Reducer 28 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_386]
-                                                  Group By Operator [GBY_385] (rows=1 width=12)
+                                                BROADCAST [RS_382]
+                                                  Group By Operator [GBY_381] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                   <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_359]
-                                                      Group By Operator [GBY_356] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_355]
+                                                      Group By Operator [GBY_352] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                        Select Operator [SEL_353] (rows=8000000 width=4)
+                                                        Select Operator [SEL_349] (rows=8000000 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_347]
+                                                           Please refer to the previous Select Operator [SEL_343]
                 <-Reducer 4 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_367]
+                  Reduce Output Operator [RS_363]
                     PartitionCols:_col0
-                    Group By Operator [GBY_366] (rows=59 width=115)
+                    Group By Operator [GBY_362] (rows=59 width=115)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Group By Operator [GBY_365] (rows=64 width=115)
+                      Group By Operator [GBY_361] (rows=64 width=115)
                         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=64 width=115)
                             Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                            Merge Join Operator [MERGEJOIN_306] (rows=41476 width=3)
+                            Merge Join Operator [MERGEJOIN_302] (rows=41476 width=3)
                               Conds:RS_29._col0=RS_30._col2(Inner),Output:["_col1","_col7"]
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_29]
                                 PartitionCols:_col0
-                                 Please refer to the previous Merge Join Operator [MERGEJOIN_297]
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_293]
                             <-Reducer 16 [SIMPLE_EDGE]
                               SHUFFLE [RS_30]
                                 PartitionCols:_col2
                                 Select Operator [SEL_25] (rows=2876890 width=4)
                                   Output:["_col2","_col4"]
-                                  Merge Join Operator [MERGEJOIN_299] (rows=2876890 width=4)
-                                    Conds:RS_22._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
+                                  Merge Join Operator [MERGEJOIN_295] (rows=2876890 width=4)
+                                    Conds:RS_22._col2=RS_344._col0(Inner),Output:["_col1","_col3"]
                                   <-Map 25 [SIMPLE_EDGE] vectorized
-                                    PARTITION_ONLY_SHUFFLE [RS_348]
+                                    PARTITION_ONLY_SHUFFLE [RS_344]
                                       PartitionCols:_col0
-                                       Please refer to the previous Select Operator [SEL_347]
+                                       Please refer to the previous Select Operator [SEL_343]
                                   <-Reducer 15 [SIMPLE_EDGE]
                                     SHUFFLE [RS_22]
                                       PartitionCols:_col2
-                                      Merge Join Operator [MERGEJOIN_298] (rows=14384447 width=4)
-                                        Conds:RS_364._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      Merge Join Operator [MERGEJOIN_294] (rows=14384447 width=4)
+                                        Conds:RS_360._col0=RS_328._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 17 [SIMPLE_EDGE] vectorized
-                                        PARTITION_ONLY_SHUFFLE [RS_332]
+                                        PARTITION_ONLY_SHUFFLE [RS_328]
                                           PartitionCols:_col0
-                                           Please refer to the previous Select Operator [SEL_331]
+                                           Please refer to the previous Select Operator [SEL_327]
                                       <-Map 14 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_364]
+                                        SHUFFLE [RS_360]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_363] (rows=525327191 width=118)
+                                          Select Operator [SEL_359] (rows=525327191 width=118)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_362] (rows=525327191 width=118)
+                                            Filter Operator [FIL_358] (rows=525327191 width=118)
                                               predicate:((ss_addr_sk BETWEEN DynamicValue(RS_23_customer_address_ca_address_sk_min) AND DynamicValue(RS_23_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_23_customer_address_ca_address_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_20_date_dim_d_date_sk_min) AND DynamicValue(RS_20_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_20_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
                                               TableScan [TS_10] (rows=575995635 width=118)
                                                 default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
                                               <-Reducer 18 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_345]
-                                                  Group By Operator [GBY_344] (rows=1 width=12)
+                                                BROADCAST [RS_341]
+                                                  Group By Operator [GBY_340] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_341]
-                                                      Group By Operator [GBY_338] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_337]
+                                                      Group By Operator [GBY_334] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_333] (rows=50 width=4)
+                                                        Select Operator [SEL_329] (rows=50 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_331]
+                                                           Please refer to the previous Select Operator [SEL_327]
                                               <-Reducer 26 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_361]
-                                                  Group By Operator [GBY_360] (rows=1 width=12)
+                                                BROADCAST [RS_357]
+                                                  Group By Operator [GBY_356] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                   <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_357]
-                                                      Group By Operator [GBY_354] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_353]
+                                                      Group By Operator [GBY_350] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                        Select Operator [SEL_349] (rows=8000000 width=4)
+                                                        Select Operator [SEL_345] (rows=8000000 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_347]
+                                                           Please refer to the previous Select Operator [SEL_343]
                 <-Reducer 9 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_382]
+                  Reduce Output Operator [RS_378]
                     PartitionCols:_col0
-                    Group By Operator [GBY_381] (rows=59 width=115)
+                    Group By Operator [GBY_377] (rows=59 width=115)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Group By Operator [GBY_380] (rows=35 width=115)
+                      Group By Operator [GBY_376] (rows=35 width=115)
                         Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                       <-Reducer 8 [SIMPLE_EDGE]
                         SHUFFLE [RS_71]
                           PartitionCols:_col0
                           Group By Operator [GBY_70] (rows=35 width=115)
                             Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                            Merge Join Operator [MERGEJOIN_307] (rows=22352 width=3)
+                            Merge Join Operator [MERGEJOIN_303] (rows=22352 width=3)
                               Conds:RS_66._col0=RS_67._col3(Inner),Output:["_col1","_col7"]
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_66]
                                 PartitionCols:_col0
-                                 Please refer to the previous Merge Join Operator [MERGEJOIN_297]
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_293]
                             <-Reducer 20 [SIMPLE_EDGE]
                               SHUFFLE [RS_67]
                                 PartitionCols:_col3
                                 Select Operator [SEL_62] (rows=1550375 width=13)
                                   Output:["_col3","_col4"]
-                                  Merge Join Operator [MERGEJOIN_302] (rows=1550375 width=13)
-                                    Conds:RS_59._col1=RS_350._col0(Inner),Output:["_col2","_col3"]
+                                  Merge Join Operator [MERGEJOIN_298] (rows=1550375 width=13)
+                                    Conds:RS_59._col1=RS_346._col0(Inner),Output:["_col2","_col3"]
                                   <-Map 25 [SIMPLE_EDGE] vectorized
-                                    PARTITION_ONLY_SHUFFLE [RS_350]
+                                    PARTITION_ONLY_SHUFFLE [RS_346]
                                       PartitionCols:_col0
-                                       Please refer to the previous Select Operator [SEL_347]
+                                       Please refer to the previous Select Operator [SEL_343]
                                   <-Reducer 19 [SIMPLE_EDGE]
                                     SHUFFLE [RS_59]
                                       PartitionCols:_col1
-                                      Merge Join Operator [MERGEJOIN_301] (rows=7751872 width=98)
-                                        Conds:RS_379._col0=RS_334._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      Merge Join Operator [MERGEJOIN_297] (rows=7751872 width=98)
+                                        Conds:RS_375._col0=RS_330._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 17 [SIMPLE_EDGE] vectorized
-                                        PARTITION_ONLY_SHUFFLE [RS_334]
+                                        PARTITION_ONLY_SHUFFLE [RS_330]
                                           PartitionCols:_col0
-                                           Please refer to the previous Select Operator [SEL_331]
+                                           Please refer to the previous Select Operator [SEL_327]
                                       <-Map 29 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_379]
+                                        SHUFFLE [RS_375]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_378] (rows=285117733 width=123)
+                                          Select Operator [SEL_374] (rows=285117733 width=123)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_377] (rows=285117733 width=123)
+                                            Filter Operator [FIL_373] (rows=285117733 width=123)
                                               predicate:((cs_bill_addr_sk BETWEEN DynamicValue(RS_60_customer_address_ca_address_sk_min) AND DynamicValue(RS_60_customer_address_ca_address_sk_max) and in_bloom_filter(cs_bill_addr_sk, DynamicValue(RS_60_customer_address_ca_address_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_57_date_dim_d_date_sk_min) AND DynamicValue(RS_57_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_57_date_dim_d_date_sk_bloom_filter))) and cs_bill_addr_sk is not null and cs_sold_date_sk is not null)
                                               TableScan [TS_47] (rows=287989836 width=123)
                                                 default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_addr_sk","cs_item_sk","cs_ext_sales_price"]
                                               <-Reducer 21 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_374]
-                                                  Group By Operator [GBY_373] (rows=1 width=12)
+                                                BROADCAST [RS_370]
+                                                  Group By Operator [GBY_369] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_342]
-                                                      Group By Operator [GBY_339] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_338]
+                                                      Group By Operator [GBY_335] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_335] (rows=50 width=4)
+                                                        Select Operator [SEL_331] (rows=50 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_331]
+                                                           Please refer to the previous Select Operator [SEL_327]
                                               <-Reducer 27 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_376]
-                                                  Group By Operator [GBY_375] (rows=1 width=12)
+                                                BROADCAST [RS_372]
+                                                  Group By Operator [GBY_371] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                   <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_358]
-                                                      Group By Operator [GBY_355] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_354]
+                                                      Group By Operator [GBY_351] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                        Select Operator [SEL_351] (rows=8000000 width=4)
+                                                        Select Operator [SEL_347] (rows=8000000 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_347]
+                                                           Please refer to the previous Select Operator [SEL_343]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out
index b57ded3..cac7668 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out
@@ -183,55 +183,55 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_370]
-        Limit [LIM_369] (rows=100 width=212)
+      File Output Operator [FS_366]
+        Limit [LIM_365] (rows=100 width=212)
           Number of rows:100
-          Select Operator [SEL_368] (rows=430 width=212)
+          Select Operator [SEL_364] (rows=430 width=212)
             Output:["_col0","_col1"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_367]
-              Group By Operator [GBY_366] (rows=430 width=212)
+            SHUFFLE [RS_363]
+              Group By Operator [GBY_362] (rows=430 width=212)
                 Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
               <-Union 5 [SIMPLE_EDGE]
                 <-Reducer 10 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_382]
+                  Reduce Output Operator [RS_378]
                     PartitionCols:_col0
-                    Group By Operator [GBY_381] (rows=430 width=212)
+                    Group By Operator [GBY_377] (rows=430 width=212)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Group By Operator [GBY_380] (rows=430 width=212)
+                      Group By Operator [GBY_376] (rows=430 width=212)
                         Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                       <-Reducer 9 [SIMPLE_EDGE]
                         SHUFFLE [RS_69]
                           PartitionCols:_col0
                           Group By Operator [GBY_68] (rows=430 width=212)
                             Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                            Merge Join Operator [MERGEJOIN_304] (rows=373066 width=100)
+                            Merge Join Operator [MERGEJOIN_300] (rows=373066 width=100)
                               Conds:RS_64._col0=RS_65._col3(Inner),Output:["_col1","_col7"]
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_64]
                                 PartitionCols:_col0
-                                Merge Join Operator [MERGEJOIN_294] (rows=17170 width=104)
-                                  Conds:RS_319._col1=RS_325._col0(Inner),Output:["_col0","_col1"]
+                                Merge Join Operator [MERGEJOIN_290] (rows=17170 width=104)
+                                  Conds:RS_315._col1=RS_321._col0(Inner),Output:["_col0","_col1"]
                                 <-Map 1 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_319]
+                                  SHUFFLE [RS_315]
                                     PartitionCols:_col1
-                                    Select Operator [SEL_318] (rows=462000 width=104)
+                                    Select Operator [SEL_314] (rows=462000 width=104)
                                       Output:["_col0","_col1"]
                                       TableScan [TS_0] (rows=462000 width=104)
                                         default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
                                 <-Reducer 16 [ONE_TO_ONE_EDGE] vectorized
-                                  FORWARD [RS_325]
+                                  FORWARD [RS_321]
                                     PartitionCols:_col0
-                                    Group By Operator [GBY_324] (rows=11550 width=100)
+                                    Group By Operator [GBY_320] (rows=11550 width=100)
                                       Output:["_col0"],keys:KEY._col0
                                     <-Map 15 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_323]
+                                      SHUFFLE [RS_319]
                                         PartitionCols:_col0
-                                        Group By Operator [GBY_322] (rows=11550 width=100)
+                                        Group By Operator [GBY_318] (rows=11550 width=100)
                                           Output:["_col0"],keys:i_item_id
-                                          Select Operator [SEL_321] (rows=23100 width=189)
+                                          Select Operator [SEL_317] (rows=23100 width=189)
                                             Output:["i_item_id"]
-                                            Filter Operator [FIL_320] (rows=23100 width=189)
+                                            Filter Operator [FIL_316] (rows=23100 width=189)
                                               predicate:(i_color) IN ('orchid', 'chiffon', 'lace')
                                               TableScan [TS_2] (rows=462000 width=189)
                                                 default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_id","i_color"]
@@ -240,231 +240,231 @@ Stage-0
                                 PartitionCols:_col3
                                 Select Operator [SEL_60] (rows=1550375 width=13)
                                   Output:["_col3","_col4"]
-                                  Merge Join Operator [MERGEJOIN_299] (rows=1550375 width=13)
-                                    Conds:RS_57._col1=RS_346._col0(Inner),Output:["_col2","_col3"]
+                                  Merge Join Operator [MERGEJOIN_295] (rows=1550375 width=13)
+                                    Conds:RS_57._col1=RS_342._col0(Inner),Output:["_col2","_col3"]
                                   <-Map 28 [SIMPLE_EDGE] vectorized
-                                    PARTITION_ONLY_SHUFFLE [RS_346]
+                                    PARTITION_ONLY_SHUFFLE [RS_342]
                                       PartitionCols:_col0
-                                      Select Operator [SEL_343] (rows=8000000 width=4)
+                                      Select Operator [SEL_339] (rows=8000000 width=4)
                                         Output:["_col0"]
-                                        Filter Operator [FIL_342] (rows=8000000 width=112)
+                                        Filter Operator [FIL_338] (rows=8000000 width=112)
                                           predicate:(ca_gmt_offset = -8)
                                           TableScan [TS_15] (rows=40000000 width=112)
                                             default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_gmt_offset"]
                                   <-Reducer 22 [SIMPLE_EDGE]
                                     SHUFFLE [RS_57]
                                       PartitionCols:_col1
-                                      Merge Join Operator [MERGEJOIN_298] (rows=7751872 width=98)
-                                        Conds:RS_379._col0=RS_330._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      Merge Join Operator [MERGEJOIN_294] (rows=7751872 width=98)
+                                        Conds:RS_375._col0=RS_326._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 20 [SIMPLE_EDGE] vectorized
-                                        PARTITION_ONLY_SHUFFLE [RS_330]
+                                        PARTITION_ONLY_SHUFFLE [RS_326]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_327] (rows=50 width=4)
+                                          Select Operator [SEL_323] (rows=50 width=4)
                                             Output:["_col0"]
-                                            Filter Operator [FIL_326] (rows=50 width=12)
+                                            Filter Operator [FIL_322] (rows=50 width=12)
                                               predicate:((d_moy = 1) and (d_year = 2000))
                                               TableScan [TS_12] (rows=73049 width=12)
                                                 default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
                                       <-Map 32 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_379]
+                                        SHUFFLE [RS_375]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_378] (rows=285117733 width=123)
+                                          Select Operator [SEL_374] (rows=285117733 width=123)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_377] (rows=285117733 width=123)
+                                            Filter Operator [FIL_373] (rows=285117733 width=123)
                                               predicate:((cs_bill_addr_sk BETWEEN DynamicValue(RS_58_customer_address_ca_address_sk_min) AND DynamicValue(RS_58_customer_address_ca_address_sk_max) and in_bloom_filter(cs_bill_addr_sk, DynamicValue(RS_58_customer_address_ca_address_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_64_item_i_item_sk_min) AND DynamicValue(RS_64_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_64_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_55_date_dim_d_date_sk_min) AND DynamicValue(RS_55_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_55_date_dim_d_date_sk_bloom_filter))) and cs_bill_addr_sk is not null and cs_sold_date_sk is not null)
                                               TableScan [TS_45] (rows=287989836 width=123)
                                                 default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_addr_sk","cs_item_sk","cs_ext_sales_price"]
                                               <-Reducer 11 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_376]
-                                                  Group By Operator [GBY_375] (rows=1 width=12)
+                                                BROADCAST [RS_372]
+                                                  Group By Operator [GBY_371] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
-                                                    SHUFFLE [RS_239]
-                                                      Group By Operator [GBY_238] (rows=1 width=12)
+                                                    SHUFFLE [RS_237]
+                                                      Group By Operator [GBY_236] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_237] (rows=17170 width=4)
+                                                        Select Operator [SEL_235] (rows=17170 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_290]
                                               <-Reducer 24 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_372]
-                                                  Group By Operator [GBY_371] (rows=1 width=12)
+                                                BROADCAST [RS_368]
+                                                  Group By Operator [GBY_367] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_338]
-                                                      Group By Operator [GBY_335] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_334]
+                                                      Group By Operator [GBY_331] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_331] (rows=50 width=4)
+                                                        Select Operator [SEL_327] (rows=50 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_327]
+                                                           Please refer to the previous Select Operator [SEL_323]
                                               <-Reducer 30 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_374]
-                                                  Group By Operator [GBY_373] (rows=1 width=12)
+                                                BROADCAST [RS_370]
+                                                  Group By Operator [GBY_369] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                   <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_354]
-                                                      Group By Operator [GBY_351] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_350]
+                                                      Group By Operator [GBY_347] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                        Select Operator [SEL_347] (rows=8000000 width=4)
+                                                        Select Operator [SEL_343] (rows=8000000 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_343]
+                                                           Please refer to the previous Select Operator [SEL_339]
                 <-Reducer 13 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_394]
+                  Reduce Output Operator [RS_390]
                     PartitionCols:_col0
-                    Group By Operator [GBY_393] (rows=430 width=212)
+                    Group By Operator [GBY_389] (rows=430 width=212)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Group By Operator [GBY_392] (rows=430 width=212)
+                      Group By Operator [GBY_388] (rows=430 width=212)
                         Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                       <-Reducer 12 [SIMPLE_EDGE]
                         SHUFFLE [RS_106]
                           PartitionCols:_col0
                           Group By Operator [GBY_105] (rows=430 width=212)
                             Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                            Merge Join Operator [MERGEJOIN_305] (rows=189670 width=190)
+                            Merge Join Operator [MERGEJOIN_301] (rows=189670 width=190)
                               Conds:RS_101._col0=RS_102._col2(Inner),Output:["_col1","_col7"]
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_101]
                                 PartitionCols:_col0
-                                 Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_290]
                             <-Reducer 26 [SIMPLE_EDGE]
                               SHUFFLE [RS_102]
                                 PartitionCols:_col2
                                 Select Operator [SEL_97] (rows=788222 width=110)
                                   Output:["_col2","_col4"]
-                                  Merge Join Operator [MERGEJOIN_302] (rows=788222 width=110)
-                                    Conds:RS_94._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
+                                  Merge Join Operator [MERGEJOIN_298] (rows=788222 width=110)
+                                    Conds:RS_94._col2=RS_344._col0(Inner),Output:["_col1","_col3"]
                                   <-Map 28 [SIMPLE_EDGE] vectorized
-                                    PARTITION_ONLY_SHUFFLE [RS_348]
+                                    PARTITION_ONLY_SHUFFLE [RS_344]
                                       PartitionCols:_col0
-                                       Please refer to the previous Select Operator [SEL_343]
+                                       Please refer to the previous Select Operator [SEL_339]
                                   <-Reducer 25 [SIMPLE_EDGE]
                                     SHUFFLE [RS_94]
                                       PartitionCols:_col2
-                                      Merge Join Operator [MERGEJOIN_301] (rows=3941109 width=118)
-                                        Conds:RS_391._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      Merge Join Operator [MERGEJOIN_297] (rows=3941109 width=118)
+                                        Conds:RS_387._col0=RS_328._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 20 [SIMPLE_EDGE] vectorized
-                                        PARTITION_ONLY_SHUFFLE [RS_332]
+                                        PARTITION_ONLY_SHUFFLE [RS_328]
                                           PartitionCols:_col0
-                                           Please refer to the previous Select Operator [SEL_327]
+                                           Please refer to the previous Select Operator [SEL_323]
                                       <-Map 33 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_391]
+                                        SHUFFLE [RS_387]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_390] (rows=143931246 width=123)
+                                          Select Operator [SEL_386] (rows=143931246 width=123)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_389] (rows=143931246 width=123)
+                                            Filter Operator [FIL_385] (rows=143931246 width=123)
                                               predicate:((ws_bill_addr_sk BETWEEN DynamicValue(RS_95_customer_address_ca_address_sk_min) AND DynamicValue(RS_95_customer_address_ca_address_sk_max) and in_bloom_filter(ws_bill_addr_sk, DynamicValue(RS_95_customer_address_ca_address_sk_bloom_filter))) and (ws_item_sk BETWEEN DynamicValue(RS_101_item_i_item_sk_min) AND DynamicValue(RS_101_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_101_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_92_date_dim_d_date_sk_min) AND DynamicValue(RS_92_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_92_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
                                               TableScan [TS_82] (rows=144002668 width=123)
                                                 default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_addr_sk","ws_ext_sales_price"]
                                               <-Reducer 14 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_388]
-                                                  Group By Operator [GBY_387] (rows=1 width=12)
+                                                BROADCAST [RS_384]
+                                                  Group By Operator [GBY_383] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
-                                                    SHUFFLE [RS_285]
-                                                      Group By Operator [GBY_284] (rows=1 width=12)
+                                                    SHUFFLE [RS_277]
+                                                      Group By Operator [GBY_276] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_283] (rows=17170 width=4)
+                                                        Select Operator [SEL_275] (rows=17170 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_290]
                                               <-Reducer 27 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_384]
-                                                  Group By Operator [GBY_383] (rows=1 width=12)
+                                                BROADCAST [RS_380]
+                                                  Group By Operator [GBY_379] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_339]
-                                                      Group By Operator [GBY_336] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_335]
+                                                      Group By Operator [GBY_332] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_333] (rows=50 width=4)
+                                                        Select Operator [SEL_329] (rows=50 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_327]
+                                                           Please refer to the previous Select Operator [SEL_323]
                                               <-Reducer 31 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_386]
-                                                  Group By Operator [GBY_385] (rows=1 width=12)
+                                                BROADCAST [RS_382]
+                                                  Group By Operator [GBY_381] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                   <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_355]
-                                                      Group By Operator [GBY_352] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_351]
+                                                      Group By Operator [GBY_348] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                        Select Operator [SEL_349] (rows=8000000 width=4)
+                                                        Select Operator [SEL_345] (rows=8000000 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_343]
+                                                           Please refer to the previous Select Operator [SEL_339]
                 <-Reducer 4 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_365]
+                  Reduce Output Operator [RS_361]
                     PartitionCols:_col0
-                    Group By Operator [GBY_364] (rows=430 width=212)
+                    Group By Operator [GBY_360] (rows=430 width=212)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Group By Operator [GBY_363] (rows=430 width=212)
+                      Group By Operator [GBY_359] (rows=430 width=212)
                         Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                       <-Reducer 3 [SIMPLE_EDGE]
                         SHUFFLE [RS_33]
                           PartitionCols:_col0
                           Group By Operator [GBY_32] (rows=430 width=212)
                             Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                            Merge Join Operator [MERGEJOIN_303] (rows=692265 width=100)
+                            Merge Join Operator [MERGEJOIN_299] (rows=692265 width=100)
                               Conds:RS_28._col0=RS_29._col2(Inner),Output:["_col1","_col7"]
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_28]
                                 PartitionCols:_col0
-                                 Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_290]
                             <-Reducer 19 [SIMPLE_EDGE]
                               SHUFFLE [RS_29]
                                 PartitionCols:_col2
                                 Select Operator [SEL_24] (rows=2876890 width=4)
                                   Output:["_col2","_col4"]
-                                  Merge Join Operator [MERGEJOIN_296] (rows=2876890 width=4)
-                                    Conds:RS_21._col2=RS_344._col0(Inner),Output:["_col1","_col3"]
+                                  Merge Join Operator [MERGEJOIN_292] (rows=2876890 width=4)
+                                    Conds:RS_21._col2=RS_340._col0(Inner),Output:["_col1","_col3"]
                                   <-Map 28 [SIMPLE_EDGE] vectorized
-                                    PARTITION_ONLY_SHUFFLE [RS_344]
+                                    PARTITION_ONLY_SHUFFLE [RS_340]
                                       PartitionCols:_col0
-                                       Please refer to the previous Select Operator [SEL_343]
+                                       Please refer to the previous Select Operator [SEL_339]
                                   <-Reducer 18 [SIMPLE_EDGE]
                                     SHUFFLE [RS_21]
                                       PartitionCols:_col2
-                                      Merge Join Operator [MERGEJOIN_295] (rows=14384447 width=4)
-                                        Conds:RS_362._col0=RS_328._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      Merge Join Operator [MERGEJOIN_291] (rows=14384447 width=4)
+                                        Conds:RS_358._col0=RS_324._col0(Inner),Output:["_col1","_col2","_col3"]
                                       <-Map 20 [SIMPLE_EDGE] vectorized
-                                        PARTITION_ONLY_SHUFFLE [RS_328]
+                                        PARTITION_ONLY_SHUFFLE [RS_324]
                                           PartitionCols:_col0
-                                           Please refer to the previous Select Operator [SEL_327]
+                                           Please refer to the previous Select Operator [SEL_323]
                                       <-Map 17 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_362]
+                                        SHUFFLE [RS_358]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_361] (rows=525327191 width=118)
+                                          Select Operator [SEL_357] (rows=525327191 width=118)
                                             Output:["_col0","_col1","_col2","_col3"]
-                                            Filter Operator [FIL_360] (rows=525327191 width=118)
+                                            Filter Operator [FIL_356] (rows=525327191 width=118)
                                               predicate:((ss_addr_sk BETWEEN DynamicValue(RS_22_customer_address_ca_address_sk_min) AND DynamicValue(RS_22_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_22_customer_address_ca_address_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_28_item_i_item_sk_min) AND DynamicValue(RS_28_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_28_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_19_date_dim_d_date_sk_min) AND DynamicValue(RS_19_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_19_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
                                               TableScan [TS_9] (rows=575995635 width=118)
                                                 default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
                                               <-Reducer 21 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_341]
-                                                  Group By Operator [GBY_340] (rows=1 width=12)
+                                                BROADCAST [RS_337]
+                                                  Group By Operator [GBY_336] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_337]
-                                                      Group By Operator [GBY_334] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_333]
+                                                      Group By Operator [GBY_330] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_329] (rows=50 width=4)
+                                                        Select Operator [SEL_325] (rows=50 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_327]
+                                                           Please refer to the previous Select Operator [SEL_323]
                                               <-Reducer 29 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_357]
-                                                  Group By Operator [GBY_356] (rows=1 width=12)
+                                                BROADCAST [RS_353]
+                                                  Group By Operator [GBY_352] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                   <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_353]
-                                                      Group By Operator [GBY_350] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_349]
+                                                      Group By Operator [GBY_346] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                        Select Operator [SEL_345] (rows=8000000 width=4)
+                                                        Select Operator [SEL_341] (rows=8000000 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_343]
+                                                           Please refer to the previous Select Operator [SEL_339]
                                               <-Reducer 8 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_359]
-                                                  Group By Operator [GBY_358] (rows=1 width=12)
+                                                BROADCAST [RS_355]
+                                                  Group By Operator [GBY_354] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
-                                                    SHUFFLE [RS_203]
-                                                      Group By Operator [GBY_202] (rows=1 width=12)
+                                                    SHUFFLE [RS_197]
+                                                      Group By Operator [GBY_196] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_201] (rows=17170 width=4)
+                                                        Select Operator [SEL_195] (rows=17170 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_290]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out
index 85c962f..74bec5c 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out
@@ -1,4 +1,4 @@
-Warning: Map Join MAPJOIN[172][bigTable=?] in task 'Reducer 15' is a cross product
+Warning: Map Join MAPJOIN[170][bigTable=?] in task 'Reducer 15' is a cross product
 PREHOOK: query: explain
 select  a.ca_state state, count(*) cnt
  from customer_address a
@@ -83,153 +83,153 @@ Stage-0
     limit:100
     Stage-1
       Reducer 10 vectorized
-      File Output Operator [FS_234]
-        Limit [LIM_233] (rows=1 width=94)
+      File Output Operator [FS_232]
+        Limit [LIM_231] (rows=1 width=94)
           Number of rows:100
-          Select Operator [SEL_232] (rows=1 width=94)
+          Select Operator [SEL_230] (rows=1 width=94)
             Output:["_col0","_col1"]
           <-Reducer 9 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_231]
-              Filter Operator [FIL_230] (rows=1 width=94)
+            SHUFFLE [RS_229]
+              Filter Operator [FIL_228] (rows=1 width=94)
                 predicate:(_col1 >= 10L)
-                Group By Operator [GBY_229] (rows=1 width=94)
+                Group By Operator [GBY_227] (rows=1 width=94)
                   Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
                 <-Reducer 8 [SIMPLE_EDGE]
                   SHUFFLE [RS_68]
                     PartitionCols:_col0
                     Group By Operator [GBY_67] (rows=1 width=94)
                       Output:["_col0","_col1"],aggregations:["count()"],keys:_col9
-                      Merge Join Operator [MERGEJOIN_175] (rows=316 width=86)
-                        Conds:RS_63._col4=RS_214._col0(Inner),Output:["_col9"]
+                      Merge Join Operator [MERGEJOIN_173] (rows=316 width=86)
+                        Conds:RS_63._col4=RS_212._col0(Inner),Output:["_col9"]
                       <-Map 16 [SIMPLE_EDGE] vectorized
-                        SHUFFLE [RS_214]
+                        SHUFFLE [RS_212]
                           PartitionCols:_col0
-                          Select Operator [SEL_213] (rows=154000 width=227)
+                          Select Operator [SEL_211] (rows=154000 width=227)
                             Output:["_col0"]
-                            Filter Operator [FIL_212] (rows=154000 width=227)
+                            Filter Operator [FIL_210] (rows=154000 width=227)
                               predicate:(_col4 > _col1)
-                              Map Join Operator [MAPJOIN_211] (rows=462000 width=227)
-                                Conds:RS_208._col0=SEL_210._col2(Inner),HybridGraceHashJoin:true,Output:["_col1","_col3","_col4"]
+                              Map Join Operator [MAPJOIN_209] (rows=462000 width=227)
+                                Conds:RS_206._col0=SEL_208._col2(Inner),HybridGraceHashJoin:true,Output:["_col1","_col3","_col4"]
                               <-Reducer 15 [BROADCAST_EDGE] vectorized
-                                BROADCAST [RS_208]
+                                BROADCAST [RS_206]
                                   PartitionCols:_col0
-                                  Map Join Operator [MAPJOIN_207] (rows=10 width=202)
+                                  Map Join Operator [MAPJOIN_205] (rows=10 width=202)
                                     Conds:(Inner),Output:["_col0","_col1"]
                                   <-Reducer 5 [BROADCAST_EDGE] vectorized
-                                    BROADCAST [RS_204]
-                                      Select Operator [SEL_203] (rows=1 width=8)
-                                        Filter Operator [FIL_202] (rows=1 width=8)
+                                    BROADCAST [RS_202]
+                                      Select Operator [SEL_201] (rows=1 width=8)
+                                        Filter Operator [FIL_200] (rows=1 width=8)
                                           predicate:(sq_count_check(_col0) <= 1)
-                                          Group By Operator [GBY_201] (rows=1 width=8)
+                                          Group By Operator [GBY_199] (rows=1 width=8)
                                             Output:["_col0"],aggregations:["count(VALUE._col0)"]
                                           <-Reducer 4 [CUSTOM_SIMPLE_EDGE] vectorized
-                                            PARTITION_ONLY_SHUFFLE [RS_200]
-                                              Group By Operator [GBY_199] (rows=1 width=8)
+                                            PARTITION_ONLY_SHUFFLE [RS_198]
+                                              Group By Operator [GBY_197] (rows=1 width=8)
                                                 Output:["_col0"],aggregations:["count()"]
-                                                Select Operator [SEL_198] (rows=25 width=4)
-                                                  Group By Operator [GBY_197] (rows=25 width=4)
+                                                Select Operator [SEL_196] (rows=25 width=4)
+                                                  Group By Operator [GBY_195] (rows=25 width=4)
                                                     Output:["_col0"],keys:KEY._col0
                                                   <-Map 2 [SIMPLE_EDGE] vectorized
-                                                    SHUFFLE [RS_187]
+                                                    SHUFFLE [RS_185]
                                                       PartitionCols:_col0
-                                                      Group By Operator [GBY_185] (rows=25 width=4)
+                                                      Group By Operator [GBY_183] (rows=25 width=4)
                                                         Output:["_col0"],keys:d_month_seq
-                                                        Select Operator [SEL_183] (rows=50 width=12)
+                                                        Select Operator [SEL_181] (rows=50 width=12)
                                                           Output:["d_month_seq"]
-                                                          Filter Operator [FIL_181] (rows=50 width=12)
+                                                          Filter Operator [FIL_179] (rows=50 width=12)
                                                             predicate:((d_moy = 2) and (d_year = 2000))
                                                             TableScan [TS_3] (rows=73049 width=12)
                                                               default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_month_seq","d_year","d_moy"]
-                                  <-Select Operator [SEL_206] (rows=10 width=202)
+                                  <-Select Operator [SEL_204] (rows=10 width=202)
                                       Output:["_col0","_col1"]
-                                      Group By Operator [GBY_205] (rows=10 width=210)
+                                      Group By Operator [GBY_203] (rows=10 width=210)
                                         Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
                                       <-Map 14 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_196]
+                                        SHUFFLE [RS_194]
                                           PartitionCols:_col0
-                                          Group By Operator [GBY_195] (rows=10 width=210)
+                                          Group By Operator [GBY_193] (rows=10 width=210)
                                             Output:["_col0","_col1","_col2"],aggregations:["sum(i_current_price)","count(i_current_price)"],keys:i_category
-                                            Filter Operator [FIL_194] (rows=462000 width=201)
+                                            Filter Operator [FIL_192] (rows=462000 width=201)
                                               predicate:i_category is not null
                                               TableScan [TS_22] (rows=462000 width=201)
                                                 default@item,j,Tbl:COMPLETE,Col:COMPLETE,Output:["i_current_price","i_category"]
-                              <-Select Operator [SEL_210] (rows=462000 width=205)
+                              <-Select Operator [SEL_208] (rows=462000 width=205)
                                   Output:["_col0","_col1","_col2"]
-                                  Filter Operator [FIL_209] (rows=462000 width=205)
+                                  Filter Operator [FIL_207] (rows=462000 width=205)
                                     predicate:i_category is not null
                                     TableScan [TS_43] (rows=462000 width=205)
                                       default@item,i,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_category"]
                       <-Reducer 7 [SIMPLE_EDGE]
                         SHUFFLE [RS_63]
                           PartitionCols:_col4
-                          Merge Join Operator [MERGEJOIN_174] (rows=7192227 width=90)
-                            Conds:RS_223._col5=RS_61._col0(Inner),Output:["_col4","_col9"]
+                          Merge Join Operator [MERGEJOIN_172] (rows=7192227 width=90)
+                            Conds:RS_221._col5=RS_61._col0(Inner),Output:["_col4","_col9"]
                           <-Map 6 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_223]
+                            SHUFFLE [RS_221]
                               PartitionCols:_col5
-                              Map Join Operator [MAPJOIN_222] (rows=7192227 width=4)
-                                Conds:RS_193._col0=SEL_221._col0(Inner),HybridGraceHashJoin:true,Output:["_col4","_col5"]
+                              Map Join Operator [MAPJOIN_220] (rows=7192227 width=4)
+                                Conds:RS_191._col0=SEL_219._col0(Inner),HybridGraceHashJoin:true,Output:["_col4","_col5"]
                               <-Map 1 [BROADCAST_EDGE] vectorized
-                                BROADCAST [RS_193]
+                                BROADCAST [RS_191]
                                   PartitionCols:_col0
-                                  Map Join Operator [MAPJOIN_192] (rows=660 width=4)
-                                    Conds:SEL_191._col1=RS_189._col0(Inner),HybridGraceHashJoin:true,Output:["_col0"]
+                                  Map Join Operator [MAPJOIN_190] (rows=660 width=4)
+                                    Conds:SEL_189._col1=RS_187._col0(Inner),HybridGraceHashJoin:true,Output:["_col0"]
                                   <-Reducer 3 [BROADCAST_EDGE] vectorized
-                                    BROADCAST [RS_189]
+                                    BROADCAST [RS_187]
                                       PartitionCols:_col0
-                                      Group By Operator [GBY_188] (rows=25 width=4)
+                                      Group By Operator [GBY_186] (rows=25 width=4)
                                         Output:["_col0"],keys:KEY._col0
                                       <-Map 2 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_186]
+                                        SHUFFLE [RS_184]
                                           PartitionCols:_col0
-                                          Group By Operator [GBY_184] (rows=25 width=4)
+                                          Group By Operator [GBY_182] (rows=25 width=4)
                                             Output:["_col0"],keys:d_month_seq
-                                            Select Operator [SEL_182] (rows=50 width=12)
+                                            Select Operator [SEL_180] (rows=50 width=12)
                                               Output:["d_month_seq"]
-                                              Filter Operator [FIL_180] (rows=50 width=12)
+                                              Filter Operator [FIL_178] (rows=50 width=12)
                                                 predicate:((d_moy = 2) and (d_year = 2000) and d_month_seq is not null)
                                                  Please refer to the previous TableScan [TS_3]
-                                  <-Select Operator [SEL_191] (rows=73049 width=8)
+                                  <-Select Operator [SEL_189] (rows=73049 width=8)
                                       Output:["_col0","_col1"]
-                                      Filter Operator [FIL_190] (rows=73049 width=8)
+                                      Filter Operator [FIL_188] (rows=73049 width=8)
                                         predicate:d_month_seq is not null
                                         TableScan [TS_0] (rows=73049 width=8)
                                           default@date_dim,d,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq"]
-                              <-Select Operator [SEL_221] (rows=525327388 width=11)
+                              <-Select Operator [SEL_219] (rows=525327388 width=11)
                                   Output:["_col0","_col1","_col2"]
-                                  Filter Operator [FIL_220] (rows=525327388 width=11)
+                                  Filter Operator [FIL_218] (rows=525327388 width=11)
                                     predicate:((ss_item_sk BETWEEN DynamicValue(RS_64_i_i_item_sk_min) AND DynamicValue(RS_64_i_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_64_i_i_item_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
                                     TableScan [TS_10] (rows=575995635 width=11)
                                       default@store_sales,s,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk"]
                                     <-Reducer 17 [BROADCAST_EDGE] vectorized
-                                      BROADCAST [RS_219]
-                                        Group By Operator [GBY_218] (rows=1 width=12)
+                                      BROADCAST [RS_217]
+                                        Group By Operator [GBY_216] (rows=1 width=12)
                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                         <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_217]
-                                            Group By Operator [GBY_216] (rows=1 width=12)
+                                          SHUFFLE [RS_215]
+                                            Group By Operator [GBY_214] (rows=1 width=12)
                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                              Select Operator [SEL_215] (rows=154000 width=4)
+                                              Select Operator [SEL_213] (rows=154000 width=4)
                                                 Output:["_col0"]
-                                                 Please refer to the previous Select Operator [SEL_213]
+                                                 Please refer to the previous Select Operator [SEL_211]
                           <-Reducer 12 [SIMPLE_EDGE]
                             SHUFFLE [RS_61]
                               PartitionCols:_col0
-                              Merge Join Operator [MERGEJOIN_171] (rows=80000000 width=90)
-                                Conds:RS_226._col1=RS_228._col0(Inner),Output:["_col0","_col3"]
+                              Merge Join Operator [MERGEJOIN_169] (rows=80000000 width=90)
+                                Conds:RS_224._col1=RS_226._col0(Inner),Output:["_col0","_col3"]
                               <-Map 11 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_226]
+                                SHUFFLE [RS_224]
                                   PartitionCols:_col1
-                                  Select Operator [SEL_225] (rows=80000000 width=8)
+                                  Select Operator [SEL_223] (rows=80000000 width=8)
                                     Output:["_col0","_col1"]
-                                    Filter Operator [FIL_224] (rows=80000000 width=8)
+                                    Filter Operator [FIL_222] (rows=80000000 width=8)
                                       predicate:c_current_addr_sk is not null
                                       TableScan [TS_13] (rows=80000000 width=8)
                                         default@customer,c,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk"]
                               <-Map 13 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_228]
+                                SHUFFLE [RS_226]
                                   PartitionCols:_col0
-                                  Select Operator [SEL_227] (rows=40000000 width=90)
+                                  Select Operator [SEL_225] (rows=40000000 width=90)
                                     Output:["_col0","_col1"]
                                     TableScan [TS_16] (rows=40000000 width=90)
                                       default@customer_address,a,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]


[72/75] [abbrv] hive git commit: HIVE-20661: Dynamic partitions loading calls add partition for every partition 1-by-1 (Laszlo Pinter via Peter Vary)

Posted by se...@apache.org.
HIVE-20661: Dynamic partitions loading calls add partition for every partition 1-by-1 (Laszlo Pinter via Peter Vary)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0d701546
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0d701546
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0d701546

Branch: refs/heads/master-tez092
Commit: 0d7015468611c485c01bb80cdbe4c89e4e68b680
Parents: 50a96d7
Author: Laszlo Pinter <lp...@cloudera.com>
Authored: Fri Oct 26 13:43:53 2018 +0200
Committer: Peter Vary <pv...@cloudera.com>
Committed: Fri Oct 26 13:43:53 2018 +0200

----------------------------------------------------------------------
 .../metastore/SynchronizedMetaStoreClient.java  |   4 +
 .../apache/hadoop/hive/ql/metadata/Hive.java    | 495 +++++++++++++------
 .../ql/metadata/SessionHiveMetaStoreClient.java |  52 +-
 .../hive/metastore/HiveMetaStoreClient.java     |   2 +-
 4 files changed, 398 insertions(+), 155 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/0d701546/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java b/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java
index 0ab77e8..e8f3623 100644
--- a/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java
+++ b/ql/src/java/org/apache/hadoop/hive/metastore/SynchronizedMetaStoreClient.java
@@ -78,6 +78,10 @@ public final class SynchronizedMetaStoreClient {
     return client.add_partition(partition);
   }
 
+  public synchronized int add_partitions(List<Partition> partitions) throws TException {
+    return client.add_partitions(partitions);
+  }
+
   public synchronized void alter_partition(String catName, String dbName, String tblName,
       Partition newPart, EnvironmentContext environmentContext, String writeIdList) throws TException {
     client.alter_partition(catName, dbName, tblName, newPart, environmentContext, writeIdList);

http://git-wip-us.apache.org/repos/asf/hive/blob/0d701546/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index 4de0389..012a670 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -45,6 +45,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
@@ -96,18 +97,17 @@ import org.apache.hadoop.hive.io.HdfsUtils;
 import org.apache.hadoop.hive.metastore.HiveMetaException;
 import org.apache.hadoop.hive.metastore.HiveMetaHook;
 import org.apache.hadoop.hive.metastore.HiveMetaHookLoader;
-import org.apache.hadoop.hive.metastore.HiveMetaStore;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreUtils;
 import org.apache.hadoop.hive.metastore.IMetaStoreClient;
 import org.apache.hadoop.hive.metastore.PartitionDropOptions;
-import org.apache.hadoop.hive.metastore.RawStore;
 import org.apache.hadoop.hive.metastore.RetryingMetaStoreClient;
 import org.apache.hadoop.hive.metastore.SynchronizedMetaStoreClient;
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.Warehouse;
 import org.apache.hadoop.hive.metastore.ReplChangeManager;
 import org.apache.hadoop.hive.metastore.api.*;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils;
 import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
 import org.apache.hadoop.hive.ql.ErrorMsg;
@@ -1866,17 +1866,102 @@ public class Hive {
       boolean isSkewedStoreAsSubdir,
       boolean isSrcLocal, boolean isAcidIUDoperation, boolean hasFollowingStatsTask, Long writeId,
       int stmtId, boolean isInsertOverwrite) throws HiveException {
+
+    PerfLogger perfLogger = SessionState.getPerfLogger();
+    perfLogger.PerfLogBegin("MoveTask", PerfLogger.LOAD_PARTITION);
+
+    // Get the partition object if it already exists
+    Partition oldPart = getPartition(tbl, partSpec, false);
+    boolean isTxnTable = AcidUtils.isTransactionalTable(tbl);
+
+    // If config is set, table is not temporary and partition being inserted exists, capture
+    // the list of files added. For not yet existing partitions (insert overwrite to new partition
+    // or dynamic partition inserts), the add partition event will capture the list of files added.
+    List<Path> newFiles = Collections.synchronizedList(new ArrayList<>());
+
+    Partition newTPart = loadPartitionInternal(loadPath, tbl, partSpec, oldPart,
+            loadFileType, inheritTableSpecs,
+            inheritLocation, isSkewedStoreAsSubdir, isSrcLocal, isAcidIUDoperation,
+            hasFollowingStatsTask, writeId, stmtId, isInsertOverwrite, isTxnTable, newFiles);
+
+    AcidUtils.TableSnapshot tableSnapshot = AcidUtils.getTableSnapshot(conf,
+            newTPart.getTable(), true);
+    if (tableSnapshot != null) {
+      newTPart.getTPartition().setWriteId(tableSnapshot.getWriteId());
+    }
+
+    if (oldPart == null) {
+      addPartitionToMetastore(newTPart, hasFollowingStatsTask, tbl, tableSnapshot);
+      // For acid table, add the acid_write event with file list at the time of load itself. But
+      // it should be done after partition is created.
+      if (isTxnTable && (null != newFiles)) {
+        addWriteNotificationLog(tbl, partSpec, newFiles, writeId);
+      }
+    } else {
+      try {
+        setStatsPropAndAlterPartition(hasFollowingStatsTask, tbl, newTPart, tableSnapshot);
+      } catch (TException e) {
+        LOG.error(StringUtils.stringifyException(e));
+        throw new HiveException(e);
+      }
+    }
+
+    perfLogger.PerfLogEnd("MoveTask", PerfLogger.LOAD_PARTITION);
+
+    return newTPart;
+  }
+
+  /**
+   * Move all the files from loadPath into Hive. If the partition
+   * does not exist - one is created - files in loadPath are moved into Hive. But the
+   * directory itself is not removed.
+   *
+   * @param loadPath
+   *          Directory containing files to load into Table
+   * @param tbl
+   *          name of table to be loaded.
+   * @param partSpec
+   *          defines which partition needs to be loaded
+   * @param oldPart
+   *          already existing partition object, can be null
+   * @param loadFileType
+   *          if REPLACE_ALL - replace files in the table,
+   *          otherwise add files to table (KEEP_EXISTING, OVERWRITE_EXISTING)
+   * @param inheritTableSpecs if true, on [re]creating the partition, take the
+   *          location/inputformat/outputformat/serde details from table spec
+   * @param inheritLocation
+   *          if true, partition path is generated from table
+   * @param isSkewedStoreAsSubdir
+   *          if true, skewed is stored as sub-directory
+   * @param isSrcLocal
+   *          If the source directory is LOCAL
+   * @param isAcidIUDoperation
+   *          true if this is an ACID operation Insert/Update/Delete operation
+   * @param hasFollowingStatsTask
+   *          true if there is a following task which updates the stats, so, this method need not update.
+   * @param writeId
+   *          write ID allocated for the current load operation
+   * @param stmtId
+   *          statement ID of the current load statement
+   * @param isInsertOverwrite
+   * @param isTxnTable
+   *
+   * @return Partition object being loaded with data
+   * @throws HiveException
+   */
+  private Partition loadPartitionInternal(Path loadPath, Table tbl, Map<String, String> partSpec,
+                        Partition oldPart, LoadFileType loadFileType, boolean inheritTableSpecs,
+                        boolean inheritLocation, boolean isSkewedStoreAsSubdir,
+                        boolean isSrcLocal, boolean isAcidIUDoperation, boolean hasFollowingStatsTask,
+                        Long writeId, int stmtId, boolean isInsertOverwrite,
+                        boolean isTxnTable, List<Path> newFiles) throws HiveException {
     Path tblDataLocationPath =  tbl.getDataLocation();
     boolean isMmTableWrite = AcidUtils.isInsertOnlyTable(tbl.getParameters());
     assert tbl.getPath() != null : "null==getPath() for " + tbl.getTableName();
     boolean isFullAcidTable = AcidUtils.isFullAcidTable(tbl);
-    boolean isTxnTable = AcidUtils.isTransactionalTable(tbl);
     try {
       PerfLogger perfLogger = SessionState.getPerfLogger();
-      perfLogger.PerfLogBegin("MoveTask", PerfLogger.LOAD_PARTITION);
 
-      // Get the partition object if it already exists
-      Partition oldPart = getPartition(tbl, partSpec, false);
       /**
        * Move files before creating the partition since down stream processes
        * check for existence of partition in metadata before accessing the data.
@@ -1908,17 +1993,9 @@ public class Hive {
         newPartPath = oldPartPath == null
           ? genPartPathFromTable(tbl, partSpec, tblDataLocationPath) : oldPartPath;
       }
-      List<Path> newFiles = Collections.synchronizedList(new ArrayList<Path>());
 
       perfLogger.PerfLogBegin("MoveTask", PerfLogger.FILE_MOVES);
 
-      // If config is set, table is not temporary and partition being inserted exists, capture
-      // the list of files added. For not yet existing partitions (insert overwrite to new partition
-      // or dynamic partition inserts), the add partition event will capture the list of files added.
-      if (areEventsForDmlNeeded(tbl, oldPart)) {
-        newFiles = Collections.synchronizedList(new ArrayList<Path>());
-      }
-
       // Note: the stats for ACID tables do not have any coordination with either Hive ACID logic
       //       like txn commits, time outs, etc.; nor the lower level sync in metastore pertaining
       //       to ACID updates. So the are not themselves ACID.
@@ -1975,11 +2052,6 @@ public class Hive {
       Partition newTPart = oldPart != null ? oldPart : new Partition(tbl, partSpec, newPartPath);
       alterPartitionSpecInMemory(tbl, partSpec, newTPart.getTPartition(), inheritTableSpecs, newPartPath.toString());
       validatePartition(newTPart);
-      AcidUtils.TableSnapshot tableSnapshot = null;
-      tableSnapshot = AcidUtils.getTableSnapshot(conf, newTPart.getTable(), true);
-      if (tableSnapshot != null) {
-        newTPart.getTPartition().setWriteId(tableSnapshot.getWriteId());
-      }
 
       // If config is set, table is not temporary and partition being inserted exists, capture
       // the list of files added. For not yet existing partitions (insert overwrite to new partition
@@ -2037,55 +2109,96 @@ public class Hive {
           // The ACID state is probably absent. Warning is logged in the get method.
           MetaStoreServerUtils.clearQuickStats(newTPart.getParameters());
         }
-        try {
-          LOG.debug("Adding new partition " + newTPart.getSpec());
-          getSynchronizedMSC().add_partition(newTPart.getTPartition());
-        } catch (AlreadyExistsException aee) {
-          // With multiple users concurrently issuing insert statements on the same partition has
-          // a side effect that some queries may not see a partition at the time when they're issued,
-          // but will realize the partition is actually there when it is trying to add such partition
-          // to the metastore and thus get AlreadyExistsException, because some earlier query just created it (race condition).
-          // For example, imagine such a table is created:
-          //  create table T (name char(50)) partitioned by (ds string);
-          // and the following two queries are launched at the same time, from different sessions:
-          //  insert into table T partition (ds) values ('Bob', 'today'); -- creates the partition 'today'
-          //  insert into table T partition (ds) values ('Joe', 'today'); -- will fail with AlreadyExistsException
-          // In that case, we want to retry with alterPartition.
-          LOG.debug("Caught AlreadyExistsException, trying to alter partition instead");
-          setStatsPropAndAlterPartition(hasFollowingStatsTask, tbl, newTPart, tableSnapshot);
-        } catch (Exception e) {
-          try {
-            final FileSystem newPathFileSystem = newPartPath.getFileSystem(this.getConf());
-            boolean isAutoPurge = "true".equalsIgnoreCase(tbl.getProperty("auto.purge"));
-            final FileStatus status = newPathFileSystem.getFileStatus(newPartPath);
-            Hive.trashFiles(newPathFileSystem, new FileStatus[] {status}, this.getConf(), isAutoPurge);
-          } catch (IOException io) {
-            LOG.error("Could not delete partition directory contents after failed partition creation: ", io);
-          }
-          throw e;
-        }
-
-        // For acid table, add the acid_write event with file list at the time of load itself. But
-        // it should be done after partition is created.
-        if (isTxnTable && (null != newFiles)) {
-          addWriteNotificationLog(tbl, partSpec, newFiles, writeId);
-        }
-      } else {
-        setStatsPropAndAlterPartition(hasFollowingStatsTask, tbl, newTPart, tableSnapshot);
       }
 
-      perfLogger.PerfLogEnd("MoveTask", PerfLogger.LOAD_PARTITION);
       return newTPart;
-    } catch (IOException e) {
+    } catch (IOException | MetaException | InvalidOperationException e) {
       LOG.error(StringUtils.stringifyException(e));
       throw new HiveException(e);
-    } catch (MetaException e) {
-      LOG.error(StringUtils.stringifyException(e));
-      throw new HiveException(e);
-    } catch (InvalidOperationException e) {
+    }
+  }
+
+  private void addPartitionToMetastore(Partition newTPart, boolean hasFollowingStatsTask,
+                                       Table tbl, TableSnapshot tableSnapshot) throws HiveException{
+    try {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Adding new partition " + newTPart.getSpec());
+      }
+      getSynchronizedMSC().add_partition(newTPart.getTPartition());
+    } catch (AlreadyExistsException aee) {
+      // With multiple users concurrently issuing insert statements on the same partition has
+      // a side effect that some queries may not see a partition at the time when they're issued,
+      // but will realize the partition is actually there when it is trying to add such partition
+      // to the metastore and thus get AlreadyExistsException, because some earlier query just
+      // created it (race condition).
+      // For example, imagine such a table is created:
+      //  create table T (name char(50)) partitioned by (ds string);
+      // and the following two queries are launched at the same time, from different sessions:
+      //  insert into table T partition (ds) values ('Bob', 'today'); -- creates the partition 'today'
+      //  insert into table T partition (ds) values ('Joe', 'today'); -- will fail with AlreadyExistsException
+      // In that case, we want to retry with alterPartition.
+      LOG.debug("Caught AlreadyExistsException, trying to alter partition instead");
+      try {
+        setStatsPropAndAlterPartition(hasFollowingStatsTask, tbl, newTPart, tableSnapshot);
+      } catch (TException e) {
+        LOG.error(StringUtils.stringifyException(e));
+        throw new HiveException(e);
+      }
+    } catch (Exception e) {
+      try {
+        final FileSystem newPathFileSystem = newTPart.getPartitionPath().getFileSystem(this.getConf());
+        boolean isAutoPurge = "true".equalsIgnoreCase(tbl.getProperty("auto.purge"));
+        final FileStatus status = newPathFileSystem.getFileStatus(newTPart.getPartitionPath());
+        Hive.trashFiles(newPathFileSystem, new FileStatus[]{status}, this.getConf(), isAutoPurge);
+      } catch (IOException io) {
+        LOG.error("Could not delete partition directory contents after failed partition creation: ", io);
+      }
       LOG.error(StringUtils.stringifyException(e));
       throw new HiveException(e);
-    } catch (TException e) {
+    }
+  }
+
+  private void addPartitionsToMetastore(List<Partition> partitions,
+                                        boolean hasFollowingStatsTask, Table tbl,
+                                        List<AcidUtils.TableSnapshot> tableSnapshots)
+                                        throws HiveException {
+    try {
+      if (LOG.isDebugEnabled()) {
+        StringBuffer debugMsg = new StringBuffer("Adding new partitions ");
+        partitions.forEach(partition -> debugMsg.append(partition.getSpec() + " "));
+        LOG.debug(debugMsg.toString());
+      }
+      getSynchronizedMSC().add_partitions(partitions.parallelStream().map(Partition::getTPartition)
+              .collect(Collectors.toList()));
+    } catch(AlreadyExistsException aee) {
+      // With multiple users concurrently issuing insert statements on the same partition has
+      // a side effect that some queries may not see a partition at the time when they're issued,
+      // but will realize the partition is actually there when it is trying to add such partition
+      // to the metastore and thus get AlreadyExistsException, because some earlier query just
+      // created it (race condition).
+      // For example, imagine such a table is created:
+      //  create table T (name char(50)) partitioned by (ds string);
+      // and the following two queries are launched at the same time, from different sessions:
+      //  insert into table T partition (ds) values ('Bob', 'today'); -- creates the partition 'today'
+      //  insert into table T partition (ds) values ('Joe', 'today'); -- will fail with AlreadyExistsException
+      // In that case, we want to retry with alterPartition.
+      LOG.debug("Caught AlreadyExistsException, trying to add partitions one by one.");
+      assert partitions.size() == tableSnapshots.size();
+      for (int i = 0; i < partitions.size(); i++) {
+        addPartitionToMetastore(partitions.get(i), hasFollowingStatsTask, tbl,
+                tableSnapshots.get(i));
+      }
+    } catch (Exception e) {
+      try {
+        for (Partition partition : partitions) {
+          final FileSystem newPathFileSystem = partition.getPartitionPath().getFileSystem(this.getConf());
+          boolean isAutoPurge = "true".equalsIgnoreCase(tbl.getProperty("auto.purge"));
+          final FileStatus status = newPathFileSystem.getFileStatus(partition.getPartitionPath());
+          Hive.trashFiles(newPathFileSystem, new FileStatus[]{status}, this.getConf(), isAutoPurge);
+        }
+      } catch (IOException io) {
+        LOG.error("Could not delete partition directory contents after failed partition creation: ", io);
+      }
       LOG.error(StringUtils.stringifyException(e));
       throw new HiveException(e);
     }
@@ -2375,16 +2488,6 @@ private void constructOneLBLocationMap(FileStatus fSta,
     PerfLogger perfLogger = SessionState.getPerfLogger();
     perfLogger.PerfLogBegin("MoveTask", PerfLogger.LOAD_DYNAMIC_PARTITIONS);
 
-    final Map<Map<String, String>, Partition> partitionsMap =
-        Collections.synchronizedMap(new LinkedHashMap<Map<String, String>, Partition>());
-
-    int poolSize = conf.getInt(ConfVars.HIVE_LOAD_DYNAMIC_PARTITIONS_THREAD_COUNT.varname, 1);
-    final ExecutorService pool = Executors.newFixedThreadPool(poolSize,
-            new ThreadFactoryBuilder()
-                .setDaemon(true)
-                .setNameFormat("load-dynamic-partitions-%d")
-                .build());
-
     // Get all valid partition paths and existing partitions for them (if any)
     final Table tbl = getTable(tableName);
     final Set<Path> validPartitions = getValidPartitionsInPath(numDP, numLB, loadPath, writeId, stmtId,
@@ -2392,113 +2495,193 @@ private void constructOneLBLocationMap(FileStatus fSta,
 
     final int partsToLoad = validPartitions.size();
     final AtomicInteger partitionsLoaded = new AtomicInteger(0);
-
     final boolean inPlaceEligible = conf.getLong("fs.trash.interval", 0) <= 0
         && InPlaceUpdate.canRenderInPlace(conf) && !SessionState.getConsole().getIsSilent();
     final PrintStream ps = (inPlaceEligible) ? SessionState.getConsole().getInfoStream() : null;
+
     final SessionState parentSession = SessionState.get();
+    List<Callable<Partition>> tasks = Lists.newLinkedList();
 
-    final List<Future<Void>> futures = Lists.newLinkedList();
-    // for each dynamically created DP directory, construct a full partition spec
-    // and load the partition based on that
-    final Map<Long, RawStore> rawStoreMap = new ConcurrentHashMap<>();
-    try {
-      for(final Path partPath : validPartitions) {
-        // generate a full partition specification
-        final LinkedHashMap<String, String> fullPartSpec = Maps.newLinkedHashMap(partSpec);
-        if (!Warehouse.makeSpecFromName(
-            fullPartSpec, partPath, new HashSet<String>(partSpec.keySet()))) {
-          Utilities.FILE_OP_LOGGER.warn("Ignoring invalid DP directory " + partPath);
-          continue;
-        }
-        futures.add(pool.submit(new Callable<Void>() {
-          @Override
-          public Void call() throws Exception {
-            try {
-              // move file would require session details (needCopy() invokes SessionState.get)
-              SessionState.setCurrentSessionState(parentSession);
-              LOG.info("New loading path = " + partPath + " with partSpec " + fullPartSpec);
-
-              // load the partition
-              Partition newPartition = loadPartition(partPath, tbl, fullPartSpec, loadFileType,
-                  true, false, numLB > 0, false, isAcid, hasFollowingStatsTask, writeId, stmtId,
-                  isInsertOverwrite);
-              partitionsMap.put(fullPartSpec, newPartition);
-
-              if (inPlaceEligible) {
-                synchronized (ps) {
-                  InPlaceUpdate.rePositionCursor(ps);
-                  partitionsLoaded.incrementAndGet();
-                  InPlaceUpdate.reprintLine(ps, "Loaded : " + partitionsLoaded.get() + "/"
-                      + partsToLoad + " partitions.");
-                }
-              }
-              return null;
-            } catch (Exception t) {
-              LOG.error("Exception when loading partition with parameters "
-                  + " partPath=" + partPath + ", "
+    final class PartitionDetails {
+      Map<String, String> fullSpec;
+      Partition partition;
+      List<Path> newFiles;
+      boolean hasOldPartition = false;
+      AcidUtils.TableSnapshot tableSnapshot;
+    }
+
+    Map<Path, PartitionDetails> partitionDetailsMap =
+            Collections.synchronizedMap(new LinkedHashMap<>());
+
+    // calculate full path spec for each valid partition path
+    validPartitions.forEach(partPath -> {
+      Map<String, String> fullPartSpec = Maps.newLinkedHashMap(partSpec);
+      if (!Warehouse.makeSpecFromName(fullPartSpec, partPath, new HashSet<>(partSpec.keySet()))) {
+        Utilities.FILE_OP_LOGGER.warn("Ignoring invalid DP directory " + partPath);
+      } else {
+        PartitionDetails details = new PartitionDetails();
+        details.fullSpec = fullPartSpec;
+        partitionDetailsMap.put(partPath, details);
+      }
+    });
+
+    // fetch all the partitions matching the part spec using the partition iterable
+    // this way the maximum batch size configuration parameter is considered
+    PartitionIterable partitionIterable = new PartitionIterable(Hive.get(), tbl, partSpec,
+              conf.getInt(MetastoreConf.ConfVars.BATCH_RETRIEVE_MAX.getVarname(), 300));
+    Iterator<Partition> iterator = partitionIterable.iterator();
+
+    // Match valid partition path to partitions
+    while (iterator.hasNext()) {
+      Partition partition = iterator.next();
+      partitionDetailsMap.entrySet().parallelStream()
+              .filter(entry -> entry.getValue().fullSpec.equals(partition.getSpec()))
+              .findAny().ifPresent(entry -> {
+                entry.getValue().partition = partition;
+                entry.getValue().hasOldPartition = true;
+              });
+    }
+
+    boolean isTxnTable = AcidUtils.isTransactionalTable(tbl);
+
+    for (Entry<Path, PartitionDetails> entry : partitionDetailsMap.entrySet()) {
+      tasks.add(() -> {
+        PartitionDetails partitionDetails = entry.getValue();
+        Map<String, String> fullPartSpec = partitionDetails.fullSpec;
+        try {
+
+          SessionState.setCurrentSessionState(parentSession);
+          LOG.info("New loading path = " + entry.getKey() + " withPartSpec " + fullPartSpec);
+
+          List<Path> newFiles = Lists.newArrayList();
+          Partition oldPartition = partitionDetails.partition;
+          // load the partition
+          Partition partition = loadPartitionInternal(entry.getKey(), tbl,
+                  fullPartSpec, oldPartition, loadFileType, true, false, numLB > 0, false, isAcid,
+                  hasFollowingStatsTask, writeId, stmtId, isInsertOverwrite, isTxnTable, newFiles);
+          // if the partition already existed before the loading, no need to add it again to the
+          // metastore
+
+          AcidUtils.TableSnapshot tableSnapshot = AcidUtils.getTableSnapshot(conf,
+                  partition.getTable(), true);
+          if (tableSnapshot != null) {
+            partition.getTPartition().setWriteId(tableSnapshot.getWriteId());
+          }
+          partitionDetails.tableSnapshot = tableSnapshot;
+          if (oldPartition == null) {
+            partitionDetails.newFiles = newFiles;
+            partitionDetails.partition = partition;
+          }
+
+          if (inPlaceEligible) {
+            synchronized (ps) {
+              InPlaceUpdate.rePositionCursor(ps);
+              partitionsLoaded.incrementAndGet();
+              InPlaceUpdate.reprintLine(ps, "Loaded : " + partitionsLoaded.get() + "/"
+                  + partsToLoad + " partitions.");
+            }
+          }
+
+          return partition;
+        } catch (Exception e) {
+          LOG.error("Exception when loading partition with parameters "
+                  + " partPath=" + entry.getKey() + ", "
                   + " table=" + tbl.getTableName() + ", "
                   + " partSpec=" + fullPartSpec + ", "
                   + " loadFileType=" + loadFileType.toString() + ", "
                   + " listBucketingLevel=" + numLB + ", "
                   + " isAcid=" + isAcid + ", "
-                  + " hasFollowingStatsTask=" + hasFollowingStatsTask, t);
-              throw t;
-            } finally {
-              // Add embedded rawstore, so we can cleanup later to avoid memory leak
-              if (getMSC().isLocalMetaStore()) {
-                Long threadId = Thread.currentThread().getId();
-                RawStore threadLocalRawStore = HiveMetaStore.HMSHandler.getRawStore();
-                if (threadLocalRawStore == null) {
-                  // If the thread local rawStore is already cleaned by current thread, then remove from rawStoreMap.
-                  rawStoreMap.remove(threadId);
-                } else {
-                  // If same thread is re-used, then need to cleanup the latest thread local instance of rawStore.
-                  // So, overwrite the old one if exists in rawStoreMap.
-                  rawStoreMap.put(threadId, threadLocalRawStore);
-                }
-              }
-            }
-          }
-        }));
-      }
-      pool.shutdown();
-      LOG.debug("Number of partitions to be added is " + futures.size());
+                  + " hasFollowingStatsTask=" + hasFollowingStatsTask, e);
+          throw e;
+        }
+      });
+    }
 
-      for (Future future : futures) {
-        future.get();
+    int poolSize = conf.getInt(ConfVars.HIVE_LOAD_DYNAMIC_PARTITIONS_THREAD_COUNT.varname, 1);
+    ExecutorService executor = Executors.newFixedThreadPool(poolSize,
+            new ThreadFactoryBuilder().setDaemon(true).setNameFormat("load-dynamic-partitionsToAdd-%d").build());
+
+    List<Future<Partition>> futures = Lists.newLinkedList();
+    Map<Map<String, String>, Partition> result = Maps.newLinkedHashMap();
+    try {
+      futures = executor.invokeAll(tasks);
+      LOG.debug("Number of partitionsToAdd to be added is " + futures.size());
+      for (Future<Partition> future : futures) {
+        Partition partition = future.get();
+        result.put(partition.getSpec(), partition);
+      }
+      // add new partitions in batch
+
+      addPartitionsToMetastore(
+              partitionDetailsMap.entrySet()
+                      .parallelStream()
+                      .filter(entry -> !entry.getValue().hasOldPartition)
+                      .map(entry -> entry.getValue().partition)
+                      .collect(Collectors.toList()),
+              hasFollowingStatsTask,
+              tbl,
+              partitionDetailsMap.entrySet()
+                      .parallelStream()
+                      .filter(entry -> !entry.getValue().hasOldPartition)
+                      .map(entry -> entry.getValue().tableSnapshot)
+                      .collect(Collectors.toList()));
+      // For acid table, add the acid_write event with file list at the time of load itself. But
+      // it should be done after partition is created.
+
+      for (Entry<Path, PartitionDetails> entry : partitionDetailsMap.entrySet()) {
+        PartitionDetails partitionDetails = entry.getValue();
+        if (isTxnTable && partitionDetails.newFiles != null) {
+          addWriteNotificationLog(tbl, partitionDetails.fullSpec, partitionDetails.newFiles, writeId);
+        }
+        if (partitionDetails.hasOldPartition) {
+          setStatsPropAndAlterPartition(hasFollowingStatsTask, tbl, partitionDetails.partition,
+                  partitionDetails.tableSnapshot);
+        }
       }
     } catch (InterruptedException | ExecutionException e) {
-      LOG.debug("Cancelling " + futures.size() + " dynamic loading tasks");
-      //cancel other futures
-      for (Future future : futures) {
-        future.cancel(true);
-      }
-      throw new HiveException("Exception when loading "
-          + partsToLoad + " in table " + tbl.getTableName()
-          + " with loadPath=" + loadPath, e);
+      throw new HiveException("Exception when loading " + validPartitions.size()
+              + " in table " + tbl.getTableName()
+              + " with loadPath=" + loadPath);
+    } catch (TException e) {
+      LOG.error(StringUtils.stringifyException(e));
+      throw new HiveException(e);
+    } catch (Exception e) {
+
+      StringBuffer logMsg = new StringBuffer();
+      logMsg.append("Exception when loading partitionsToAdd with parameters ");
+      logMsg.append("partPaths=");
+      validPartitions.forEach(path -> logMsg.append(path + ", "));
+      logMsg.append("table=" + tbl.getTableName() + ", ").
+              append("partSpec=" + partSpec + ", ").
+              append("loadFileType=" + loadFileType.toString() + ", ").
+              append("listBucketingLevel=" + numLB + ", ").
+              append("isAcid=" + isAcid + ", ").
+              append("hasFollowingStatsTask=" + hasFollowingStatsTask);
+
+      LOG.error(logMsg.toString(), e);
+      throw e;
     } finally {
-      rawStoreMap.forEach((k, rs) -> rs.shutdown());
+      LOG.debug("Cancelling " + futures.size() + " dynamic loading tasks");
+      executor.shutdownNow();
     }
 
     try {
       if (isAcid) {
-        List<String> partNames = new ArrayList<>(partitionsMap.size());
-        for (Partition p : partitionsMap.values()) {
-          partNames.add(p.getName());
-        }
+        List<String> partNames =
+                result.values().parallelStream().map(Partition::getName).collect(Collectors.toList());
         getMSC().addDynamicPartitions(parentSession.getTxnMgr().getCurrentTxnId(), writeId,
                 tbl.getDbName(), tbl.getTableName(), partNames,
                 AcidUtils.toDataOperationType(operation));
       }
-      LOG.info("Loaded " + partitionsMap.size() + " partitions");
+      LOG.info("Loaded " + result.size() + "partitionsToAdd");
 
       perfLogger.PerfLogEnd("MoveTask", PerfLogger.LOAD_DYNAMIC_PARTITIONS);
 
-      return partitionsMap;
+      return result;
     } catch (TException te) {
+      LOG.error(StringUtils.stringifyException(te));
       throw new HiveException("Exception updating metastore for acid table "
-          + tableName + " with partitions " + partitionsMap.values(), te);
+          + tableName + " with partitions " + result.values(), te);
     }
   }
 
@@ -3184,6 +3367,11 @@ private void constructOneLBLocationMap(FileStatus fSta,
     List<String> names = null;
     try {
       names = getMSC().listPartitionNames(dbName, tblName, max);
+    } catch (NoSuchObjectException nsoe) {
+      // this means no partition exists for the given dbName and tblName
+      // key value pairs - thrift cannot handle null return values, hence
+      // listPartitionNames() throws NoSuchObjectException to indicate null partitions
+      return Lists.newArrayList();
     } catch (Exception e) {
       LOG.error(StringUtils.stringifyException(e));
       throw new HiveException(e);
@@ -3200,6 +3388,11 @@ private void constructOneLBLocationMap(FileStatus fSta,
 
     try {
       names = getMSC().listPartitionNames(dbName, tblName, pvals, max);
+    } catch (NoSuchObjectException nsoe) {
+      // this means no partition exists for the given partition spec
+      // key value pairs - thrift cannot handle null return values, hence
+      // listPartitionNames() throws NoSuchObjectException to indicate null partitions
+      return Lists.newArrayList();
     } catch (Exception e) {
       LOG.error(StringUtils.stringifyException(e));
       throw new HiveException(e);

http://git-wip-us.apache.org/repos/asf/hive/blob/0d701546/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
index dd23d7d..322b580 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java
@@ -901,14 +901,23 @@ public class SessionHiveMetaStoreClient extends HiveMetaStoreClient implements I
       assertPartitioned();
       pTree.addPartition(p);
     }
+
     private Partition getPartition(String partName) throws MetaException {
       assertPartitioned();
       return pTree.getPartition(partName);
     }
+
+    private int addPartitions(List<Partition> partitions) throws AlreadyExistsException,
+            MetaException {
+      assertPartitioned();
+      return pTree.addPartitions(partitions);
+    }
+
     private List<Partition> getPartitions(List<String> partialPartVals) throws MetaException {
       assertPartitioned();
       return pTree.getPartitions(partialPartVals);
     }
+
     private void assertPartitioned() throws MetaException {
       if(tTable.getPartitionKeysSize() <= 0) {
         throw new MetaException(Warehouse.getQualifiedName(tTable) + " is not partitioned");
@@ -939,6 +948,17 @@ public class SessionHiveMetaStoreClient extends HiveMetaStoreClient implements I
       private Partition getPartition(String partName) {
         return parts.get(partName);
       }
+
+      private int addPartitions(List<Partition> partitions)
+              throws AlreadyExistsException, MetaException {
+        int partitionsAdded = 0;
+        for (Partition partition : partitions) {
+          addPartition(partition);
+          partitionsAdded++;
+        }
+        return partitionsAdded;
+      }
+
       /**
        * Provided values for the 1st N partition columns, will return all matching PartitionS
        * The list is a partial list of partition values in the same order as partition columns.
@@ -960,9 +980,7 @@ public class SessionHiveMetaStoreClient extends HiveMetaStoreClient implements I
     }
   }
   /**
-   * Loading Dynamic Partitons calls this.
-   * Hive.loadPartition() calls this which in turn can be called from Hive.loadDynamicPartitions()
-   * among others
+   * Hive.loadPartition() calls this.
    * @param partition
    *          The partition to add
    * @return the partition added
@@ -985,6 +1003,34 @@ public class SessionHiveMetaStoreClient extends HiveMetaStoreClient implements I
     tt.addPartition(deepCopy(partition));
     return partition;
   }
+
+  /**
+   * Loading Dynamic Partitions calls this. The partitions which are loaded, must belong to the
+   * same table.
+   * @param partitions the new partitions to be added, must be not null
+   * @return number of partitions that were added
+   * @throws TException
+   */
+  @Override
+  public int add_partitions(List<Partition> partitions) throws TException {
+    if (partitions.isEmpty()) {
+      return 0;
+    }
+    Partition partition = partitions.get(0);
+    org.apache.hadoop.hive.metastore.api.Table table =
+            getTempTable(partition.getDbName(), partition.getTableName());
+    if (table == null) {
+      // not a temp table - Try underlying client
+      return super.add_partitions(partitions);
+    }
+    TempTable tt = getTempTable(table);
+    if (tt == null) {
+      throw new IllegalStateException("TempTable not found for" +
+              table.getTableName());
+    }
+    return tt.addPartitions(deepCopyPartitions(partitions));
+  }
+
   /**
    * @param partialPvals partition values, can be partial.  This really means that missing values
    *                    are represented by empty str.

http://git-wip-us.apache.org/repos/asf/hive/blob/0d701546/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index aba63f0..90b5764 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -2468,7 +2468,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     return copy;
   }
 
-  private List<Partition> deepCopyPartitions(List<Partition> partitions) {
+  protected List<Partition> deepCopyPartitions(List<Partition> partitions) {
     return deepCopyPartitions(partitions, null);
   }
 


[10/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query66.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query66.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query66.q.out
new file mode 100644
index 0000000..f82272c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query66.q.out
@@ -0,0 +1,702 @@
+PREHOOK: query: explain
+select   
+         w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+        ,ship_carriers
+        ,year
+ 	,sum(jan_sales) as jan_sales
+ 	,sum(feb_sales) as feb_sales
+ 	,sum(mar_sales) as mar_sales
+ 	,sum(apr_sales) as apr_sales
+ 	,sum(may_sales) as may_sales
+ 	,sum(jun_sales) as jun_sales
+ 	,sum(jul_sales) as jul_sales
+ 	,sum(aug_sales) as aug_sales
+ 	,sum(sep_sales) as sep_sales
+ 	,sum(oct_sales) as oct_sales
+ 	,sum(nov_sales) as nov_sales
+ 	,sum(dec_sales) as dec_sales
+ 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
+ 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
+ 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
+ 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
+ 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
+ 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
+ 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
+ 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
+ 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
+ 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
+ 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
+ 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
+ 	,sum(jan_net) as jan_net
+ 	,sum(feb_net) as feb_net
+ 	,sum(mar_net) as mar_net
+ 	,sum(apr_net) as apr_net
+ 	,sum(may_net) as may_net
+ 	,sum(jun_net) as jun_net
+ 	,sum(jul_net) as jul_net
+ 	,sum(aug_net) as aug_net
+ 	,sum(sep_net) as sep_net
+ 	,sum(oct_net) as oct_net
+ 	,sum(nov_net) as nov_net
+ 	,sum(dec_net) as dec_net
+ from (
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then ws_sales_price* ws_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
+     from
+          web_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	  ,ship_mode
+     where
+            ws_warehouse_sk =  w_warehouse_sk
+        and ws_sold_date_sk = d_date_sk
+        and ws_sold_time_sk = t_time_sk
+ 	and ws_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 and 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+ 	)
+ union all
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
+     from
+          catalog_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	 ,ship_mode
+     where
+            cs_warehouse_sk =  w_warehouse_sk
+        and cs_sold_date_sk = d_date_sk
+        and cs_sold_time_sk = t_time_sk
+ 	and cs_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 AND 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+     ) 
+ ) x
+ group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,ship_carriers
+       ,year
+ order by w_warehouse_name
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@ship_mode
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@warehouse
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select   
+         w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+        ,ship_carriers
+        ,year
+ 	,sum(jan_sales) as jan_sales
+ 	,sum(feb_sales) as feb_sales
+ 	,sum(mar_sales) as mar_sales
+ 	,sum(apr_sales) as apr_sales
+ 	,sum(may_sales) as may_sales
+ 	,sum(jun_sales) as jun_sales
+ 	,sum(jul_sales) as jul_sales
+ 	,sum(aug_sales) as aug_sales
+ 	,sum(sep_sales) as sep_sales
+ 	,sum(oct_sales) as oct_sales
+ 	,sum(nov_sales) as nov_sales
+ 	,sum(dec_sales) as dec_sales
+ 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
+ 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
+ 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
+ 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
+ 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
+ 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
+ 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
+ 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
+ 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
+ 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
+ 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
+ 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
+ 	,sum(jan_net) as jan_net
+ 	,sum(feb_net) as feb_net
+ 	,sum(mar_net) as mar_net
+ 	,sum(apr_net) as apr_net
+ 	,sum(may_net) as may_net
+ 	,sum(jun_net) as jun_net
+ 	,sum(jul_net) as jul_net
+ 	,sum(aug_net) as aug_net
+ 	,sum(sep_net) as sep_net
+ 	,sum(oct_net) as oct_net
+ 	,sum(nov_net) as nov_net
+ 	,sum(dec_net) as dec_net
+ from (
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then ws_sales_price* ws_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
+     from
+          web_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	  ,ship_mode
+     where
+            ws_warehouse_sk =  w_warehouse_sk
+        and ws_sold_date_sk = d_date_sk
+        and ws_sold_time_sk = t_time_sk
+ 	and ws_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 and 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+ 	)
+ union all
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
+     from
+          catalog_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	 ,ship_mode
+     where
+            cs_warehouse_sk =  w_warehouse_sk
+        and cs_sold_date_sk = d_date_sk
+        and cs_sold_time_sk = t_time_sk
+ 	and cs_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 AND 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+     ) 
+ ) x
+ group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,ship_carriers
+       ,year
+ order by w_warehouse_name
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@ship_mode
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE), Reducer 19 (BROADCAST_EDGE), Reducer 22 (BROADCAST_EDGE)
+Map 25 <- Reducer 17 (BROADCAST_EDGE), Reducer 20 (BROADCAST_EDGE), Reducer 23 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 10 (SIMPLE_EDGE), Map 25 (SIMPLE_EDGE)
+Reducer 13 <- Map 18 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Map 21 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+Reducer 15 <- Map 24 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 17 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Map 18 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 20 <- Map 18 (CUSTOM_SIMPLE_EDGE)
+Reducer 22 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 23 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 18 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 21 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 24 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 8 <- Union 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 9 vectorized
+      File Output Operator [FS_267]
+        Select Operator [SEL_266] (rows=100 width=4614)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41","_col42","_col43"]
+          Limit [LIM_265] (rows=100 width=4510)
+            Number of rows:100
+            Select Operator [SEL_264] (rows=2423925 width=4510)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
+            <-Reducer 8 [SIMPLE_EDGE] vectorized
+              SHUFFLE [RS_263]
+                Group By Operator [GBY_262] (rows=2423925 width=4510)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)","sum(VALUE._col24)","sum(VALUE._col25)","sum(VALUE._col26)","sum(VALUE._col27)","sum(VALUE._col28)","sum(VALUE._col29)
 ","sum(VALUE._col30)","sum(VALUE._col31)","sum(VALUE._col32)","sum(VALUE._col33)","sum(VALUE._col34)","sum(VALUE._col35)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                <-Union 7 [SIMPLE_EDGE]
+                  <-Reducer 16 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_281]
+                      PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                      Group By Operator [GBY_280] (rows=2513727 width=4510)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)","sum(_col30)","sum(_col31)","sum(_col32)","sum(_col33)","sum(_col34)","sum(_col35)","sum(_col36)","sum(_col37)","sum(_col38)","sum(_col39)","sum(_col40)","sum(_col41)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                        Top N Key Operator [TNK_279] (rows=2513727 width=3166)
+                          keys:_col0, _col1, _col2, _col3, _col4, _col5,sort order:++++++,top n:100
+                          Select Operator [SEL_278] (rows=2513727 width=3166)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
+                            Group By Operator [GBY_277] (rows=2513700 width=3166)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                            <-Reducer 15 [SIMPLE_EDGE]
+                              SHUFFLE [RS_61]
+                                PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                Group By Operator [GBY_60] (rows=5559759 width=3166)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                  Select Operator [SEL_58] (rows=5559759 width=750)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
+                                    Merge Join Operator [MERGEJOIN_202] (rows=5559759 width=750)
+                                      Conds:RS_55._col3=RS_256._col0(Inner),Output:["_col4","_col5","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col22","_col23","_col24","_col25","_col26","_col27"]
+                                    <-Map 24 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_256]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_254] (rows=27 width=482)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                          TableScan [TS_12] (rows=27 width=482)
+                                            default@warehouse,warehouse,Tbl:COMPLETE,Col:COMPLETE,Output:["w_warehouse_sk","w_warehouse_name","w_warehouse_sq_ft","w_city","w_county","w_state","w_country"]
+                                    <-Reducer 14 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_55]
+                                        PartitionCols:_col3
+                                        Merge Join Operator [MERGEJOIN_201] (rows=5559759 width=274)
+                                          Conds:RS_52._col2=RS_243._col0(Inner),Output:["_col3","_col4","_col5","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19"]
+                                        <-Map 21 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_243]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_240] (rows=1 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_239] (rows=1 width=88)
+                                                predicate:(sm_carrier) IN ('DIAMOND', 'AIRBORNE')
+                                                TableScan [TS_9] (rows=1 width=88)
+                                                  default@ship_mode,ship_mode,Tbl:COMPLETE,Col:COMPLETE,Output:["sm_ship_mode_sk","sm_carrier"]
+                                        <-Reducer 13 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_52]
+                                            PartitionCols:_col2
+                                            Merge Join Operator [MERGEJOIN_200] (rows=11119518 width=278)
+                                              Conds:RS_49._col0=RS_231._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19"]
+                                            <-Map 18 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_231]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_228] (rows=652 width=52)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                  Filter Operator [FIL_227] (rows=652 width=12)
+                                                    predicate:(d_year = 2002)
+                                                    TableScan [TS_6] (rows=73049 width=12)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                            <-Reducer 12 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_49]
+                                                PartitionCols:_col0
+                                                Merge Join Operator [MERGEJOIN_199] (rows=31363607 width=235)
+                                                  Conds:RS_276._col1=RS_219._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5"]
+                                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_219]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_216] (rows=9600 width=4)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_215] (rows=9600 width=8)
+                                                        predicate:t_time BETWEEN 49530 AND 78330
+                                                        TableScan [TS_3] (rows=86400 width=8)
+                                                          default@time_dim,time_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["t_time_sk","t_time"]
+                                                <-Map 25 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_276]
+                                                    PartitionCols:_col1
+                                                    Select Operator [SEL_275] (rows=282272460 width=239)
+                                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                                      Filter Operator [FIL_274] (rows=282272460 width=243)
+                                                        predicate:((cs_ship_mode_sk BETWEEN DynamicValue(RS_53_ship_mode_sm_ship_mode_sk_min) AND DynamicValue(RS_53_ship_mode_sm_ship_mode_sk_max) and in_bloom_filter(cs_ship_mode_sk, DynamicValue(RS_53_ship_mode_sm_ship_mode_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_50_date_dim_d_date_sk_min) AND DynamicValue(RS_50_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_50_date_dim_d_date_sk_bloom_filter))) and (cs_sold_time_sk BETWEEN DynamicValue(RS_47_time_dim_t_time_sk_min) AND DynamicValue(RS_47_time_dim_t_time_sk_max) and in_bloom_filter(cs_sold_time_sk, DynamicValue(RS_47_time_dim_t_time_sk_bloom_filter))) and cs_ship_mode_sk is not null and cs_sold_date_sk is not null and cs_sold_time_sk is not null and cs_warehouse_sk is not null)
+                                                        TableScan [TS_32] (rows=287989836 width=243)
+                                                          default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_sold_time_sk","cs_ship_mode_sk","cs_warehouse_sk","cs_quantity","cs_ext_sales_price","cs_net_paid_inc_ship_tax"]
+                                                        <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_269]
+                                                            Group By Operator [GBY_268] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_224]
+                                                                Group By Operator [GBY_222] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_220] (rows=9600 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_216]
+                                                        <-Reducer 20 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_271]
+                                                            Group By Operator [GBY_270] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 18 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_236]
+                                                                Group By Operator [GBY_234] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_232] (rows=652 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_228]
+                                                        <-Reducer 23 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_273]
+                                                            Group By Operator [GBY_272] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_248]
+                                                                Group By Operator [GBY_246] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_244] (rows=1 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_240]
+                  <-Reducer 6 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_261]
+                      PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                      Group By Operator [GBY_260] (rows=2513727 width=4510)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)","sum(_col30)","sum(_col31)","sum(_col32)","sum(_col33)","sum(_col34)","sum(_col35)","sum(_col36)","sum(_col37)","sum(_col38)","sum(_col39)","sum(_col40)","sum(_col41)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                        Top N Key Operator [TNK_259] (rows=2513727 width=3166)
+                          keys:_col0, _col1, _col2, _col3, _col4, _col5,sort order:++++++,top n:100
+                          Select Operator [SEL_258] (rows=2513727 width=3166)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29","_col30","_col31","_col32","_col33","_col34","_col35","_col36","_col37","_col38","_col39","_col40","_col41"]
+                            Group By Operator [GBY_257] (rows=27 width=3166)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","sum(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)","sum(VALUE._col12)","sum(VALUE._col13)","sum(VALUE._col14)","sum(VALUE._col15)","sum(VALUE._col16)","sum(VALUE._col17)","sum(VALUE._col18)","sum(VALUE._col19)","sum(VALUE._col20)","sum(VALUE._col21)","sum(VALUE._col22)","sum(VALUE._col23)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                            <-Reducer 5 [SIMPLE_EDGE]
+                              SHUFFLE [RS_29]
+                                PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                Group By Operator [GBY_28] (rows=27 width=3166)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)","sum(_col9)","sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)","sum(_col15)","sum(_col16)","sum(_col17)","sum(_col18)","sum(_col19)","sum(_col20)","sum(_col21)","sum(_col22)","sum(_col23)","sum(_col24)","sum(_col25)","sum(_col26)","sum(_col27)","sum(_col28)","sum(_col29)"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                  Select Operator [SEL_26] (rows=2853684 width=750)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20","_col21","_col22","_col23","_col24","_col25","_col26","_col27","_col28","_col29"]
+                                    Merge Join Operator [MERGEJOIN_198] (rows=2853684 width=750)
+                                      Conds:RS_23._col3=RS_255._col0(Inner),Output:["_col4","_col5","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col22","_col23","_col24","_col25","_col26","_col27"]
+                                    <-Map 24 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_255]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_254]
+                                    <-Reducer 4 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_23]
+                                        PartitionCols:_col3
+                                        Merge Join Operator [MERGEJOIN_197] (rows=2853684 width=275)
+                                          Conds:RS_20._col2=RS_241._col0(Inner),Output:["_col3","_col4","_col5","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19"]
+                                        <-Map 21 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_241]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_240]
+                                        <-Reducer 3 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_20]
+                                            PartitionCols:_col2
+                                            Merge Join Operator [MERGEJOIN_196] (rows=5707369 width=279)
+                                              Conds:RS_17._col0=RS_229._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19"]
+                                            <-Map 18 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_229]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_228]
+                                            <-Reducer 2 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_17]
+                                                PartitionCols:_col0
+                                                Merge Join Operator [MERGEJOIN_195] (rows=15984351 width=235)
+                                                  Conds:RS_253._col1=RS_217._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5"]
+                                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_217]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_216]
+                                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_253]
+                                                    PartitionCols:_col1
+                                                    Select Operator [SEL_252] (rows=143859154 width=239)
+                                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                                      Filter Operator [FIL_251] (rows=143859154 width=243)
+                                                        predicate:((ws_ship_mode_sk BETWEEN DynamicValue(RS_21_ship_mode_sm_ship_mode_sk_min) AND DynamicValue(RS_21_ship_mode_sm_ship_mode_sk_max) and in_bloom_filter(ws_ship_mode_sk, DynamicValue(RS_21_ship_mode_sm_ship_mode_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_18_date_dim_d_date_sk_min) AND DynamicValue(RS_18_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_18_date_dim_d_date_sk_bloom_filter))) and (ws_sold_time_sk BETWEEN DynamicValue(RS_15_time_dim_t_time_sk_min) AND DynamicValue(RS_15_time_dim_t_time_sk_max) and in_bloom_filter(ws_sold_time_sk, DynamicValue(RS_15_time_dim_t_time_sk_bloom_filter))) and ws_ship_mode_sk is not null and ws_sold_date_sk is not null and ws_sold_time_sk is not null and ws_warehouse_sk is not null)
+                                                        TableScan [TS_0] (rows=144002668 width=243)
+                                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_sold_time_sk","ws_ship_mode_sk","ws_warehouse_sk","ws_quantity","ws_sales_price","ws_net_paid_inc_tax"]
+                                                        <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_226]
+                                                            Group By Operator [GBY_225] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_223]
+                                                                Group By Operator [GBY_221] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_218] (rows=9600 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_216]
+                                                        <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_238]
+                                                            Group By Operator [GBY_237] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 18 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_235]
+                                                                Group By Operator [GBY_233] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_230] (rows=652 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_228]
+                                                        <-Reducer 22 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_250]
+                                                            Group By Operator [GBY_249] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_247]
+                                                                Group By Operator [GBY_245] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_242] (rows=1 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_240]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query67.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query67.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query67.q.out
new file mode 100644
index 0000000..7abc959
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query67.q.out
@@ -0,0 +1,196 @@
+PREHOOK: query: explain
+select  *
+from (select i_category
+            ,i_class
+            ,i_brand
+            ,i_product_name
+            ,d_year
+            ,d_qoy
+            ,d_moy
+            ,s_store_id
+            ,sumsales
+            ,rank() over (partition by i_category order by sumsales desc) rk
+      from (select i_category
+                  ,i_class
+                  ,i_brand
+                  ,i_product_name
+                  ,d_year
+                  ,d_qoy
+                  ,d_moy
+                  ,s_store_id
+                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
+            from store_sales
+                ,date_dim
+                ,store
+                ,item
+       where  ss_sold_date_sk=d_date_sk
+          and ss_item_sk=i_item_sk
+          and ss_store_sk = s_store_sk
+          and d_month_seq between 1212 and 1212+11
+       group by  rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
+where rk <= 100
+order by i_category
+        ,i_class
+        ,i_brand
+        ,i_product_name
+        ,d_year
+        ,d_qoy
+        ,d_moy
+        ,s_store_id
+        ,sumsales
+        ,rk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  *
+from (select i_category
+            ,i_class
+            ,i_brand
+            ,i_product_name
+            ,d_year
+            ,d_qoy
+            ,d_moy
+            ,s_store_id
+            ,sumsales
+            ,rank() over (partition by i_category order by sumsales desc) rk
+      from (select i_category
+                  ,i_class
+                  ,i_brand
+                  ,i_product_name
+                  ,d_year
+                  ,d_qoy
+                  ,d_moy
+                  ,s_store_id
+                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
+            from store_sales
+                ,date_dim
+                ,store
+                ,item
+       where  ss_sold_date_sk=d_date_sk
+          and ss_item_sk=i_item_sk
+          and ss_store_sk = s_store_sk
+          and d_month_seq between 1212 and 1212+11
+       group by  rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
+where rk <= 100
+order by i_category
+        ,i_class
+        ,i_brand
+        ,i_product_name
+        ,d_year
+        ,d_qoy
+        ,d_moy
+        ,s_store_id
+        ,sumsales
+        ,rk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 11 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_107]
+        Limit [LIM_106] (rows=100 width=617)
+          Number of rows:100
+          Select Operator [SEL_105] (rows=273593580 width=617)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_104]
+              Select Operator [SEL_103] (rows=273593580 width=617)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+                Filter Operator [FIL_102] (rows=273593580 width=613)
+                  predicate:(rank_window_0 <= 100)
+                  PTF Operator [PTF_101] (rows=820780740 width=613)
+                    Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col8 DESC NULLS LAST","partition by:":"_col2"}]
+                    Select Operator [SEL_100] (rows=820780740 width=613)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                    <-Reducer 5 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_99]
+                        PartitionCols:_col2
+                        Select Operator [SEL_98] (rows=820780740 width=613)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                          Group By Operator [GBY_97] (rows=820780740 width=621)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8
+                          <-Reducer 4 [SIMPLE_EDGE]
+                            SHUFFLE [RS_21]
+                              PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8
+                              Group By Operator [GBY_20] (rows=820780740 width=621)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(_col3)"],keys:_col11, _col12, _col13, _col14, _col5, _col6, _col7, _col9, 0L
+                                Merge Join Operator [MERGEJOIN_81] (rows=91197860 width=613)
+                                  Conds:RS_16._col1=RS_96._col0(Inner),Output:["_col3","_col5","_col6","_col7","_col9","_col11","_col12","_col13","_col14"]
+                                <-Map 11 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_96]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_95] (rows=462000 width=393)
+                                      Output:["_col0","_col1","_col2","_col3","_col4"]
+                                      TableScan [TS_8] (rows=462000 width=393)
+                                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand","i_class","i_category","i_product_name"]
+                                <-Reducer 3 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_16]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_80] (rows=91197860 width=228)
+                                      Conds:RS_13._col2=RS_94._col0(Inner),Output:["_col1","_col3","_col5","_col6","_col7","_col9"]
+                                    <-Map 10 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_94]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_93] (rows=1704 width=104)
+                                          Output:["_col0","_col1"]
+                                          TableScan [TS_6] (rows=1704 width=104)
+                                            default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id"]
+                                    <-Reducer 2 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_13]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_79] (rows=91197860 width=130)
+                                          Conds:RS_92._col0=RS_84._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col7"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_84]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_83] (rows=317 width=16)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_82] (rows=317 width=20)
+                                                predicate:d_month_seq BETWEEN 1212 AND 1223
+                                                TableScan [TS_3] (rows=73049 width=20)
+                                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq","d_year","d_moy","d_qoy"]
+                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_92]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_91] (rows=525329897 width=123)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_90] (rows=525329897 width=122)
+                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_11_date_dim_d_date_sk_min) AND DynamicValue(RS_11_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_11_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_0] (rows=575995635 width=122)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_quantity","ss_sales_price"]
+                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_89]
+                                                    Group By Operator [GBY_88] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_87]
+                                                        Group By Operator [GBY_86] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_85] (rows=317 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_83]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query68.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query68.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query68.q.out
new file mode 100644
index 0000000..2188af5
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query68.q.out
@@ -0,0 +1,254 @@
+PREHOOK: query: explain
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,extended_price
+       ,extended_tax
+       ,list_price
+ from (select ss_ticket_number
+             ,ss_customer_sk
+             ,ca_city bought_city
+             ,sum(ss_ext_sales_price) extended_price 
+             ,sum(ss_ext_list_price) list_price
+             ,sum(ss_ext_tax) extended_tax 
+       from store_sales
+           ,date_dim
+           ,store
+           ,household_demographics
+           ,customer_address 
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_store_sk = store.s_store_sk  
+        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+        and store_sales.ss_addr_sk = customer_address.ca_address_sk
+        and date_dim.d_dom between 1 and 2 
+        and (household_demographics.hd_dep_count = 2 or
+             household_demographics.hd_vehicle_count= 1)
+        and date_dim.d_year in (1998,1998+1,1998+2)
+        and store.s_city in ('Cedar Grove','Wildwood')
+       group by ss_ticket_number
+               ,ss_customer_sk
+               ,ss_addr_sk,ca_city) dn
+      ,customer
+      ,customer_address current_addr
+ where ss_customer_sk = c_customer_sk
+   and customer.c_current_addr_sk = current_addr.ca_address_sk
+   and current_addr.ca_city <> bought_city
+ order by c_last_name
+         ,ss_ticket_number
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,extended_price
+       ,extended_tax
+       ,list_price
+ from (select ss_ticket_number
+             ,ss_customer_sk
+             ,ca_city bought_city
+             ,sum(ss_ext_sales_price) extended_price 
+             ,sum(ss_ext_list_price) list_price
+             ,sum(ss_ext_tax) extended_tax 
+       from store_sales
+           ,date_dim
+           ,store
+           ,household_demographics
+           ,customer_address 
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_store_sk = store.s_store_sk  
+        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+        and store_sales.ss_addr_sk = customer_address.ca_address_sk
+        and date_dim.d_dom between 1 and 2 
+        and (household_demographics.hd_dep_count = 2 or
+             household_demographics.hd_vehicle_count= 1)
+        and date_dim.d_year in (1998,1998+1,1998+2)
+        and store.s_city in ('Cedar Grove','Wildwood')
+       group by ss_ticket_number
+               ,ss_customer_sk
+               ,ss_addr_sk,ca_city) dn
+      ,customer
+      ,customer_address current_addr
+ where ss_customer_sk = c_customer_sk
+   and customer.c_current_addr_sk = current_addr.ca_address_sk
+   and current_addr.ca_city <> bought_city
+ order by c_last_name
+         ,ss_ticket_number
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 8 <- Reducer 13 (BROADCAST_EDGE), Reducer 15 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Reducer 10 <- Map 14 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 16 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 14 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 5 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 6 <- Map 5 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 12 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4 vectorized
+      File Output Operator [FS_182]
+        Limit [LIM_181] (rows=100 width=706)
+          Number of rows:100
+          Select Operator [SEL_180] (rows=4418634 width=706)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 3 [SIMPLE_EDGE]
+            SHUFFLE [RS_44]
+              Select Operator [SEL_43] (rows=4418634 width=706)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                Filter Operator [FIL_42] (rows=4418634 width=706)
+                  predicate:(_col5 <> _col8)
+                  Merge Join Operator [MERGEJOIN_143] (rows=4418634 width=706)
+                    Conds:RS_39._col0=RS_179._col1(Inner),Output:["_col2","_col3","_col5","_col6","_col8","_col9","_col10","_col11"]
+                  <-Reducer 2 [SIMPLE_EDGE]
+                    SHUFFLE [RS_39]
+                      PartitionCols:_col0
+                      Merge Join Operator [MERGEJOIN_138] (rows=80000000 width=277)
+                        Conds:RS_146._col1=RS_148._col0(Inner),Output:["_col0","_col2","_col3","_col5"]
+                      <-Map 5 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_148]
+                          PartitionCols:_col0
+                          Select Operator [SEL_147] (rows=40000000 width=97)
+                            Output:["_col0","_col1"]
+                            TableScan [TS_3] (rows=40000000 width=97)
+                              default@customer_address,current_addr,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_city"]
+                      <-Map 1 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_146]
+                          PartitionCols:_col1
+                          Select Operator [SEL_145] (rows=80000000 width=188)
+                            Output:["_col0","_col1","_col2","_col3"]
+                            Filter Operator [FIL_144] (rows=80000000 width=188)
+                              predicate:c_current_addr_sk is not null
+                              TableScan [TS_0] (rows=80000000 width=188)
+                                default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk","c_first_name","c_last_name"]
+                  <-Reducer 7 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_179]
+                      PartitionCols:_col1
+                      Select Operator [SEL_178] (rows=4418634 width=433)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                        Group By Operator [GBY_177] (rows=4418634 width=433)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+                        <-Reducer 6 [SIMPLE_EDGE]
+                          SHUFFLE [RS_33]
+                            PartitionCols:_col0, _col1, _col2, _col3
+                            Group By Operator [GBY_32] (rows=4418634 width=433)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col6)","sum(_col7)","sum(_col8)"],keys:_col1, _col13, _col3, _col5
+                              Merge Join Operator [MERGEJOIN_142] (rows=4418634 width=97)
+                                Conds:RS_28._col3=RS_149._col0(Inner),Output:["_col1","_col3","_col5","_col6","_col7","_col8","_col13"]
+                              <-Map 5 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_149]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select Operator [SEL_147]
+                              <-Reducer 11 [SIMPLE_EDGE]
+                                SHUFFLE [RS_28]
+                                  PartitionCols:_col3
+                                  Merge Join Operator [MERGEJOIN_141] (rows=4418634 width=4)
+                                    Conds:RS_25._col2=RS_168._col0(Inner),Output:["_col1","_col3","_col5","_col6","_col7","_col8"]
+                                  <-Map 16 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_168]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_167] (rows=1855 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_166] (rows=1855 width=12)
+                                          predicate:((hd_dep_count = 2) or (hd_vehicle_count = 1))
+                                          TableScan [TS_14] (rows=7200 width=12)
+                                            default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_dep_count","hd_vehicle_count"]
+                                  <-Reducer 10 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_25]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_140] (rows=17150490 width=4)
+                                        Conds:RS_22._col4=RS_160._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col7","_col8"]
+                                      <-Map 14 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_160]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_159] (rows=85 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_158] (rows=85 width=97)
+                                              predicate:(s_city) IN ('Cedar Grove', 'Wildwood')
+                                              TableScan [TS_11] (rows=1704 width=97)
+                                                default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_city"]
+                                      <-Reducer 9 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_22]
+                                          PartitionCols:_col4
+                                          Merge Join Operator [MERGEJOIN_139] (rows=42598570 width=185)
+                                            Conds:RS_176._col0=RS_152._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                          <-Map 12 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_152]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_151] (rows=170 width=4)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_150] (rows=170 width=12)
+                                                  predicate:((d_year) IN (1998, 1999, 2000) and d_dom BETWEEN 1 AND 2)
+                                                  TableScan [TS_8] (rows=73049 width=12)
+                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_dom"]
+                                          <-Map 8 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_176]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_175] (rows=457565061 width=343)
+                                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                                Filter Operator [FIL_174] (rows=457565061 width=343)
+                                                  predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_26_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_26_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_26_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_20_date_dim_d_date_sk_min) AND DynamicValue(RS_20_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_20_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_23_store_s_store_sk_min) AND DynamicValue(RS_23_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_23_store_s_store_sk_bloom_filter))) and ss_addr_sk is not null and ss_customer_sk is not null and ss_hdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                  TableScan [TS_5] (rows=575995635 width=343)
+                                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_hdemo_sk","ss_addr_sk","ss_store_sk","ss_ticket_number","ss_ext_sales_price","ss_ext_list_price","ss_ext_tax"]
+                                                  <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_157]
+                                                      Group By Operator [GBY_156] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_155]
+                                                          Group By Operator [GBY_154] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_153] (rows=170 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_151]
+                                                  <-Reducer 15 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_165]
+                                                      Group By Operator [GBY_164] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 14 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_163]
+                                                          Group By Operator [GBY_162] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_161] (rows=85 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_159]
+                                                  <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_173]
+                                                      Group By Operator [GBY_172] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_171]
+                                                          Group By Operator [GBY_170] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_169] (rows=1855 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_167]
+


[40/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query70.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query70.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query70.q.out
new file mode 100644
index 0000000..aa04df8
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query70.q.out
@@ -0,0 +1,119 @@
+PREHOOK: query: explain cbo
+select  
+    sum(ss_net_profit) as total_sum
+   ,s_state
+   ,s_county
+   ,grouping(s_state)+grouping(s_county) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(s_state)+grouping(s_county),
+ 	case when grouping(s_county) = 0 then s_state end 
+ 	order by sum(ss_net_profit) desc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,store
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ss_sold_date_sk
+ and s_store_sk  = ss_store_sk
+ and s_state in
+             ( select s_state
+               from  (select s_state as s_state,
+ 			    rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
+                      from   store_sales, store, date_dim
+                      where  d_month_seq between 1212 and 1212+11
+ 			    and d_date_sk = ss_sold_date_sk
+ 			    and s_store_sk  = ss_store_sk
+                      group by s_state
+                     ) tmp1 
+               where ranking <= 5
+             )
+ group by rollup(s_state,s_county)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then s_state end
+  ,rank_within_parent
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+    sum(ss_net_profit) as total_sum
+   ,s_state
+   ,s_county
+   ,grouping(s_state)+grouping(s_county) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(s_state)+grouping(s_county),
+ 	case when grouping(s_county) = 0 then s_state end 
+ 	order by sum(ss_net_profit) desc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,store
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ss_sold_date_sk
+ and s_store_sk  = ss_store_sk
+ and s_state in
+             ( select s_state
+               from  (select s_state as s_state,
+ 			    rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
+                      from   store_sales, store, date_dim
+                      where  d_month_seq between 1212 and 1212+11
+ 			    and d_date_sk = ss_sold_date_sk
+ 			    and s_store_sk  = ss_store_sk
+                      group by s_state
+                     ) tmp1 
+               where ranking <= 5
+             )
+ group by rollup(s_state,s_county)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then s_state end
+  ,rank_within_parent
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(total_sum=[$0], s_state=[$1], s_county=[$2], lochierarchy=[$3], rank_within_parent=[$4])
+  HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(total_sum=[$2], s_state=[$0], s_county=[$1], lochierarchy=[+(grouping($3, 1), grouping($3, 0))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($3, 1), grouping($3, 0)), CASE(=(grouping($3, 0), 0), $0, null) ORDER BY $2 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok_table_or_col s_state))=[CASE(=(+(grouping($3, 1), grouping($3, 0)), 0), $0, null)])
+      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], GROUPING__ID=[$3])
+        HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], GROUPING__ID=[GROUPING__ID()])
+          HiveProject($f0=[$7], $f1=[$6], $f2=[$2])
+            HiveJoin(condition=[=($7, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                    HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                HiveProject(s_store_sk=[$0], s_county=[$23], s_state=[$24])
+                  HiveFilter(condition=[AND(IS NOT NULL($24), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(s_state=[$0])
+                HiveFilter(condition=[<=($1, 5)])
+                  HiveProject((tok_table_or_col s_state)=[$0], rank_window_0=[$1])
+                    HiveProject((tok_table_or_col s_state)=[$0], rank_window_0=[rank() OVER (PARTITION BY $0 ORDER BY $1 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], window_col_0=[$1])
+                      HiveProject(s_state=[$0], $f1=[$1])
+                        HiveAggregate(group=[{6}], agg#0=[sum($2)])
+                          HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_net_profit=[$22])
+                                HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                              HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                                HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                            HiveProject(s_store_sk=[$0], s_state=[$24])
+                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($24))])
+                                HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out
new file mode 100644
index 0000000..4e52893
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query71.q.out
@@ -0,0 +1,130 @@
+PREHOOK: query: explain cbo
+select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
+ 	sum(ext_price) ext_price
+ from item, (select ws_ext_sales_price as ext_price, 
+                        ws_sold_date_sk as sold_date_sk,
+                        ws_item_sk as sold_item_sk,
+                        ws_sold_time_sk as time_sk  
+                 from web_sales,date_dim
+                 where d_date_sk = ws_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select cs_ext_sales_price as ext_price,
+                        cs_sold_date_sk as sold_date_sk,
+                        cs_item_sk as sold_item_sk,
+                        cs_sold_time_sk as time_sk
+                 from catalog_sales,date_dim
+                 where d_date_sk = cs_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select ss_ext_sales_price as ext_price,
+                        ss_sold_date_sk as sold_date_sk,
+                        ss_item_sk as sold_item_sk,
+                        ss_sold_time_sk as time_sk
+                 from store_sales,date_dim
+                 where d_date_sk = ss_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 ) as tmp,time_dim
+ where
+   sold_item_sk = i_item_sk
+   and i_manager_id=1
+   and time_sk = t_time_sk
+   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
+ group by i_brand, i_brand_id,t_hour,t_minute
+ order by ext_price desc, i_brand_id
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
+ 	sum(ext_price) ext_price
+ from item, (select ws_ext_sales_price as ext_price, 
+                        ws_sold_date_sk as sold_date_sk,
+                        ws_item_sk as sold_item_sk,
+                        ws_sold_time_sk as time_sk  
+                 from web_sales,date_dim
+                 where d_date_sk = ws_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select cs_ext_sales_price as ext_price,
+                        cs_sold_date_sk as sold_date_sk,
+                        cs_item_sk as sold_item_sk,
+                        cs_sold_time_sk as time_sk
+                 from catalog_sales,date_dim
+                 where d_date_sk = cs_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select ss_ext_sales_price as ext_price,
+                        ss_sold_date_sk as sold_date_sk,
+                        ss_item_sk as sold_item_sk,
+                        ss_sold_time_sk as time_sk
+                 from store_sales,date_dim
+                 where d_date_sk = ss_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 ) as tmp,time_dim
+ where
+   sold_item_sk = i_item_sk
+   and i_manager_id=1
+   and time_sk = t_time_sk
+   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
+ group by i_brand, i_brand_id,t_hour,t_minute
+ order by ext_price desc, i_brand_id
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(brand_id=[$0], brand=[$1], t_hour=[$2], t_minute=[$3], ext_price=[$4])
+  HiveSortLimit(sort0=[$4], sort1=[$5], dir0=[DESC-nulls-last], dir1=[ASC])
+    HiveProject(brand_id=[$2], brand=[$3], t_hour=[$0], t_minute=[$1], ext_price=[$4], (tok_table_or_col i_brand_id)=[$2])
+      HiveAggregate(group=[{1, 2, 8, 9}], agg#0=[sum($4)])
+        HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(t_time_sk=[$0], t_hour=[$3], t_minute=[$4], t_meal_time=[$9])
+            HiveFilter(condition=[AND(IN($9, _UTF-16LE'breakfast', _UTF-16LE'dinner'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+          HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ext_price=[$0], sold_item_sk=[$1], time_sk=[$2])
+              HiveUnion(all=[true])
+                HiveProject(ext_price=[$3], sold_item_sk=[$2], time_sk=[$1])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_sold_time_sk=[$1], ws_item_sk=[$3], ws_ext_sales_price=[$23])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER], d_moy=[CAST(12):INTEGER])
+                      HiveFilter(condition=[AND(=($8, 12), =($6, 2001), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(ext_price=[$3], sold_item_sk=[$2], time_sk=[$1])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cs_sold_date_sk=[$0], cs_sold_time_sk=[$1], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($15), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER], d_moy=[CAST(12):INTEGER])
+                      HiveFilter(condition=[AND(=($8, 12), =($6, 2001), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(ext_price=[$3], sold_item_sk=[$2], time_sk=[$1])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_sold_time_sk=[$1], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER], d_moy=[CAST(12):INTEGER])
+                      HiveFilter(condition=[AND(=($8, 12), =($6, 2001), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8], i_manager_id=[CAST(1):INTEGER])
+              HiveFilter(condition=[AND(=($20, 1), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query72.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query72.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query72.q.out
new file mode 100644
index 0000000..fca31ef
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query72.q.out
@@ -0,0 +1,130 @@
+PREHOOK: query: explain cbo
+select  i_item_desc
+      ,w_warehouse_name
+      ,d1.d_week_seq
+      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
+      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
+      ,count(*) total_cnt
+from catalog_sales
+join inventory on (cs_item_sk = inv_item_sk)
+join warehouse on (w_warehouse_sk=inv_warehouse_sk)
+join item on (i_item_sk = cs_item_sk)
+join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk)
+join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk)
+join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk)
+join date_dim d2 on (inv_date_sk = d2.d_date_sk)
+join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk)
+left outer join promotion on (cs_promo_sk=p_promo_sk)
+left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number)
+where d1.d_week_seq = d2.d_week_seq
+  and inv_quantity_on_hand < cs_quantity 
+  and d3.d_date > d1.d_date + 5
+  and hd_buy_potential = '1001-5000'
+  and d1.d_year = 2001
+  and hd_buy_potential = '1001-5000'
+  and cd_marital_status = 'M'
+  and d1.d_year = 2001
+group by i_item_desc,w_warehouse_name,d1.d_week_seq
+order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_desc
+      ,w_warehouse_name
+      ,d1.d_week_seq
+      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
+      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
+      ,count(*) total_cnt
+from catalog_sales
+join inventory on (cs_item_sk = inv_item_sk)
+join warehouse on (w_warehouse_sk=inv_warehouse_sk)
+join item on (i_item_sk = cs_item_sk)
+join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk)
+join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk)
+join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk)
+join date_dim d2 on (inv_date_sk = d2.d_date_sk)
+join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk)
+left outer join promotion on (cs_promo_sk=p_promo_sk)
+left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number)
+where d1.d_week_seq = d2.d_week_seq
+  and inv_quantity_on_hand < cs_quantity 
+  and d3.d_date > d1.d_date + 5
+  and hd_buy_potential = '1001-5000'
+  and d1.d_year = 2001
+  and hd_buy_potential = '1001-5000'
+  and cd_marital_status = 'M'
+  and d1.d_year = 2001
+group by i_item_desc,w_warehouse_name,d1.d_week_seq
+order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$5], sort1=[$0], sort2=[$1], sort3=[$2], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5])
+    HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)], agg#1=[count($4)], agg#2=[count()])
+      HiveProject($f0=[$15], $f1=[$13], $f2=[$22], $f3=[CASE(IS NULL($28), 1, 0)], $f4=[CASE(IS NOT NULL($28), 1, 0)])
+        HiveJoin(condition=[AND(=($29, $4), =($30, $6))], joinType=[left], algorithm=[none], cost=[not available])
+          HiveProject(cs_sold_date_sk=[$10], cs_ship_date_sk=[$11], cs_bill_cdemo_sk=[$12], cs_bill_hdemo_sk=[$13], cs_item_sk=[$14], cs_promo_sk=[$15], cs_order_number=[$16], cs_quantity=[$17], inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3], w_warehouse_sk=[$4], w_warehouse_name=[$5], i_item_sk=[$8], i_item_desc=[$9], cd_demo_sk=[$22], cd_marital_status=[$23], hd_demo_sk=[$24], hd_buy_potential=[$25], d_date_sk=[$18], d_date=[$19], d_week_seq=[$20], d_year=[$21], d_date_sk0=[$27], d_week_seq0=[$28], d_date_sk1=[$6], d_date0=[$7], p_promo_sk=[$26])
+            HiveJoin(condition=[AND(=($0, $27), =($20, $28))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[AND(=($14, $1), <($3, $17))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($4, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3])
+                    HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($2), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                  HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+                HiveProject(d_date_sk=[$0], d_date=[$1], i_item_sk=[$2], i_item_desc=[$3], cs_sold_date_sk=[$4], cs_ship_date_sk=[$5], cs_bill_cdemo_sk=[$6], cs_bill_hdemo_sk=[$7], cs_item_sk=[$8], cs_promo_sk=[$9], cs_order_number=[$10], cs_quantity=[$11], d_date_sk0=[$12], d_date0=[$13], d_week_seq=[$14], d_year=[$15], cd_demo_sk=[$16], cd_marital_status=[$17], hd_demo_sk=[$18], hd_buy_potential=[$19], p_promo_sk=[$20])
+                  HiveJoin(condition=[AND(=($5, $0), >(CAST($1):DOUBLE, +(CAST($13):DOUBLE, 5)))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(d_date_sk=[$0], d_date=[$2])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_item_desc=[$4])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($5, $16)], joinType=[left], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($3, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($2, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(cs_sold_date_sk=[$0], cs_ship_date_sk=[$2], cs_bill_cdemo_sk=[$4], cs_bill_hdemo_sk=[$5], cs_item_sk=[$15], cs_promo_sk=[$16], cs_order_number=[$17], cs_quantity=[$18])
+                                HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($4), IS NOT NULL($5), IS NOT NULL($0), IS NOT NULL($2))])
+                                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                              HiveProject(d_date_sk=[$0], d_date=[$2], d_week_seq=[$4], d_year=[CAST(2001):INTEGER])
+                                HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0), IS NOT NULL($4))])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                            HiveProject(cd_demo_sk=[$0], cd_marital_status=[CAST(_UTF-16LE'M'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                              HiveFilter(condition=[AND(=($2, _UTF-16LE'M'), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+                          HiveProject(hd_demo_sk=[$0], hd_buy_potential=[CAST(_UTF-16LE'1001-5000'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                            HiveFilter(condition=[AND(=($2, _UTF-16LE'1001-5000'), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                        HiveProject(p_promo_sk=[$0])
+                          HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+              HiveProject(d_date_sk=[$0], d_week_seq=[$4])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+          HiveProject(cr_item_sk=[$2], cr_order_number=[$16])
+            HiveFilter(condition=[IS NOT NULL($2)])
+              HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out
new file mode 100644
index 0000000..d28a896
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query73.q.out
@@ -0,0 +1,93 @@
+PREHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag 
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and date_dim.d_dom between 1 and 2 
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and case when household_demographics.hd_vehicle_count > 0 then 
+             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County')
+    group by ss_ticket_number,ss_customer_sk) dj,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 1 and 5
+    order by cnt desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag 
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and date_dim.d_dom between 1 and 2 
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and case when household_demographics.hd_vehicle_count > 0 then 
+             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County')
+    group by ss_ticket_number,ss_customer_sk) dj,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 1 and 5
+    order by cnt desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$5], dir0=[DESC-nulls-last])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], c_salutation=[$1], c_preferred_cust_flag=[$4], ss_ticket_number=[$5], cnt=[$7])
+    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(c_customer_sk=[$0], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10])
+        HiveFilter(condition=[IS NOT NULL($0)])
+          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+      HiveProject(ss_ticket_number=[$0], ss_customer_sk=[$1], $f2=[$2])
+        HiveFilter(condition=[BETWEEN(false, $2, 1, 5)])
+          HiveProject(ss_ticket_number=[$1], ss_customer_sk=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 4}], agg#0=[count()])
+              HiveJoin(condition=[=($3, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_store_sk=[$7], ss_ticket_number=[$9])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($3))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[$6], d_dom=[$9])
+                      HiveFilter(condition=[AND(IN($6, 2000, 2001, 2002), BETWEEN(false, $9, 1, 2), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(hd_demo_sk=[$0], hd_buy_potential=[$2], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                    HiveFilter(condition=[AND(IN($2, _UTF-16LE'>10000', _UTF-16LE'unknown'), >($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1), null), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(s_store_sk=[$0], s_county=[$23])
+                  HiveFilter(condition=[AND(IN($23, _UTF-16LE'Mobile County', _UTF-16LE'Maverick County', _UTF-16LE'Huron County', _UTF-16LE'Kittitas County'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out
new file mode 100644
index 0000000..32d6e03
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query74.q.out
@@ -0,0 +1,191 @@
+PREHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ss_net_paid) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ws_net_paid) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         )
+  select 
+        t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.year = 2001
+         and t_s_secyear.year = 2001+1
+         and t_w_firstyear.year = 2001
+         and t_w_secyear.year = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by 2,1,3
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ss_net_paid) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ws_net_paid) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         )
+  select 
+        t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.year = 2001
+         and t_s_secyear.year = 2001+1
+         and t_w_firstyear.year = 2001
+         and t_w_secyear.year = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by 2,1,3
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], sort1=[$0], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(customer_id=[$0], customer_first_name=[$1], customer_last_name=[$2])
+    HiveJoin(condition=[AND(=($0, $6), CASE(CAST(IS NOT NULL($7)):BOOLEAN, CASE(CAST(IS NOT NULL($9)):BOOLEAN, >(/($5, $9), /($3, $7)), >(null, /($3, $7))), CASE(CAST(IS NOT NULL($9)):BOOLEAN, >(/($5, $9), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(customer_id=[$0], customer_first_name=[$1], customer_last_name=[$2], year_total=[$4])
+        HiveAggregate(group=[{1, 2, 3, 8}], agg#0=[max($6)])
+          HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                HiveTableScan(table=[[default, customer]], table:alias=[customer])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_net_paid=[$20])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2002), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveJoin(condition=[=($2, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(customer_id=[$0], year_total=[$4])
+            HiveAggregate(group=[{1, 2, 3, 8}], agg#0=[max($6)])
+              HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_net_paid=[$29])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                    HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2002), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(customer_id=[$0], year_total=[$4])
+            HiveFilter(condition=[>($4, 0)])
+              HiveAggregate(group=[{1, 2, 3, 8}], agg#0=[max($6)])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_net_paid=[$20])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                      HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2001), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(customer_id=[$0], year_total=[$4])
+          HiveFilter(condition=[>($4, 0)])
+            HiveAggregate(group=[{1, 2, 3, 8}], agg#0=[max($6)])
+              HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_net_paid=[$29])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                    HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2001), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out
new file mode 100644
index 0000000..3d87d1b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query75.q.out
@@ -0,0 +1,278 @@
+PREHOOK: query: explain cbo
+WITH all_sales AS (
+ SELECT d_year
+       ,i_brand_id
+       ,i_class_id
+       ,i_category_id
+       ,i_manufact_id
+       ,SUM(sales_cnt) AS sales_cnt
+       ,SUM(sales_amt) AS sales_amt
+ FROM (SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt
+             ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt
+       FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk
+                          JOIN date_dim ON d_date_sk=cs_sold_date_sk
+                          LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number 
+                                                    AND cs_item_sk=cr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt
+             ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt
+       FROM store_sales JOIN item ON i_item_sk=ss_item_sk
+                        JOIN date_dim ON d_date_sk=ss_sold_date_sk
+                        LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number 
+                                                AND ss_item_sk=sr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt
+             ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt
+       FROM web_sales JOIN item ON i_item_sk=ws_item_sk
+                      JOIN date_dim ON d_date_sk=ws_sold_date_sk
+                      LEFT JOIN web_returns ON (ws_order_number=wr_order_number 
+                                            AND ws_item_sk=wr_item_sk)
+       WHERE i_category='Sports') sales_detail
+ GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+ SELECT  prev_yr.d_year AS prev_year
+                          ,curr_yr.d_year AS year
+                          ,curr_yr.i_brand_id
+                          ,curr_yr.i_class_id
+                          ,curr_yr.i_category_id
+                          ,curr_yr.i_manufact_id
+                          ,prev_yr.sales_cnt AS prev_yr_cnt
+                          ,curr_yr.sales_cnt AS curr_yr_cnt
+                          ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff
+                          ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff
+ FROM all_sales curr_yr, all_sales prev_yr
+ WHERE curr_yr.i_brand_id=prev_yr.i_brand_id
+   AND curr_yr.i_class_id=prev_yr.i_class_id
+   AND curr_yr.i_category_id=prev_yr.i_category_id
+   AND curr_yr.i_manufact_id=prev_yr.i_manufact_id
+   AND curr_yr.d_year=2002
+   AND prev_yr.d_year=2002-1
+   AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9
+ ORDER BY sales_cnt_diff
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+WITH all_sales AS (
+ SELECT d_year
+       ,i_brand_id
+       ,i_class_id
+       ,i_category_id
+       ,i_manufact_id
+       ,SUM(sales_cnt) AS sales_cnt
+       ,SUM(sales_amt) AS sales_amt
+ FROM (SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt
+             ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt
+       FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk
+                          JOIN date_dim ON d_date_sk=cs_sold_date_sk
+                          LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number 
+                                                    AND cs_item_sk=cr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt
+             ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt
+       FROM store_sales JOIN item ON i_item_sk=ss_item_sk
+                        JOIN date_dim ON d_date_sk=ss_sold_date_sk
+                        LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number 
+                                                AND ss_item_sk=sr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt
+             ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt
+       FROM web_sales JOIN item ON i_item_sk=ws_item_sk
+                      JOIN date_dim ON d_date_sk=ws_sold_date_sk
+                      LEFT JOIN web_returns ON (ws_order_number=wr_order_number 
+                                            AND ws_item_sk=wr_item_sk)
+       WHERE i_category='Sports') sales_detail
+ GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+ SELECT  prev_yr.d_year AS prev_year
+                          ,curr_yr.d_year AS year
+                          ,curr_yr.i_brand_id
+                          ,curr_yr.i_class_id
+                          ,curr_yr.i_category_id
+                          ,curr_yr.i_manufact_id
+                          ,prev_yr.sales_cnt AS prev_yr_cnt
+                          ,curr_yr.sales_cnt AS curr_yr_cnt
+                          ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff
+                          ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff
+ FROM all_sales curr_yr, all_sales prev_yr
+ WHERE curr_yr.i_brand_id=prev_yr.i_brand_id
+   AND curr_yr.i_class_id=prev_yr.i_class_id
+   AND curr_yr.i_category_id=prev_yr.i_category_id
+   AND curr_yr.i_manufact_id=prev_yr.i_manufact_id
+   AND curr_yr.d_year=2002
+   AND prev_yr.d_year=2002-1
+   AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9
+ ORDER BY sales_cnt_diff
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(prev_year=[CAST(2001):INTEGER], year=[CAST(2002):INTEGER], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], prev_yr_cnt=[$4], curr_yr_cnt=[$5], sales_cnt_diff=[$6], sales_amt_diff=[$7])
+  HiveSortLimit(sort0=[$6], dir0=[ASC], fetch=[100])
+    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], prev_yr_cnt=[$4], curr_yr_cnt=[$10], sales_cnt_diff=[-($10, $4)], sales_amt_diff=[-($11, $5)])
+      HiveJoin(condition=[AND(AND(AND(AND(=($6, $0), =($7, $1)), =($8, $2)), =($9, $3)), <(/(CAST($10):DECIMAL(17, 2), CAST($4):DECIMAL(17, 2)), 0.9))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], $f4=[$4], $f5=[$5])
+          HiveAggregate(group=[{0, 1, 2, 3}], agg#0=[sum($4)], agg#1=[sum($5)])
+            HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                  HiveUnion(all=[true])
+                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                      HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                          HiveUnion(all=[true])
+                            HiveProject(i_brand_id=[$12], i_class_id=[$13], i_category_id=[$14], i_manufact_id=[$16], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_quantity=[$17], cr_return_amount=[$18])
+                                  HiveFilter(condition=[IS NOT NULL($2)])
+                                    HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                                HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_ext_sales_price=[$23])
+                                      HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                                      HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_category=[CAST(_UTF-16LE'Sports'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                            HiveProject(i_brand_id=[$12], i_class_id=[$13], i_category_id=[$14], i_manufact_id=[$16], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_quantity=[$10], sr_return_amt=[$11])
+                                  HiveFilter(condition=[IS NOT NULL($2)])
+                                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                                HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], ss_quantity=[$10], ss_ext_sales_price=[$15])
+                                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                    HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                                      HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_category=[CAST(_UTF-16LE'Sports'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveProject(i_brand_id=[$12], i_class_id=[$13], i_category_id=[$14], i_manufact_id=[$16], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                      HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                        HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15])
+                          HiveFilter(condition=[IS NOT NULL($2)])
+                            HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                        HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], ws_quantity=[$18], ws_ext_sales_price=[$23])
+                              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                              HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_category=[CAST(_UTF-16LE'Sports'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_manufact_id=[$13])
+                            HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], $f4=[$4], $f5=[$5])
+          HiveAggregate(group=[{0, 1, 2, 3}], agg#0=[sum($4)], agg#1=[sum($5)])
+            HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                  HiveUnion(all=[true])
+                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                      HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                          HiveUnion(all=[true])
+                            HiveProject(i_brand_id=[$12], i_class_id=[$13], i_category_id=[$14], i_manufact_id=[$16], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_quantity=[$17], cr_return_amount=[$18])
+                                  HiveFilter(condition=[IS NOT NULL($2)])
+                                    HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                                HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_ext_sales_price=[$23])
+                                      HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                                      HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_category=[CAST(_UTF-16LE'Sports'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                            HiveProject(i_brand_id=[$12], i_class_id=[$13], i_category_id=[$14], i_manufact_id=[$16], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_quantity=[$10], sr_return_amt=[$11])
+                                  HiveFilter(condition=[IS NOT NULL($2)])
+                                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                                HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], ss_quantity=[$10], ss_ext_sales_price=[$15])
+                                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                    HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                                      HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_category=[CAST(_UTF-16LE'Sports'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveProject(i_brand_id=[$12], i_class_id=[$13], i_category_id=[$14], i_manufact_id=[$16], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                      HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                        HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15])
+                          HiveFilter(condition=[IS NOT NULL($2)])
+                            HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                        HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], ws_quantity=[$18], ws_ext_sales_price=[$23])
+                              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                              HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_category=[CAST(_UTF-16LE'Sports'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_manufact_id=[$13])
+                            HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                              HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query76.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query76.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query76.q.out
new file mode 100644
index 0000000..74f888c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query76.q.out
@@ -0,0 +1,101 @@
+PREHOOK: query: explain cbo
+select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
+        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
+         FROM store_sales, item, date_dim
+         WHERE ss_addr_sk IS NULL
+           AND ss_sold_date_sk=d_date_sk
+           AND ss_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
+         FROM web_sales, item, date_dim
+         WHERE ws_web_page_sk IS NULL
+           AND ws_sold_date_sk=d_date_sk
+           AND ws_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
+         FROM catalog_sales, item, date_dim
+         WHERE cs_warehouse_sk IS NULL
+           AND cs_sold_date_sk=d_date_sk
+           AND cs_item_sk=i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
+        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
+         FROM store_sales, item, date_dim
+         WHERE ss_addr_sk IS NULL
+           AND ss_sold_date_sk=d_date_sk
+           AND ss_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
+         FROM web_sales, item, date_dim
+         WHERE ws_web_page_sk IS NULL
+           AND ws_sold_date_sk=d_date_sk
+           AND ws_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
+         FROM catalog_sales, item, date_dim
+         WHERE cs_warehouse_sk IS NULL
+           AND cs_sold_date_sk=d_date_sk
+           AND cs_item_sk=i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject(channel=[$0], col_name=[$1], d_year=[$2], d_qoy=[$3], i_category=[$4], $f5=[$5], $f6=[$6])
+    HiveAggregate(group=[{0, 1, 2, 3, 4}], agg#0=[count()], agg#1=[sum($5)])
+      HiveProject(channel=[$0], col_name=[$1], d_year=[$2], d_qoy=[$3], i_category=[$4], ext_sales_price=[$5])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store'], col_name=[_UTF-16LE'ss_addr_sk'], d_year=[$1], d_qoy=[$2], i_category=[$4], ext_sales_price=[$8])
+            HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(d_date_sk=[$0], d_year=[$6], d_qoy=[$10])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(i_item_sk=[$0], i_category=[$12])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[null], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[AND(IS NULL($6), IS NOT NULL($2), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(channel=[_UTF-16LE'web'], col_name=[_UTF-16LE'ws_web_page_sk'], d_year=[$7], d_qoy=[$8], i_category=[$5], ext_sales_price=[$3])
+            HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_web_page_sk=[null], ws_ext_sales_price=[$23])
+                  HiveFilter(condition=[AND(IS NULL($12), IS NOT NULL($3), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(i_item_sk=[$0], i_category=[$12])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_year=[$6], d_qoy=[$10])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'catalog'], col_name=[_UTF-16LE'cs_warehouse_sk'], d_year=[$7], d_qoy=[$8], i_category=[$5], ext_sales_price=[$3])
+            HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_warehouse_sk=[null], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                  HiveFilter(condition=[AND(IS NULL($14), IS NOT NULL($15), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(i_item_sk=[$0], i_category=[$12])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_year=[$6], d_qoy=[$10])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out
new file mode 100644
index 0000000..2c42995
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query77.q.out
@@ -0,0 +1,316 @@
+Warning: Shuffle Join MERGEJOIN[317][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 16' is a cross product
+PREHOOK: query: explain cbo
+with ss as
+ (select s_store_sk,
+         sum(ss_ext_sales_price) as sales,
+         sum(ss_net_profit) as profit
+ from store_sales,
+      date_dim,
+      store
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days) 
+       and ss_store_sk = s_store_sk
+ group by s_store_sk)
+ ,
+ sr as
+ (select s_store_sk,
+         sum(sr_return_amt) as returns,
+         sum(sr_net_loss) as profit_loss
+ from store_returns,
+      date_dim,
+      store
+ where sr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and sr_store_sk = s_store_sk
+ group by s_store_sk), 
+ cs as
+ (select cs_call_center_sk,
+        sum(cs_ext_sales_price) as sales,
+        sum(cs_net_profit) as profit
+ from catalog_sales,
+      date_dim
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ group by cs_call_center_sk 
+ ), 
+ cr as
+ (select
+        sum(cr_return_amount) as returns,
+        sum(cr_net_loss) as profit_loss
+ from catalog_returns,
+      date_dim
+ where cr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ ), 
+ ws as
+ ( select wp_web_page_sk,
+        sum(ws_ext_sales_price) as sales,
+        sum(ws_net_profit) as profit
+ from web_sales,
+      date_dim,
+      web_page
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ws_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk), 
+ wr as
+ (select wp_web_page_sk,
+        sum(wr_return_amt) as returns,
+        sum(wr_net_loss) as profit_loss
+ from web_returns,
+      date_dim,
+      web_page
+ where wr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and wr_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , ss.s_store_sk as id
+        , sales
+        , coalesce(returns, 0) as returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ss left join sr
+        on  ss.s_store_sk = sr.s_store_sk
+ union all
+ select 'catalog channel' as channel
+        , cs_call_center_sk as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  cs
+       , cr
+ union all
+ select 'web channel' as channel
+        , ws.wp_web_page_sk as id
+        , sales
+        , coalesce(returns, 0) returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ws left join wr
+        on  ws.wp_web_page_sk = wr.wp_web_page_sk
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ss as
+ (select s_store_sk,
+         sum(ss_ext_sales_price) as sales,
+         sum(ss_net_profit) as profit
+ from store_sales,
+      date_dim,
+      store
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days) 
+       and ss_store_sk = s_store_sk
+ group by s_store_sk)
+ ,
+ sr as
+ (select s_store_sk,
+         sum(sr_return_amt) as returns,
+         sum(sr_net_loss) as profit_loss
+ from store_returns,
+      date_dim,
+      store
+ where sr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and sr_store_sk = s_store_sk
+ group by s_store_sk), 
+ cs as
+ (select cs_call_center_sk,
+        sum(cs_ext_sales_price) as sales,
+        sum(cs_net_profit) as profit
+ from catalog_sales,
+      date_dim
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ group by cs_call_center_sk 
+ ), 
+ cr as
+ (select
+        sum(cr_return_amount) as returns,
+        sum(cr_net_loss) as profit_loss
+ from catalog_returns,
+      date_dim
+ where cr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ ), 
+ ws as
+ ( select wp_web_page_sk,
+        sum(ws_ext_sales_price) as sales,
+        sum(ws_net_profit) as profit
+ from web_sales,
+      date_dim,
+      web_page
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ws_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk), 
+ wr as
+ (select wp_web_page_sk,
+        sum(wr_return_amt) as returns,
+        sum(wr_net_loss) as profit_loss
+ from web_returns,
+      date_dim,
+      web_page
+ where wr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and wr_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , ss.s_store_sk as id
+        , sales
+        , coalesce(returns, 0) as returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ss left join sr
+        on  ss.s_store_sk = sr.s_store_sk
+ union all
+ select 'catalog channel' as channel
+        , cs_call_center_sk as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  cs
+       , cr
+ union all
+ select 'web channel' as channel
+        , ws.wp_web_page_sk as id
+        , sales
+        , coalesce(returns, 0) returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ws left join wr
+        on  ws.wp_web_page_sk = wr.wp_web_page_sk
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(channel=[$0], id=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
+      HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store channel'], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+            HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
+              HiveProject(s_store_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{6}], agg#0=[sum($2)], agg#1=[sum($3)])
+                  HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_ext_sales_price=[$15], ss_net_profit=[$22])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(s_store_sk=[$0])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(s_store_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{0}], agg#0=[sum($3)], agg#1=[sum($4)])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(s_store_sk=[$0])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(sr_returned_date_sk=[$0], sr_store_sk=[$7], sr_return_amt=[$11], sr_net_loss=[$19])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'catalog channel'], id=[$0], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cs_call_center_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[sum($3)])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_ext_sales_price=[$23], cs_net_profit=[$33])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                    HiveProject(d_date_sk=[$0], d_date=[$2])
+                      HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject($f0=[$0], $f1=[$1])
+                HiveAggregate(group=[{}], agg#0=[sum($1)], agg#1=[sum($2)])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cr_returned_date_sk=[$0], cr_return_amount=[$18], cr_net_loss=[$26])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                    HiveProject(d_date_sk=[$0], d_date=[$2])
+                      HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'web channel'], id=[$0], sales=[$1], returns=[CASE(IS NOT NULL($4), $4, 0)], profit=[-($2, CASE(IS NOT NULL($5), $5, 0))])
+            HiveJoin(condition=[=($0, $3)], joinType=[left], algorithm=[none], cost=[not available])
+              HiveProject(wp_web_page_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{0}], agg#0=[sum($3)], agg#1=[sum($4)])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(wp_web_page_sk=[$0])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, web_page]], table:alias=[web_page])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_web_page_sk=[$12], ws_ext_sales_price=[$23], ws_net_profit=[$33])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(wp_web_page_sk=[$0], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{0}], agg#0=[sum($3)], agg#1=[sum($4)])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(wp_web_page_sk=[$0])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, web_page]], table:alias=[web_page])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(wr_returned_date_sk=[$0], wr_web_page_sk=[$11], wr_return_amt=[$15], wr_net_loss=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($11))])
+                          HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[46/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out
new file mode 100644
index 0000000..e7d1199
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query16.q.out
@@ -0,0 +1,104 @@
+PREHOOK: query: explain cbo
+select  
+   count(distinct cs_order_number) as `order count`
+  ,sum(cs_ext_ship_cost) as `total shipping cost`
+  ,sum(cs_net_profit) as `total net profit`
+from
+   catalog_sales cs1
+  ,date_dim
+  ,customer_address
+  ,call_center
+where
+    d_date between '2001-4-01' and 
+           (cast('2001-4-01' as date) + 60 days)
+and cs1.cs_ship_date_sk = d_date_sk
+and cs1.cs_ship_addr_sk = ca_address_sk
+and ca_state = 'NY'
+and cs1.cs_call_center_sk = cc_call_center_sk
+and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish',
+                  'Daviess County'
+)
+and exists (select *
+            from catalog_sales cs2
+            where cs1.cs_order_number = cs2.cs_order_number
+              and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
+and not exists(select *
+               from catalog_returns cr1
+               where cs1.cs_order_number = cr1.cr_order_number)
+order by count(distinct cs_order_number)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   count(distinct cs_order_number) as `order count`
+  ,sum(cs_ext_ship_cost) as `total shipping cost`
+  ,sum(cs_net_profit) as `total net profit`
+from
+   catalog_sales cs1
+  ,date_dim
+  ,customer_address
+  ,call_center
+where
+    d_date between '2001-4-01' and 
+           (cast('2001-4-01' as date) + 60 days)
+and cs1.cs_ship_date_sk = d_date_sk
+and cs1.cs_ship_addr_sk = ca_address_sk
+and ca_state = 'NY'
+and cs1.cs_call_center_sk = cc_call_center_sk
+and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish',
+                  'Daviess County'
+)
+and exists (select *
+            from catalog_sales cs2
+            where cs1.cs_order_number = cs2.cs_order_number
+              and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
+and not exists(select *
+               from catalog_returns cr1
+               where cs1.cs_order_number = cr1.cr_order_number)
+order by count(distinct cs_order_number)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2])
+  HiveSortLimit(sort0=[$3], dir0=[ASC], fetch=[100])
+    HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2], (tok_functiondi count (tok_table_or_col cs_order_number))=[$0])
+      HiveAggregate(group=[{}], agg#0=[count(DISTINCT $4)], agg#1=[sum($5)], agg#2=[sum($6)])
+        HiveFilter(condition=[IS NULL($14)])
+          HiveJoin(condition=[=($4, $13)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveSemiJoin(condition=[AND(<>($3, $13), =($4, $14))], joinType=[inner])
+              HiveProject(cs_ship_date_sk=[$2], cs_ship_addr_sk=[$3], cs_call_center_sk=[$4], cs_warehouse_sk=[$5], cs_order_number=[$6], cs_ext_ship_cost=[$7], cs_net_profit=[$8], d_date_sk=[$9], d_date=[$10], ca_address_sk=[$0], ca_state=[$1], cc_call_center_sk=[$11], cc_county=[$12])
+                HiveJoin(condition=[=($4, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_state=[CAST(_UTF-16LE'NY'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(=($8, _UTF-16LE'NY'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_ship_date_sk=[$2], cs_ship_addr_sk=[$10], cs_call_center_sk=[$11], cs_warehouse_sk=[$14], cs_order_number=[$17], cs_ext_ship_cost=[$28], cs_net_profit=[$33])
+                        HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($10), IS NOT NULL($11), IS NOT NULL($17))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs1])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-04-01 00:00:00, 2001-05-31 00:00:00), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(cc_call_center_sk=[$0], cc_county=[$25])
+                    HiveFilter(condition=[AND(IN($25, _UTF-16LE'Ziebach County', _UTF-16LE'Levy County', _UTF-16LE'Huron County', _UTF-16LE'Franklin Parish', _UTF-16LE'Daviess County'), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+              HiveProject(cs_warehouse_sk=[$14], cs_order_number=[$17])
+                HiveFilter(condition=[AND(IS NOT NULL($17), IS NOT NULL($14))])
+                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs2])
+            HiveProject(cr_order_number0=[$0], $f1=[true])
+              HiveAggregate(group=[{16}])
+                HiveFilter(condition=[IS NOT NULL($16)])
+                  HiveTableScan(table=[[default, catalog_returns]], table:alias=[cr1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out
new file mode 100644
index 0000000..6c5b480
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query17.q.out
@@ -0,0 +1,141 @@
+PREHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,s_state
+       ,count(ss_quantity) as store_sales_quantitycount
+       ,avg(ss_quantity) as store_sales_quantityave
+       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
+       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
+       ,count(sr_return_quantity) as_store_returns_quantitycount
+       ,avg(sr_return_quantity) as_store_returns_quantityave
+       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
+       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
+       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
+ from store_sales
+     ,store_returns
+     ,catalog_sales
+     ,date_dim d1
+     ,date_dim d2
+     ,date_dim d3
+     ,store
+     ,item
+ where d1.d_quarter_name = '2000Q1'
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+ group by i_item_id
+         ,i_item_desc
+         ,s_state
+ order by i_item_id
+         ,i_item_desc
+         ,s_state
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,s_state
+       ,count(ss_quantity) as store_sales_quantitycount
+       ,avg(ss_quantity) as store_sales_quantityave
+       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
+       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
+       ,count(sr_return_quantity) as_store_returns_quantitycount
+       ,avg(sr_return_quantity) as_store_returns_quantityave
+       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
+       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
+       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
+ from store_sales
+     ,store_returns
+     ,catalog_sales
+     ,date_dim d1
+     ,date_dim d2
+     ,date_dim d3
+     ,store
+     ,item
+ where d1.d_quarter_name = '2000Q1'
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+ group by i_item_id
+         ,i_item_desc
+         ,s_state
+ order by i_item_id
+         ,i_item_desc
+         ,s_state
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], s_state=[$2], store_sales_quantitycount=[$3], store_sales_quantityave=[/(CAST($4):DOUBLE, $3)], store_sales_quantitystdev=[POWER(/(-($5, /(*($6, $6), $3)), CASE(=($3, 1), null, -($3, 1))), 0.5)], store_sales_quantitycov=[/(POWER(/(-($5, /(*($6, $6), $3)), CASE(=($3, 1), null, -($3, 1))), 0.5), /(CAST($4):DOUBLE, $3))], as_store_returns_quantitycount=[$7], as_store_returns_quantityave=[/(CAST($8):DOUBLE, $7)], as_store_returns_quantitystdev=[POWER(/(-($9, /(*($10, $10), $7)), CASE(=($7, 1), null, -($7, 1))), 0.5)], store_returns_quantitycov=[/(POWER(/(-($9, /(*($10, $10), $7)), CASE(=($7, 1), null, -($7, 1))), 0.5), /(CAST($8):DOUBLE, $7))], catalog_sales_quantitycount=[$11], catalog_sales_quantityave=[/(CAST($12):DOUBLE, $11)], catalog_sales_quantitystdev=[/(POWER(/(-($13, /(*($14, $14), $11)), CASE(=($11, 1), null, -($11, 1))), 0.5), /(CAST($12):DOUBLE, $11))], catalog_sales_quantitycov=[/(POWER(/(-($13, /(*($14, $14), $11)), CASE(=($
 11, 1), null, -($11, 1))), 0.5), /(CAST($12):DOUBLE, $11))])
+    HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)], agg#1=[sum($3)], agg#2=[sum($7)], agg#3=[sum($6)], agg#4=[count($4)], agg#5=[sum($4)], agg#6=[sum($9)], agg#7=[sum($8)], agg#8=[count($5)], agg#9=[sum($5)], agg#10=[sum($11)], agg#11=[sum($10)])
+      HiveProject($f0=[$9], $f1=[$10], $f2=[$25], $f3=[$5], $f4=[$21], $f5=[$14], $f30=[CAST($5):DOUBLE], $f7=[*(CAST($5):DOUBLE, CAST($5):DOUBLE)], $f40=[CAST($21):DOUBLE], $f9=[*(CAST($21):DOUBLE, CAST($21):DOUBLE)], $f50=[CAST($14):DOUBLE], $f11=[*(CAST($14):DOUBLE, CAST($14):DOUBLE)])
+        HiveJoin(condition=[=($24, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[AND(AND(=($2, $19), =($1, $18)), =($4, $20))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($8, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_quantity=[$10])
+                  HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0], d_quarter_name=[CAST(_UTF-16LE'2000Q1'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                  HiveFilter(condition=[AND(=($15, _UTF-16LE'2000Q1'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2], cs_quantity=[$3], d_date_sk=[$4], d_quarter_name=[$5], sr_returned_date_sk=[$6], sr_item_sk=[$7], sr_customer_sk=[$8], sr_ticket_number=[$9], sr_return_quantity=[$10], d_date_sk0=[$11], d_quarter_name0=[$12])
+              HiveJoin(condition=[AND(=($8, $1), =($7, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_quantity=[$18])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($15), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_quarter_name=[$15])
+                    HiveFilter(condition=[AND(IN($15, _UTF-16LE'2000Q1', _UTF-16LE'2000Q2', _UTF-16LE'2000Q3'), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$1], sr_customer_sk=[$2], sr_ticket_number=[$3], sr_return_quantity=[$4], d_date_sk=[$5], d_quarter_name=[$6])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9], sr_return_quantity=[$10])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveProject(d_date_sk=[$0], d_quarter_name=[$15])
+                      HiveFilter(condition=[AND(IN($15, _UTF-16LE'2000Q1', _UTF-16LE'2000Q2', _UTF-16LE'2000Q3'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+          HiveProject(s_store_sk=[$0], s_state=[$24])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out
new file mode 100644
index 0000000..7e931c5
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query18.q.out
@@ -0,0 +1,114 @@
+PREHOOK: query: explain cbo
+select  i_item_id,
+        ca_country,
+        ca_state, 
+        ca_county,
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
+ from catalog_sales, customer_demographics cd1, 
+      customer_demographics cd2, customer, customer_address, date_dim, item
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd1.cd_demo_sk and
+       cs_bill_customer_sk = c_customer_sk and
+       cd1.cd_gender = 'M' and 
+       cd1.cd_education_status = 'College' and
+       c_current_cdemo_sk = cd2.cd_demo_sk and
+       c_current_addr_sk = ca_address_sk and
+       c_birth_month in (9,5,12,4,1,10) and
+       d_year = 2001 and
+       ca_state in ('ND','WI','AL'
+                   ,'NC','OK','MS','TN')
+ group by rollup (i_item_id, ca_country, ca_state, ca_county)
+ order by ca_country,
+        ca_state, 
+        ca_county,
+	i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id,
+        ca_country,
+        ca_state, 
+        ca_county,
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
+ from catalog_sales, customer_demographics cd1, 
+      customer_demographics cd2, customer, customer_address, date_dim, item
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd1.cd_demo_sk and
+       cs_bill_customer_sk = c_customer_sk and
+       cd1.cd_gender = 'M' and 
+       cd1.cd_education_status = 'College' and
+       c_current_cdemo_sk = cd2.cd_demo_sk and
+       c_current_addr_sk = ca_address_sk and
+       c_birth_month in (9,5,12,4,1,10) and
+       d_year = 2001 and
+       ca_state in ('ND','WI','AL'
+                   ,'NC','OK','MS','TN')
+ group by rollup (i_item_id, ca_country, ca_state, ca_county)
+ order by ca_country,
+        ca_state, 
+        ca_county,
+	i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$3], sort3=[$0], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[/($4, $5)], $f5=[/($6, $7)], $f6=[/($8, $9)], $f7=[/($10, $11)], $f8=[/($12, $13)], $f9=[/($14, $15)], $f10=[/($16, $17)])
+    HiveAggregate(group=[{0, 1, 2, 3}], groups=[[{0, 1, 2, 3}, {0, 1, 2}, {0, 1}, {0}, {}]], agg#0=[sum($4)], agg#1=[count($4)], agg#2=[sum($5)], agg#3=[count($5)], agg#4=[sum($6)], agg#5=[count($6)], agg#6=[sum($7)], agg#7=[count($7)], agg#8=[sum($8)], agg#9=[count($8)], agg#10=[sum($9)], agg#11=[count($9)], agg#12=[sum($10)], agg#13=[count($10)])
+      HiveProject($f0=[$11], $f1=[$8], $f2=[$7], $f3=[$6], $f4=[CAST($16):DECIMAL(12, 2)], $f5=[CAST($17):DECIMAL(12, 2)], $f6=[CAST($19):DECIMAL(12, 2)], $f7=[CAST($18):DECIMAL(12, 2)], $f8=[CAST($20):DECIMAL(12, 2)], $f9=[CAST($4):DECIMAL(12, 2)], $f10=[CAST($26):DECIMAL(12, 2)])
+        HiveJoin(condition=[=($13, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($1, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4], c_birth_month=[$12], c_birth_year=[$13])
+                HiveFilter(condition=[AND(IN($12, 9, 5, 12, 4, 1, 10), IS NOT NULL($0), IS NOT NULL($2), IS NOT NULL($4))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7], ca_state=[$8], ca_country=[$10])
+                HiveFilter(condition=[AND(IN($8, _UTF-16LE'ND', _UTF-16LE'WI', _UTF-16LE'AL', _UTF-16LE'NC', _UTF-16LE'OK', _UTF-16LE'MS', _UTF-16LE'TN'), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(cd_demo_sk=[$0])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], cs_sold_date_sk=[$2], cs_bill_customer_sk=[$3], cs_bill_cdemo_sk=[$4], cs_item_sk=[$5], cs_quantity=[$6], cs_list_price=[$7], cs_sales_price=[$8], cs_coupon_amt=[$9], cs_net_profit=[$10], d_date_sk=[$11], d_year=[$12], cd_demo_sk=[$13], cd_gender=[$14], cd_education_status=[$15], cd_dep_count=[$16])
+            HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_bill_cdemo_sk=[$4], cs_item_sk=[$15], cs_quantity=[$18], cs_list_price=[$20], cs_sales_price=[$21], cs_coupon_amt=[$27], cs_net_profit=[$33])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($3), IS NOT NULL($0), IS NOT NULL($15))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(cd_demo_sk=[$0], cd_gender=[CAST(_UTF-16LE'M'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_education_status=[CAST(_UTF-16LE'College'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_dep_count=[$6])
+                  HiveFilter(condition=[AND(=($1, _UTF-16LE'M'), =($3, _UTF-16LE'College'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query19.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query19.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query19.q.out
new file mode 100644
index 0000000..c24d76f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query19.q.out
@@ -0,0 +1,92 @@
+PREHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item,customer,customer_address,store
+ where d_date_sk = ss_sold_date_sk
+   and ss_item_sk = i_item_sk
+   and i_manager_id=7
+   and d_moy=11
+   and d_year=1999
+   and ss_customer_sk = c_customer_sk 
+   and c_current_addr_sk = ca_address_sk
+   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
+   and ss_store_sk = s_store_sk 
+ group by i_brand
+      ,i_brand_id
+      ,i_manufact_id
+      ,i_manufact
+ order by ext_price desc
+         ,i_brand
+         ,i_brand_id
+         ,i_manufact_id
+         ,i_manufact
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item,customer,customer_address,store
+ where d_date_sk = ss_sold_date_sk
+   and ss_item_sk = i_item_sk
+   and i_manager_id=7
+   and d_moy=11
+   and d_year=1999
+   and ss_customer_sk = c_customer_sk 
+   and c_current_addr_sk = ca_address_sk
+   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
+   and ss_store_sk = s_store_sk 
+ group by i_brand
+      ,i_brand_id
+      ,i_manufact_id
+      ,i_manufact
+ order by ext_price desc
+         ,i_brand
+         ,i_brand_id
+         ,i_manufact_id
+         ,i_manufact
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(brand_id=[$0], brand=[$1], i_manufact_id=[$2], i_manufact=[$3], ext_price=[$4])
+  HiveSortLimit(sort0=[$4], sort1=[$5], sort2=[$6], sort3=[$2], sort4=[$3], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+    HiveProject(brand_id=[$0], brand=[$1], i_manufact_id=[$2], i_manufact=[$3], ext_price=[$4], (tok_table_or_col i_brand)=[$1], (tok_table_or_col i_brand_id)=[$0])
+      HiveAggregate(group=[{13, 14, 15, 16}], agg#0=[sum($8)])
+        HiveJoin(condition=[AND(<>(substr($3, 1, 5), substr($19, 1, 5)), =($7, $18))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0], ca_zip=[$9])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5], d_year=[$6], d_moy=[$7], i_item_sk=[$8], i_brand_id=[$9], i_brand=[$10], i_manufact_id=[$11], i_manufact=[$12], i_manager_id=[$13])
+              HiveJoin(condition=[=($1, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ext_sales_price=[$15])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2), IS NOT NULL($3), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(11):INTEGER])
+                    HiveFilter(condition=[AND(=($8, 11), =($6, 1999), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8], i_manufact_id=[$13], i_manufact=[$14], i_manager_id=[CAST(7):INTEGER])
+                  HiveFilter(condition=[AND(=($20, 7), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveProject(s_store_sk=[$0], s_zip=[$25])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out
new file mode 100644
index 0000000..cca252e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query2.q.out
@@ -0,0 +1,170 @@
+PREHOOK: query: explain cbo
+with wscs as
+ (select sold_date_sk
+        ,sales_price
+  from (select ws_sold_date_sk sold_date_sk
+              ,ws_ext_sales_price sales_price
+        from web_sales) x
+        union all
+       (select cs_sold_date_sk sold_date_sk
+              ,cs_ext_sales_price sales_price
+        from catalog_sales)),
+ wswscs as 
+ (select d_week_seq,
+        sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
+ from wscs
+     ,date_dim
+ where d_date_sk = sold_date_sk
+ group by d_week_seq)
+ select d_week_seq1
+       ,round(sun_sales1/sun_sales2,2)
+       ,round(mon_sales1/mon_sales2,2)
+       ,round(tue_sales1/tue_sales2,2)
+       ,round(wed_sales1/wed_sales2,2)
+       ,round(thu_sales1/thu_sales2,2)
+       ,round(fri_sales1/fri_sales2,2)
+       ,round(sat_sales1/sat_sales2,2)
+ from
+ (select wswscs.d_week_seq d_week_seq1
+        ,sun_sales sun_sales1
+        ,mon_sales mon_sales1
+        ,tue_sales tue_sales1
+        ,wed_sales wed_sales1
+        ,thu_sales thu_sales1
+        ,fri_sales fri_sales1
+        ,sat_sales sat_sales1
+  from wswscs,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001) y,
+ (select wswscs.d_week_seq d_week_seq2
+        ,sun_sales sun_sales2
+        ,mon_sales mon_sales2
+        ,tue_sales tue_sales2
+        ,wed_sales wed_sales2
+        ,thu_sales thu_sales2
+        ,fri_sales fri_sales2
+        ,sat_sales sat_sales2
+  from wswscs
+      ,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001+1) z
+ where d_week_seq1=d_week_seq2-53
+ order by d_week_seq1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with wscs as
+ (select sold_date_sk
+        ,sales_price
+  from (select ws_sold_date_sk sold_date_sk
+              ,ws_ext_sales_price sales_price
+        from web_sales) x
+        union all
+       (select cs_sold_date_sk sold_date_sk
+              ,cs_ext_sales_price sales_price
+        from catalog_sales)),
+ wswscs as 
+ (select d_week_seq,
+        sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
+ from wscs
+     ,date_dim
+ where d_date_sk = sold_date_sk
+ group by d_week_seq)
+ select d_week_seq1
+       ,round(sun_sales1/sun_sales2,2)
+       ,round(mon_sales1/mon_sales2,2)
+       ,round(tue_sales1/tue_sales2,2)
+       ,round(wed_sales1/wed_sales2,2)
+       ,round(thu_sales1/thu_sales2,2)
+       ,round(fri_sales1/fri_sales2,2)
+       ,round(sat_sales1/sat_sales2,2)
+ from
+ (select wswscs.d_week_seq d_week_seq1
+        ,sun_sales sun_sales1
+        ,mon_sales mon_sales1
+        ,tue_sales tue_sales1
+        ,wed_sales wed_sales1
+        ,thu_sales thu_sales1
+        ,fri_sales fri_sales1
+        ,sat_sales sat_sales1
+  from wswscs,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001) y,
+ (select wswscs.d_week_seq d_week_seq2
+        ,sun_sales sun_sales2
+        ,mon_sales mon_sales2
+        ,tue_sales tue_sales2
+        ,wed_sales wed_sales2
+        ,thu_sales thu_sales2
+        ,fri_sales fri_sales2
+        ,sat_sales sat_sales2
+  from wswscs
+      ,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001+1) z
+ where d_week_seq1=d_week_seq2-53
+ order by d_week_seq1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC])
+  HiveProject(d_week_seq1=[$0], _o__c1=[round(/($1, $11), 2)], _o__c2=[round(/($2, $12), 2)], _o__c3=[round(/($3, $13), 2)], _o__c4=[round(/($4, $14), 2)], _o__c5=[round(/($5, $15), 2)], _o__c6=[round(/($6, $16), 2)], _o__c7=[round(/($7, $17), 2)])
+    HiveJoin(condition=[=($0, -($10, 53))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
+          HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
+            HiveProject($f0=[$3], $f1=[CASE(=($4, _UTF-16LE'Sunday'), $1, null)], $f2=[CASE(=($4, _UTF-16LE'Monday'), $1, null)], $f3=[CASE(=($4, _UTF-16LE'Tuesday'), $1, null)], $f4=[CASE(=($4, _UTF-16LE'Wednesday'), $1, null)], $f5=[CASE(=($4, _UTF-16LE'Thursday'), $1, null)], $f6=[CASE(=($4, _UTF-16LE'Friday'), $1, null)], $f7=[CASE(=($4, _UTF-16LE'Saturday'), $1, null)])
+              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
+                  HiveUnion(all=[true])
+                    HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$23])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(cs_sold_date_sk=[$0], cs_ext_sales_price=[$23])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0], d_week_seq=[$4], d_day_name=[$14])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(d_week_seq=[$4], d_year=[CAST(2001):INTEGER])
+          HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($4))])
+            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(d_week_seq2=[$0], sun_sales2=[$1], mon_sales2=[$2], tue_sales2=[$3], wed_sales2=[$4], thu_sales2=[$5], fri_sales2=[$6], sat_sales2=[$7])
+        HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
+              HiveProject($f0=[$3], $f1=[CASE(=($4, _UTF-16LE'Sunday'), $1, null)], $f2=[CASE(=($4, _UTF-16LE'Monday'), $1, null)], $f3=[CASE(=($4, _UTF-16LE'Tuesday'), $1, null)], $f4=[CASE(=($4, _UTF-16LE'Wednesday'), $1, null)], $f5=[CASE(=($4, _UTF-16LE'Thursday'), $1, null)], $f6=[CASE(=($4, _UTF-16LE'Friday'), $1, null)], $f7=[CASE(=($4, _UTF-16LE'Saturday'), $1, null)])
+                HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
+                    HiveUnion(all=[true])
+                      HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(cs_sold_date_sk=[$0], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_week_seq=[$4], d_day_name=[$14])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(d_week_seq=[$4], d_year=[CAST(2002):INTEGER])
+            HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($4))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out
new file mode 100644
index 0000000..834c804
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query20.q.out
@@ -0,0 +1,81 @@
+PREHOOK: query: explain cbo
+select  i_item_desc 
+       ,i_category 
+       ,i_class 
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue 
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from	catalog_sales
+     ,item 
+     ,date_dim
+ where cs_item_sk = i_item_sk 
+   and i_category in ('Jewelry', 'Sports', 'Books')
+   and cs_sold_date_sk = d_date_sk
+ and d_date between cast('2001-01-12' as date) 
+ 				and (cast('2001-01-12' as date) + 30 days)
+ group by i_item_id
+         ,i_item_desc 
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_desc 
+       ,i_category 
+       ,i_class 
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue 
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from	catalog_sales
+     ,item 
+     ,date_dim
+ where cs_item_sk = i_item_sk 
+   and i_category in ('Jewelry', 'Sports', 'Books')
+   and cs_sold_date_sk = d_date_sk
+ and d_date between cast('2001-01-12' as date) 
+ 				and (cast('2001-01-12' as date) + 30 days)
+ group by i_item_id
+         ,i_item_desc 
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3], itemrevenue=[$4], revenueratio=[$5])
+  HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$6], sort3=[$0], sort4=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+    HiveProject(i_item_desc=[$1], i_category=[$4], i_class=[$3], i_current_price=[$2], itemrevenue=[$5], revenueratio=[/(*($5, CAST(100):DECIMAL(10, 0)), sum($5) OVER (PARTITION BY $3 ORDER BY $3 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING))], (tok_table_or_col i_item_id)=[$0])
+      HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
+            HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+              HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+            HiveProject(d_date_sk=[$0], d_date=[$2])
+              HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-01-12 00:00:00, 2001-02-11 00:00:00), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out
new file mode 100644
index 0000000..a54a085
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query21.q.out
@@ -0,0 +1,90 @@
+PREHOOK: query: explain cbo
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
+	                then inv_quantity_on_hand 
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
+                      then inv_quantity_on_hand 
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0 
+             then inv_after / inv_before 
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
+	                then inv_quantity_on_hand 
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
+                      then inv_quantity_on_hand 
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0 
+             then inv_after / inv_before 
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+    HiveFilter(condition=[CASE(>($2, 0), BETWEEN(false, /(CAST($3):DOUBLE, CAST($2):DOUBLE), 6.66667E-1, 1.5E0), null)])
+      HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)])
+        HiveProject($f0=[$1], $f1=[$9], $f2=[CASE(<(CAST($7):DATE, 1998-04-08), $5, 0)], $f3=[CASE(>=(CAST($7):DATE, 1998-04-08), $5, 0)])
+          HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+            HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3])
+                  HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($1), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                HiveProject(d_date_sk=[$0], d_date=[$2])
+                  HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-09 00:00:00, 1998-05-08 00:00:00), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1], i_current_price=[$5])
+                HiveFilter(condition=[AND(BETWEEN(false, $5, 0.99, 1.49), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query22.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query22.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query22.q.out
new file mode 100644
index 0000000..c5118ee
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query22.q.out
@@ -0,0 +1,72 @@
+PREHOOK: query: explain cbo
+select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,avg(inv_quantity_on_hand) qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1212 and 1212 + 11
+       group by rollup(i_product_name
+                       ,i_brand
+                       ,i_class
+                       ,i_category)
+order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,avg(inv_quantity_on_hand) qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1212 and 1212 + 11
+       group by rollup(i_product_name
+                       ,i_brand
+                       ,i_class
+                       ,i_category)
+order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$4], sort1=[$0], sort2=[$1], sort3=[$2], sort4=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject($f0=[$3], $f1=[$0], $f2=[$1], $f3=[$2], $f4=[/(CAST($4):DOUBLE, $5)])
+    HiveAggregate(group=[{1, 2, 3, 4}], groups=[[{1, 2, 3, 4}, {1, 2, 4}, {1, 4}, {4}, {}]], agg#0=[sum($8)], agg#1=[count($8)])
+      HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12], i_product_name=[$21])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveJoin(condition=[=($2, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1), IS NOT NULL($2))])
+                HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+            HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+              HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(w_warehouse_sk=[$0])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out
new file mode 100644
index 0000000..baf790e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out
@@ -0,0 +1,281 @@
+Warning: Shuffle Join MERGEJOIN[589][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 29' is a cross product
+Warning: Shuffle Join MERGEJOIN[590][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 30' is a cross product
+Warning: Shuffle Join MERGEJOIN[592][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 33' is a cross product
+Warning: Shuffle Join MERGEJOIN[593][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 34' is a cross product
+PREHOOK: query: explain cbo
+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
+  *
+from
+ max_store_sales))
+  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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+  *
+from
+ max_store_sales))
+  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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0])
+    HiveAggregate(group=[{}], agg#0=[sum($0)])
+      HiveProject(sales=[$0])
+        HiveUnion(all=[true])
+          HiveProject(sales=[*(CAST($5):DECIMAL(10, 0), $6)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0])
+                HiveJoin(condition=[>($1, *(0.95, $3))], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject($f0=[$0], $f1=[$1])
+                    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                      HiveProject($f0=[$3], $f1=[*(CAST($1):DECIMAL(10, 0), $2)])
+                        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_customer_sk=[$3], ss_quantity=[$10], ss_sales_price=[$13])
+                            HiveFilter(condition=[IS NOT NULL($3)])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(c_customer_sk=[$0])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cnt=[$0])
+                      HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                        HiveProject(cnt=[$0])
+                          HiveAggregate(group=[{}], cnt=[COUNT()])
+                            HiveProject
+                              HiveProject($f0=[$0])
+                                HiveAggregate(group=[{}], agg#0=[count($0)])
+                                  HiveProject($f0=[$0], $f1=[$1])
+                                    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                                      HiveProject($f0=[$0], $f1=[*(CAST($3):DECIMAL(10, 0), $4)])
+                                        HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveProject(c_customer_sk=[$0])
+                                            HiveFilter(condition=[IS NOT NULL($0)])
+                                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                          HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_quantity=[$10], ss_sales_price=[$13])
+                                              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                                              HiveFilter(condition=[AND(IN($6, 1999, 2000, 2001, 2002), IS NOT NULL($0))])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject($f0=[$0])
+                      HiveAggregate(group=[{}], agg#0=[max($1)])
+                        HiveProject($f0=[$0], $f1=[$1])
+                          HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                            HiveProject($f0=[$0], $f1=[*(CAST($3):DECIMAL(10, 0), $4)])
+                              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(c_customer_sk=[$0])
+                                  HiveFilter(condition=[IS NOT NULL($0)])
+                                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_quantity=[$10], ss_sales_price=[$13])
+                                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                  HiveProject(d_date_sk=[$0], d_year=[$6])
+                                    HiveFilter(condition=[AND(IN($6, 1999, 2000, 2001, 2002), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f1=[$0])
+                  HiveAggregate(group=[{1}])
+                    HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+                      HiveFilter(condition=[>($3, 4)])
+                        HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                          HiveProject($f0=[substr($6, 1, 30)], $f1=[$5], $f2=[$3])
+                            HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2))])
+                                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                HiveProject(d_date_sk=[$0], d_date=[$2], d_year=[$6])
+                                  HiveFilter(condition=[AND(IN($6, 1999, 2000, 2001, 2002), IS NOT NULL($0))])
+                                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                              HiveProject(i_item_sk=[$0], i_item_desc=[$4])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_quantity=[$18], cs_list_price=[$20])
+                    HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($3), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(1):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 1999), =($8, 1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(sales=[*(CAST($5):DECIMAL(10, 0), $6)])
+            HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0])
+                HiveJoin(condition=[>($1, *(0.95, $3))], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject($f0=[$0], $f1=[$1])
+                    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                      HiveProject($f0=[$3], $f1=[*(CAST($1):DECIMAL(10, 0), $2)])
+                        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_customer_sk=[$3], ss_quantity=[$10], ss_sales_price=[$13])
+                            HiveFilter(condition=[IS NOT NULL($3)])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(c_customer_sk=[$0])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cnt=[$0])
+                      HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                        HiveProject(cnt=[$0])
+                          HiveAggregate(group=[{}], cnt=[COUNT()])
+                            HiveProject
+                              HiveProject($f0=[$0])
+                                HiveAggregate(group=[{}], agg#0=[count($0)])
+                                  HiveProject($f0=[$0], $f1=[$1])
+                                    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                                      HiveProject($f0=[$0], $f1=[*(CAST($3):DECIMAL(10, 0), $4)])
+                                        HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveProject(c_customer_sk=[$0])
+                                            HiveFilter(condition=[IS NOT NULL($0)])
+                                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                          HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_quantity=[$10], ss_sales_price=[$13])
+                                              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                                              HiveFilter(condition=[AND(IN($6, 1999, 2000, 2001, 2002), IS NOT NULL($0))])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject($f0=[$0])
+                      HiveAggregate(group=[{}], agg#0=[max($1)])
+                        HiveProject($f0=[$0], $f1=[$1])
+                          HiveAggregate(group=[{0}], agg#0=[sum($1)])
+                            HiveProject($f0=[$0], $f1=[*(CAST($3):DECIMAL(10, 0), $4)])
+                              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(c_customer_sk=[$0])
+                                  HiveFilter(condition=[IS NOT NULL($0)])
+                                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_quantity=[$10], ss_sales_price=[$13])
+                                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                  HiveProject(d_date_sk=[$0], d_year=[$6])
+                                    HiveFilter(condition=[AND(IN($6, 1999, 2000, 2001, 2002), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f1=[$0])
+                  HiveAggregate(group=[{1}])
+                    HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+                      HiveFilter(condition=[>($3, 4)])
+                        HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                          HiveProject($f0=[substr($6, 1, 30)], $f1=[$5], $f2=[$3])
+                            HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2))])
+                                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                HiveProject(d_date_sk=[$0], d_date=[$2], d_year=[$6])
+                                  HiveFilter(condition=[AND(IN($6, 1999, 2000, 2001, 2002), IS NOT NULL($0))])
+                                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                              HiveProject(i_item_sk=[$0], i_item_desc=[$4])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_customer_sk=[$4], ws_quantity=[$18], ws_list_price=[$20])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(1):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 1999), =($8, 1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
new file mode 100644
index 0000000..53220d2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
@@ -0,0 +1,171 @@
+Warning: Shuffle Join MERGEJOIN[290][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain cbo
+with ssales as
+(select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,ca_state
+      ,s_state
+      ,i_color
+      ,i_current_price
+      ,i_manager_id
+      ,i_units
+      ,i_size
+      ,sum(ss_sales_price) netpaid
+from store_sales
+    ,store_returns
+    ,store
+    ,item
+    ,customer
+    ,customer_address
+where ss_ticket_number = sr_ticket_number
+  and ss_item_sk = sr_item_sk
+  and ss_customer_sk = c_customer_sk
+  and ss_item_sk = i_item_sk
+  and ss_store_sk = s_store_sk
+  and c_birth_country = upper(ca_country)
+  and s_zip = ca_zip
+and s_market_id=7
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+        ,ca_state
+        ,s_state
+        ,i_color
+        ,i_current_price
+        ,i_manager_id
+        ,i_units
+        ,i_size)
+select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,sum(netpaid) paid
+from ssales
+where i_color = 'orchid'
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+having sum(netpaid) > (select 0.05*avg(netpaid)
+                                 from ssales)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssales as
+(select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,ca_state
+      ,s_state
+      ,i_color
+      ,i_current_price
+      ,i_manager_id
+      ,i_units
+      ,i_size
+      ,sum(ss_sales_price) netpaid
+from store_sales
+    ,store_returns
+    ,store
+    ,item
+    ,customer
+    ,customer_address
+where ss_ticket_number = sr_ticket_number
+  and ss_item_sk = sr_item_sk
+  and ss_customer_sk = c_customer_sk
+  and ss_item_sk = i_item_sk
+  and ss_store_sk = s_store_sk
+  and c_birth_country = upper(ca_country)
+  and s_zip = ca_zip
+and s_market_id=7
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+        ,ca_state
+        ,s_state
+        ,i_color
+        ,i_current_price
+        ,i_manager_id
+        ,i_units
+        ,i_size)
+select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,sum(netpaid) paid
+from ssales
+where i_color = 'orchid'
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+having sum(netpaid) > (select 0.05*avg(netpaid)
+                                 from ssales)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+  HiveJoin(condition=[>($3, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveProject(c_last_name=[$1], c_first_name=[$0], s_store_name=[$2], $f3=[$3])
+      HiveAggregate(group=[{1, 2, 7}], agg#0=[sum($9)])
+        HiveProject(ca_state=[$0], c_first_name=[$1], c_last_name=[$2], i_current_price=[$3], i_size=[$4], i_units=[$5], i_manager_id=[$6], s_store_name=[$7], s_state=[$8], $f9=[$9])
+          HiveAggregate(group=[{0, 6, 7, 15, 16, 18, 19, 21, 23}], agg#0=[sum($13)])
+            HiveJoin(condition=[AND(=($8, UPPER($2)), =($24, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_state=[$8], ca_zip=[$9], ca_country=[$10])
+                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                  HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($14))])
+                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                        HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($7), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[CAST(_UTF-16LE'orchid'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_units=[$18], i_manager_id=[$20])
+                        HiveFilter(condition=[AND(=($17, _UTF-16LE'orchid'), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveProject(s_store_sk=[$0], s_store_name=[$5], s_market_id=[CAST(7):INTEGER], s_state=[$24], s_zip=[$25])
+                      HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($0), IS NOT NULL($25))])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+    HiveProject(_o__c0=[*(0.05, /($0, $1))])
+      HiveAggregate(group=[{}], agg#0=[sum($10)], agg#1=[count($10)])
+        HiveProject(c_first_name=[$0], c_last_name=[$1], s_store_name=[$2], s_state=[$3], i_current_price=[$4], i_size=[$5], i_color=[$6], i_units=[$7], i_manager_id=[$8], ca_state=[$9], $f10=[$10])
+          HiveAggregate(group=[{3, 4, 12, 14, 17, 18, 19, 20, 21, 22}], agg#0=[sum($10)])
+            HiveJoin(condition=[AND(=($5, UPPER($24)), =($15, $23))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                  HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveJoin(condition=[=($4, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($14))])
+                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                    HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                        HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($7), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(s_store_sk=[$0], s_store_name=[$5], s_market_id=[CAST(7):INTEGER], s_state=[$24], s_zip=[$25])
+                        HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($0), IS NOT NULL($25))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+                  HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[$17], i_units=[$18], i_manager_id=[$20])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(ca_state=[$8], ca_zip=[$9], ca_country=[$10])
+                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query25.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query25.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query25.q.out
new file mode 100644
index 0000000..88e0cf0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query25.q.out
@@ -0,0 +1,146 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], s_store_id=[$2], s_store_name=[$3], $f4=[$4], $f5=[$5], $f6=[$6])
+    HiveAggregate(group=[{1, 2, 28, 29}], agg#0=[sum($8)], agg#1=[sum($23)], agg#2=[sum($15)])
+      HiveJoin(condition=[=($27, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[AND(AND(=($2, $18), =($1, $17)), =($4, $19))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_net_profit=[$22])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(4):INTEGER])
+                HiveFilter(condition=[AND(=($8, 4), =($6, 2000), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2], cs_net_profit=[$3], d_date_sk=[$4], d_year=[$5], d_moy=[$6], sr_returned_date_sk=[$7], sr_item_sk=[$8], sr_customer_sk=[$9], sr_ticket_number=[$10], sr_net_loss=[$11], d_date_sk0=[$12], d_year0=[$13], d_moy0=[$14])
+              HiveJoin(condition=[AND(=($9, $1), =($8, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_net_profit=[$33])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($15), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[$8])
+                    HiveFilter(condition=[AND(BETWEEN(false, $8, 4, 10), =($6, 2000), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$1], sr_customer_sk=[$2], sr_ticket_number=[$3], sr_net_loss=[$4], d_date_sk=[$5], d_year=[$6], d_moy=[$7])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9], sr_net_loss=[$19])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[$8])
+                      HiveFilter(condition=[AND(BETWEEN(false, $8, 4, 10), =($6, 2000), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+        HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, store]], table:alias=[store])
+


[33/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query42.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query42.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query42.q.out
new file mode 100644
index 0000000..8f2f79f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query42.q.out
@@ -0,0 +1,68 @@
+PREHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_category_id
+ 	,item.i_category
+ 	,sum(ss_ext_sales_price)
+ 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_manager_id = 1  	
+ 	and dt.d_moy=12
+ 	and dt.d_year=1998
+ group by 	dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_category_id
+ 	,item.i_category
+ 	,sum(ss_ext_sales_price)
+ 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_manager_id = 1  	
+ 	and dt.d_moy=12
+ 	and dt.d_year=1998
+ group by 	dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject(d_year=[CAST(1998):INTEGER], i_category_id=[$0], i_category=[$1], _o__c3=[$2])
+    HiveSortLimit(sort0=[$3], sort1=[$0], sort2=[$1], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC])
+      HiveProject(i_category_id=[$0], i_category=[$1], _o__c3=[$2], (tok_function sum (tok_table_or_col ss_ext_sales_price))=[$2])
+        HiveAggregate(group=[{5, 6}], agg#0=[sum($2)])
+          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[AND(=($8, 12), =($6, 1998))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[dt])
+            HiveProject(i_item_sk=[$0], i_category_id=[$11], i_category=[$12])
+              HiveFilter(condition=[=($20, 1)])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out
new file mode 100644
index 0000000..6b21ee4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query43.q.out
@@ -0,0 +1,61 @@
+PREHOOK: query: explain cbo
+select  s_store_name, s_store_id,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from date_dim, store_sales, store
+ where d_date_sk = ss_sold_date_sk and
+       s_store_sk = ss_store_sk and
+       s_gmt_offset = -6 and
+       d_year = 1998 
+ group by s_store_name, s_store_id
+ order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  s_store_name, s_store_id,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from date_dim, store_sales, store
+ where d_date_sk = ss_sold_date_sk and
+       s_store_sk = ss_store_sk and
+       s_gmt_offset = -6 and
+       d_year = 1998 
+ group by s_store_name, s_store_id
+ order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
+    HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
+      HiveProject($f0=[$13], $f1=[$12], $f2=[CASE($4, $2, null)], $f3=[CASE($5, $2, null)], $f4=[CASE($6, $2, null)], $f5=[CASE($7, $2, null)], $f6=[CASE($8, $2, null)], $f7=[CASE($9, $2, null)], $f8=[CASE($10, $2, null)])
+        HiveJoin(condition=[=($11, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0], ==[=($14, _UTF-16LE'Sunday')], =2=[=($14, _UTF-16LE'Monday')], =3=[=($14, _UTF-16LE'Tuesday')], =4=[=($14, _UTF-16LE'Wednesday')], =5=[=($14, _UTF-16LE'Thursday')], =6=[=($14, _UTF-16LE'Friday')], =7=[=($14, _UTF-16LE'Saturday')])
+              HiveFilter(condition=[=($6, 1998)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
+            HiveFilter(condition=[=($27, -6)])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query44.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query44.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query44.q.out
new file mode 100644
index 0000000..8cc89f6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query44.q.out
@@ -0,0 +1,113 @@
+Warning: Shuffle Join MERGEJOIN[101][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain cbo
+select  asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
+from(select *
+     from (select item_sk,rank() over (order by rank_col asc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col 
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V1)V11
+     where rnk  < 11) asceding,
+    (select *
+     from (select item_sk,rank() over (order by rank_col desc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V2)V21
+     where rnk  < 11) descending,
+item i1,
+item i2
+where asceding.rnk = descending.rnk 
+  and i1.i_item_sk=asceding.item_sk
+  and i2.i_item_sk=descending.item_sk
+order by asceding.rnk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
+from(select *
+     from (select item_sk,rank() over (order by rank_col asc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col 
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V1)V11
+     where rnk  < 11) asceding,
+    (select *
+     from (select item_sk,rank() over (order by rank_col desc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V2)V21
+     where rnk  < 11) descending,
+item i1,
+item i2
+where asceding.rnk = descending.rnk 
+  and i1.i_item_sk=asceding.item_sk
+  and i2.i_item_sk=descending.item_sk
+order by asceding.rnk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(rnk=[$3], best_performing=[$1], worst_performing=[$5])
+    HiveJoin(condition=[=($3, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_product_name=[$21])
+          HiveTableScan(table=[[default, item]], table:alias=[i1])
+        HiveProject(item_sk=[$0], rank_window_0=[$1])
+          HiveFilter(condition=[<($1, 11)])
+            HiveProject(item_sk=[$0], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY $1 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+              HiveJoin(condition=[>($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f0=[$0], $f1=[/($1, $2)])
+                  HiveAggregate(group=[{2}], agg#0=[sum($22)], agg#1=[count($22)])
+                    HiveFilter(condition=[=($7, 410)])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[ss1])
+                HiveProject(*=[*(0.9, /($1, $2))])
+                  HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[count($1)])
+                    HiveProject($f0=[true], $f1=[$22])
+                      HiveFilter(condition=[AND(=($7, 410), IS NULL($5))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+      HiveProject(i_item_sk=[$0], i_product_name=[$1], item_sk=[$2], rank_window_0=[$3])
+        HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_product_name=[$21])
+            HiveTableScan(table=[[default, item]], table:alias=[i2])
+          HiveProject(item_sk=[$0], rank_window_0=[$1])
+            HiveFilter(condition=[<($1, 11)])
+              HiveProject(item_sk=[$0], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY $1 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveJoin(condition=[>($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject($f0=[$0], $f1=[/($1, $2)])
+                    HiveAggregate(group=[{2}], agg#0=[sum($22)], agg#1=[count($22)])
+                      HiveFilter(condition=[=($7, 410)])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[ss1])
+                  HiveProject(*=[*(0.9, /($1, $2))])
+                    HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[count($1)])
+                      HiveProject($f0=[true], $f1=[$22])
+                        HiveFilter(condition=[AND(=($7, 410), IS NULL($5))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query45.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query45.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query45.q.out
new file mode 100644
index 0000000..85f8116
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query45.q.out
@@ -0,0 +1,81 @@
+PREHOOK: query: explain cbo
+select  ca_zip, ca_county, sum(ws_sales_price)
+ from web_sales, customer, customer_address, date_dim, item
+ where ws_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ws_item_sk = i_item_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
+ 	      or 
+ 	      i_item_id in (select i_item_id
+                             from item
+                             where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                             )
+ 	    )
+ 	and ws_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip, ca_county
+ order by ca_zip, ca_county
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  ca_zip, ca_county, sum(ws_sales_price)
+ from web_sales, customer, customer_address, date_dim, item
+ where ws_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ws_item_sk = i_item_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
+ 	      or 
+ 	      i_item_id in (select i_item_id
+                             from item
+                             where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                             )
+ 	    )
+ 	and ws_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip, ca_county
+ order by ca_zip, ca_county
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(ca_zip=[$1], ca_county=[$0], $f2=[$2])
+    HiveAggregate(group=[{7, 8}], agg#0=[sum($3)])
+      HiveFilter(condition=[OR(IN(substr($8, 1, 5), _UTF-16LE'85669', _UTF-16LE'86197', _UTF-16LE'88274', _UTF-16LE'83405', _UTF-16LE'86475', _UTF-16LE'85392', _UTF-16LE'85460', _UTF-16LE'80348', _UTF-16LE'81792'), IS NOT NULL($15))])
+        HiveProject(ws_sold_date_sk=[$9], ws_item_sk=[$10], ws_bill_customer_sk=[$11], ws_sales_price=[$12], c_customer_sk=[$0], c_current_addr_sk=[$1], ca_address_sk=[$2], ca_county=[$3], ca_zip=[$4], d_date_sk=[$13], d_year=[$14], d_qoy=[$15], i_item_sk=[$5], i_item_id=[$6], i_item_id0=[$7], i1160=[$8])
+          HiveJoin(condition=[=($11, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                HiveFilter(condition=[IS NOT NULL($4)])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7], ca_zip=[$9])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_id0=[$2], i1160=[$3], ws_sold_date_sk=[$4], ws_item_sk=[$5], ws_bill_customer_sk=[$6], ws_sales_price=[$7], d_date_sk=[$8], d_year=[$9], d_qoy=[$10])
+              HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[left], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0], i1160=[true])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[IN($0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29)])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$1], ws_bill_customer_sk=[$2], ws_sales_price=[$3], d_date_sk=[$4], d_year=[$5], d_qoy=[$6])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_customer_sk=[$4], ws_sales_price=[$21])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(2):INTEGER])
+                      HiveFilter(condition=[AND(=($10, 2), =($6, 2000))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query46.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query46.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query46.q.out
new file mode 100644
index 0000000..df36f9b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query46.q.out
@@ -0,0 +1,113 @@
+PREHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,amt,profit 
+ from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,ca_city bought_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics,customer_address 
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and store_sales.ss_addr_sk = customer_address.ca_address_sk
+    and (household_demographics.hd_dep_count = 2 or
+         household_demographics.hd_vehicle_count= 1)
+    and date_dim.d_dow in (6,0)
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_city in ('Cedar Grove','Wildwood','Union','Salem','Highland Park') 
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
+    where ss_customer_sk = c_customer_sk
+      and customer.c_current_addr_sk = current_addr.ca_address_sk
+      and current_addr.ca_city <> bought_city
+  order by c_last_name
+          ,c_first_name
+          ,ca_city
+          ,bought_city
+          ,ss_ticket_number
+  limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,amt,profit 
+ from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,ca_city bought_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics,customer_address 
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and store_sales.ss_addr_sk = customer_address.ca_address_sk
+    and (household_demographics.hd_dep_count = 2 or
+         household_demographics.hd_vehicle_count= 1)
+    and date_dim.d_dow in (6,0)
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_city in ('Cedar Grove','Wildwood','Union','Salem','Highland Park') 
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
+    where ss_customer_sk = c_customer_sk
+      and customer.c_current_addr_sk = current_addr.ca_address_sk
+      and current_addr.ca_city <> bought_city
+  order by c_last_name
+          ,c_first_name
+          ,ca_city
+          ,bought_city
+          ,ss_ticket_number
+  limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], ca_city=[$5], bought_city=[$8], ss_ticket_number=[$6], amt=[$9], profit=[$10])
+    HiveJoin(condition=[AND(<>($5, $8), =($7, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9])
+          HiveFilter(condition=[IS NOT NULL($4)])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ca_address_sk=[$0], ca_city=[$6])
+          HiveTableScan(table=[[default, customer_address]], table:alias=[current_addr])
+      HiveProject(ss_ticket_number=[$3], ss_customer_sk=[$1], bought_city=[$0], amt=[$4], profit=[$5])
+        HiveAggregate(group=[{1, 3, 5, 7}], agg#0=[sum($8)], agg#1=[sum($9)])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ca_address_sk=[$0], ca_city=[$6])
+              HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($4, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_coupon_amt=[$19], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($6), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(IN($7, 6, 0), IN($6, 1998, 1999, 2000))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0])
+                  HiveFilter(condition=[IN($22, _UTF-16LE'Cedar Grove', _UTF-16LE'Wildwood', _UTF-16LE'Union', _UTF-16LE'Salem', _UTF-16LE'Highland Park')])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(hd_demo_sk=[$0])
+                HiveFilter(condition=[OR(=($3, 2), =($4, 1))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query47.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query47.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query47.q.out
new file mode 100644
index 0000000..3c90232
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query47.q.out
@@ -0,0 +1,177 @@
+PREHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        s_store_name, s_company_name,
+        d_year, d_moy,
+        sum(ss_sales_price) sum_sales,
+        avg(sum(ss_sales_price)) over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name
+           order by d_year, d_moy) rn
+ from item, store_sales, date_dim, store
+ where ss_item_sk = i_item_sk and
+       ss_sold_date_sk = d_date_sk and
+       ss_store_sk = s_store_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          s_store_name, s_company_name,
+          d_year, d_moy),
+ v2 as(
+ select v1.i_category
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1.s_store_name = v1_lag.s_store_name and
+       v1.s_store_name = v1_lead.s_store_name and
+       v1.s_company_name = v1_lag.s_company_name and
+       v1.s_company_name = v1_lead.s_company_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and    
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        s_store_name, s_company_name,
+        d_year, d_moy,
+        sum(ss_sales_price) sum_sales,
+        avg(sum(ss_sales_price)) over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name
+           order by d_year, d_moy) rn
+ from item, store_sales, date_dim, store
+ where ss_item_sk = i_item_sk and
+       ss_sold_date_sk = d_date_sk and
+       ss_store_sk = s_store_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          s_store_name, s_company_name,
+          d_year, d_moy),
+ v2 as(
+ select v1.i_category
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1.s_store_name = v1_lag.s_store_name and
+       v1.s_store_name = v1_lead.s_store_name and
+       v1.s_company_name = v1_lag.s_company_name and
+       v1.s_company_name = v1_lead.s_company_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and    
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_category=[$0], d_year=[$1], d_moy=[$2], avg_monthly_sales=[$3], sum_sales=[$4], psum=[$5], nsum=[$6])
+  HiveSortLimit(sort0=[$7], sort1=[$2], dir0=[ASC], dir1=[ASC], fetch=[100])
+    HiveProject(i_category=[$12], d_year=[$16], d_moy=[$17], avg_monthly_sales=[$19], sum_sales=[$18], psum=[$10], nsum=[$4], (- (tok_table_or_col sum_sales) (tok_table_or_col avg_monthly_sales))=[-($18, $19)])
+      HiveJoin(condition=[AND(AND(AND(AND(=($12, $0), =($13, $1)), =($14, $2)), =($15, $3)), =($20, $5))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col s_store_name)=[$2], (tok_table_or_col s_company_name)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$4], -=[-($5, 1)])
+          HiveFilter(condition=[IS NOT NULL($5)])
+            HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4, $5 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+              HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+                HiveAggregate(group=[{1, 2, 8, 9, 11, 12}], agg#0=[sum($6)])
+                  HiveJoin(condition=[=($5, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                        HiveFilter(condition=[AND(IS NOT NULL($12), IS NOT NULL($8))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                          HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                      HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($17))])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+        HiveJoin(condition=[AND(AND(AND(AND(=($6, $0), =($7, $1)), =($8, $2)), =($9, $3)), =($14, $5))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col s_store_name)=[$2], (tok_table_or_col s_company_name)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$4], +=[+($5, 1)])
+            HiveFilter(condition=[IS NOT NULL($5)])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4, $5 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11, 12}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                          HiveFilter(condition=[AND(IS NOT NULL($12), IS NOT NULL($8))])
+                            HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                        HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($17))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col s_store_name)=[$2], (tok_table_or_col s_company_name)=[$3], (tok_table_or_col d_year)=[$4], (tok_table_or_col d_moy)=[$5], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[$7], rank_window_1=[$8])
+            HiveFilter(condition=[AND(=($4, 2000), >($7, 0), CASE(>($7, 0), >(/(ABS(-($6, $7)), $7), 0.1), null), IS NOT NULL($8))])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_table_or_col d_year)=[$2], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[avg($6) OVER (PARTITION BY $1, $0, $4, $5, $2 ORDER BY $1 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $5 NULLS FIRST, $2 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4, $5 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11, 12}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                          HiveFilter(condition=[AND(IS NOT NULL($12), IS NOT NULL($8))])
+                            HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                        HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($17))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query48.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query48.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query48.q.out
new file mode 100644
index 0000000..12d5934
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query48.q.out
@@ -0,0 +1,160 @@
+PREHOOK: query: explain cbo
+select sum (ss_quantity)
+ from store_sales, store, customer_demographics, customer_address, date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 1998
+ and  
+ (
+  (
+   cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 100.00 and 150.00  
+   )
+ or
+  (
+  cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 50.00 and 100.00   
+  )
+ or 
+ (
+  cd_demo_sk = ss_cdemo_sk
+  and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 150.00 and 200.00  
+ )
+ )
+ and
+ (
+  (
+  ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 0 and 2000  
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 3000 
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 25000 
+  )
+ )
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select sum (ss_quantity)
+ from store_sales, store, customer_demographics, customer_address, date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 1998
+ and  
+ (
+  (
+   cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 100.00 and 150.00  
+   )
+ or
+  (
+  cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 50.00 and 100.00   
+  )
+ or 
+ (
+  cd_demo_sk = ss_cdemo_sk
+  and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 150.00 and 200.00  
+ )
+ )
+ and
+ (
+  (
+  ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 0 and 2000  
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 3000 
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 25000 
+  )
+ )
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveAggregate(group=[{}], agg#0=[sum($9)])
+  HiveJoin(condition=[AND(=($8, $0), OR(AND($1, $10), AND($2, $11), AND($3, $12)))], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM')], IN2=[IN($8, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN')], IN3=[IN($8, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV')])
+      HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'))])
+        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+    HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(d_date_sk=[$0])
+        HiveFilter(condition=[=($6, 1998)])
+          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(cd_demo_sk=[$0])
+          HiveFilter(condition=[AND(=($2, _UTF-16LE'M'), =($3, _UTF-16LE'4 yr Degree'))])
+            HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+        HiveProject(ss_sold_date_sk=[$0], ss_cdemo_sk=[$4], ss_addr_sk=[$6], ss_quantity=[$10], BETWEEN=[BETWEEN(false, $22, 0, 2000)], BETWEEN6=[BETWEEN(false, $22, 150, 3000)], BETWEEN7=[BETWEEN(false, $22, 50, 25000)])
+          HiveFilter(condition=[AND(OR(BETWEEN(false, $13, 100, 150), BETWEEN(false, $13, 50, 100), BETWEEN(false, $13, 150, 200)), OR(BETWEEN(false, $22, 0, 2000), BETWEEN(false, $22, 150, 3000), BETWEEN(false, $22, 50, 25000)), IS NOT NULL($7), IS NOT NULL($4), IS NOT NULL($6), IS NOT NULL($0))])
+            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out
new file mode 100644
index 0000000..bc108db
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query49.q.out
@@ -0,0 +1,330 @@
+PREHOOK: query: explain cbo
+select  
+ 'web' as channel
+ ,web.item
+ ,web.return_ratio
+ ,web.return_rank
+ ,web.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select ws.ws_item_sk as item
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		 web_sales ws left outer join web_returns wr 
+ 			on (ws.ws_order_number = wr.wr_order_number and 
+ 			ws.ws_item_sk = wr.wr_item_sk)
+                 ,date_dim
+ 		where 
+ 			wr.wr_return_amt > 10000 
+ 			and ws.ws_net_profit > 1
+                         and ws.ws_net_paid > 0
+                         and ws.ws_quantity > 0
+                         and ws_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by ws.ws_item_sk
+ 	) in_web
+ ) web
+ where 
+ (
+ web.return_rank <= 10
+ or
+ web.currency_rank <= 10
+ )
+ union
+ select 
+ 'catalog' as channel
+ ,catalog.item
+ ,catalog.return_ratio
+ ,catalog.return_rank
+ ,catalog.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select 
+ 		cs.cs_item_sk as item
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		catalog_sales cs left outer join catalog_returns cr
+ 			on (cs.cs_order_number = cr.cr_order_number and 
+ 			cs.cs_item_sk = cr.cr_item_sk)
+                ,date_dim
+ 		where 
+ 			cr.cr_return_amount > 10000 
+ 			and cs.cs_net_profit > 1
+                         and cs.cs_net_paid > 0
+                         and cs.cs_quantity > 0
+                         and cs_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+                 group by cs.cs_item_sk
+ 	) in_cat
+ ) catalog
+ where 
+ (
+ catalog.return_rank <= 10
+ or
+ catalog.currency_rank <=10
+ )
+ union
+ select 
+ 'store' as channel
+ ,store.item
+ ,store.return_ratio
+ ,store.return_rank
+ ,store.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select sts.ss_item_sk as item
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		store_sales sts left outer join store_returns sr
+ 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
+                ,date_dim
+ 		where 
+ 			sr.sr_return_amt > 10000 
+ 			and sts.ss_net_profit > 1
+                         and sts.ss_net_paid > 0 
+                         and sts.ss_quantity > 0
+                         and ss_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by sts.ss_item_sk
+ 	) in_store
+ ) store
+ where  (
+ store.return_rank <= 10
+ or 
+ store.currency_rank <= 10
+ )
+ order by 1,4,5
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+ 'web' as channel
+ ,web.item
+ ,web.return_ratio
+ ,web.return_rank
+ ,web.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select ws.ws_item_sk as item
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		 web_sales ws left outer join web_returns wr 
+ 			on (ws.ws_order_number = wr.wr_order_number and 
+ 			ws.ws_item_sk = wr.wr_item_sk)
+                 ,date_dim
+ 		where 
+ 			wr.wr_return_amt > 10000 
+ 			and ws.ws_net_profit > 1
+                         and ws.ws_net_paid > 0
+                         and ws.ws_quantity > 0
+                         and ws_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by ws.ws_item_sk
+ 	) in_web
+ ) web
+ where 
+ (
+ web.return_rank <= 10
+ or
+ web.currency_rank <= 10
+ )
+ union
+ select 
+ 'catalog' as channel
+ ,catalog.item
+ ,catalog.return_ratio
+ ,catalog.return_rank
+ ,catalog.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select 
+ 		cs.cs_item_sk as item
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		catalog_sales cs left outer join catalog_returns cr
+ 			on (cs.cs_order_number = cr.cr_order_number and 
+ 			cs.cs_item_sk = cr.cr_item_sk)
+                ,date_dim
+ 		where 
+ 			cr.cr_return_amount > 10000 
+ 			and cs.cs_net_profit > 1
+                         and cs.cs_net_paid > 0
+                         and cs.cs_quantity > 0
+                         and cs_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+                 group by cs.cs_item_sk
+ 	) in_cat
+ ) catalog
+ where 
+ (
+ catalog.return_rank <= 10
+ or
+ catalog.currency_rank <=10
+ )
+ union
+ select 
+ 'store' as channel
+ ,store.item
+ ,store.return_ratio
+ ,store.return_rank
+ ,store.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select sts.ss_item_sk as item
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		store_sales sts left outer join store_returns sr
+ 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
+                ,date_dim
+ 		where 
+ 			sr.sr_return_amt > 10000 
+ 			and sts.ss_net_profit > 1
+                         and sts.ss_net_paid > 0 
+                         and sts.ss_quantity > 0
+                         and ss_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by sts.ss_item_sk
+ 	) in_store
+ ) store
+ where  (
+ store.return_rank <= 10
+ or 
+ store.currency_rank <= 10
+ )
+ order by 1,4,5
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+    HiveAggregate(group=[{0, 1, 2, 3, 4}])
+      HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+            HiveAggregate(group=[{0, 1, 2, 3, 4}])
+              HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+                HiveUnion(all=[true])
+                  HiveProject(channel=[_UTF-16LE'web'], item=[$0], return_ratio=[$1], return_rank=[$2], currency_rank=[$3])
+                    HiveFilter(condition=[OR(<=($2, 10), <=($3, 10))])
+                      HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                          HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
+                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15])
+                                  HiveFilter(condition=[>($15, 10000)])
+                                    HiveTableScan(table=[[default, web_returns]], table:alias=[wr])
+                                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], ws_quantity=[$18], ws_net_paid=[$29], ws_net_profit=[$33])
+                                    HiveFilter(condition=[AND(>($33, 1), >($29, 0), >($18, 0), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, web_sales]], table:alias=[ws])
+                                  HiveProject(d_date_sk=[$0])
+                                    HiveFilter(condition=[AND(=($6, 2000), =($8, 12))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(channel=[_UTF-16LE'catalog'], item=[$0], return_ratio=[$1], return_rank=[$2], currency_rank=[$3])
+                    HiveFilter(condition=[OR(<=($2, 10), <=($3, 10))])
+                      HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                          HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
+                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_quantity=[$17], cr_return_amount=[$18])
+                                  HiveFilter(condition=[>($18, 10000)])
+                                    HiveTableScan(table=[[default, catalog_returns]], table:alias=[cr])
+                                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_net_paid=[$29], cs_net_profit=[$33])
+                                    HiveFilter(condition=[AND(>($33, 1), >($29, 0), >($18, 0), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs])
+                                  HiveProject(d_date_sk=[$0])
+                                    HiveFilter(condition=[AND(=($6, 2000), =($8, 12))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'store'], item=[$0], return_ratio=[$1], return_rank=[$2], currency_rank=[$3])
+            HiveFilter(condition=[OR(<=($2, 10), <=($3, 10))])
+              HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                  HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
+                    HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                      HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_quantity=[$10], sr_return_amt=[$11])
+                          HiveFilter(condition=[>($11, 10000)])
+                            HiveTableScan(table=[[default, store_returns]], table:alias=[sr])
+                        HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], ss_quantity=[$10], ss_net_paid=[$20], ss_net_profit=[$22])
+                            HiveFilter(condition=[AND(>($22, 1), >($20, 0), >($10, 0), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[sts])
+                          HiveProject(d_date_sk=[$0])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 12))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query5.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query5.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query5.q.out
new file mode 100644
index 0000000..54f3dd6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query5.q.out
@@ -0,0 +1,339 @@
+PREHOOK: query: explain cbo
+with ssr as
+ (select s_store_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ss_store_sk as store_sk,
+            ss_sold_date_sk  as date_sk,
+            ss_ext_sales_price as sales_price,
+            ss_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from store_sales
+    union all
+    select sr_store_sk as store_sk,
+           sr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           sr_return_amt as return_amt,
+           sr_net_loss as net_loss
+    from store_returns
+   ) salesreturns,
+     date_dim,
+     store
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  14 days)
+       and store_sk = s_store_sk
+ group by s_store_id)
+ ,
+ csr as
+ (select cp_catalog_page_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  cs_catalog_page_sk as page_sk,
+            cs_sold_date_sk  as date_sk,
+            cs_ext_sales_price as sales_price,
+            cs_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from catalog_sales
+    union all
+    select cr_catalog_page_sk as page_sk,
+           cr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           cr_return_amount as return_amt,
+           cr_net_loss as net_loss
+    from catalog_returns
+   ) salesreturns,
+     date_dim,
+     catalog_page
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and page_sk = cp_catalog_page_sk
+ group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select web_site_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ws_web_site_sk as wsr_web_site_sk,
+            ws_sold_date_sk  as date_sk,
+            ws_ext_sales_price as sales_price,
+            ws_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from web_sales
+    union all
+    select ws_web_site_sk as wsr_web_site_sk,
+           wr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           wr_return_amt as return_amt,
+           wr_net_loss as net_loss
+    from web_returns left outer join web_sales on
+         ( wr_item_sk = ws_item_sk
+           and wr_order_number = ws_order_number)
+   ) salesreturns,
+     date_dim,
+     web_site
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and wsr_web_site_sk = web_site_sk
+ group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || s_store_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || cp_catalog_page_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_page
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssr as
+ (select s_store_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ss_store_sk as store_sk,
+            ss_sold_date_sk  as date_sk,
+            ss_ext_sales_price as sales_price,
+            ss_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from store_sales
+    union all
+    select sr_store_sk as store_sk,
+           sr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           sr_return_amt as return_amt,
+           sr_net_loss as net_loss
+    from store_returns
+   ) salesreturns,
+     date_dim,
+     store
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  14 days)
+       and store_sk = s_store_sk
+ group by s_store_id)
+ ,
+ csr as
+ (select cp_catalog_page_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  cs_catalog_page_sk as page_sk,
+            cs_sold_date_sk  as date_sk,
+            cs_ext_sales_price as sales_price,
+            cs_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from catalog_sales
+    union all
+    select cr_catalog_page_sk as page_sk,
+           cr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           cr_return_amount as return_amt,
+           cr_net_loss as net_loss
+    from catalog_returns
+   ) salesreturns,
+     date_dim,
+     catalog_page
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and page_sk = cp_catalog_page_sk
+ group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select web_site_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ws_web_site_sk as wsr_web_site_sk,
+            ws_sold_date_sk  as date_sk,
+            ws_ext_sales_price as sales_price,
+            ws_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from web_sales
+    union all
+    select ws_web_site_sk as wsr_web_site_sk,
+           wr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           wr_return_amt as return_amt,
+           wr_net_loss as net_loss
+    from web_returns left outer join web_sales on
+         ( wr_item_sk = ws_item_sk
+           and wr_order_number = ws_order_number)
+   ) salesreturns,
+     date_dim,
+     web_site
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and wsr_web_site_sk = web_site_sk
+ group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || s_store_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || cp_catalog_page_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_page
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(channel=[$0], id=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
+      HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store channel'], id=[||(_UTF-16LE'store', $0)], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveAggregate(group=[{8}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)])
+              HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(store_sk=[$0], date_sk=[$1], sales_price=[$2], profit=[$3], return_amt=[$4], net_loss=[$5])
+                    HiveUnion(all=[true])
+                      HiveProject(store_sk=[$7], date_sk=[$0], sales_price=[$15], profit=[$22], return_amt=[CAST(0):DECIMAL(7, 2)], net_loss=[CAST(0):DECIMAL(7, 2)])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(store_sk=[$7], date_sk=[$0], sales_price=[CAST(0):DECIMAL(7, 2)], profit=[CAST(0):DECIMAL(7, 2)], return_amt=[$11], net_loss=[$19])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-08-18 00:00:00)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_store_id=[$1])
+                  HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveProject(channel=[_UTF-16LE'catalog channel'], id=[||(_UTF-16LE'catalog_page', $0)], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveAggregate(group=[{1}], agg#0=[sum($4)], agg#1=[sum($5)], agg#2=[sum($6)], agg#3=[sum($7)])
+              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cp_catalog_page_sk=[$0], cp_catalog_page_id=[$1])
+                  HiveTableScan(table=[[default, catalog_page]], table:alias=[catalog_page])
+                HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(page_sk=[$0], date_sk=[$1], sales_price=[$2], profit=[$3], return_amt=[$4], net_loss=[$5])
+                    HiveUnion(all=[true])
+                      HiveProject(page_sk=[$12], date_sk=[$0], sales_price=[$23], profit=[$33], return_amt=[CAST(0):DECIMAL(7, 2)], net_loss=[CAST(0):DECIMAL(7, 2)])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(page_sk=[$12], date_sk=[$0], sales_price=[CAST(0):DECIMAL(7, 2)], profit=[CAST(0):DECIMAL(7, 2)], return_amt=[$18], net_loss=[$26])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12))])
+                          HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-08-18 00:00:00)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'web channel'], id=[||(_UTF-16LE'web_site', $0)], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveAggregate(group=[{8}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)])
+              HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(wsr_web_site_sk=[$0], date_sk=[$1], sales_price=[$2], profit=[$3], return_amt=[$4], net_loss=[$5])
+                    HiveUnion(all=[true])
+                      HiveProject(wsr_web_site_sk=[$13], date_sk=[$0], sales_price=[$23], profit=[$33], return_amt=[CAST(0):DECIMAL(7, 2)], net_loss=[CAST(0):DECIMAL(7, 2)])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($13))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(ws_web_site_sk=[$1], wr_returned_date_sk=[$3], $f2=[CAST(0):DECIMAL(7, 2)], $f3=[CAST(0):DECIMAL(7, 2)], wr_return_amt=[$6], wr_net_loss=[$7])
+                        HiveJoin(condition=[AND(=($4, $0), =($5, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ws_item_sk=[$3], ws_web_site_sk=[$13], ws_order_number=[$17])
+                            HiveFilter(condition=[IS NOT NULL($13)])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(wr_returned_date_sk=[$0], wr_item_sk=[$2], wr_order_number=[$13], wr_return_amt=[$15], wr_net_loss=[$23])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-08-18 00:00:00)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(web_site_sk=[$0], web_site_id=[$1])
+                  HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query50.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query50.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query50.q.out
new file mode 100644
index 0000000..49c87ee
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query50.q.out
@@ -0,0 +1,146 @@
+PREHOOK: query: explain cbo
+select  
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   store_sales
+  ,store_returns
+  ,store
+  ,date_dim d1
+  ,date_dim d2
+where
+    d2.d_year = 2000
+and d2.d_moy  = 9
+and ss_ticket_number = sr_ticket_number
+and ss_item_sk = sr_item_sk
+and ss_sold_date_sk   = d1.d_date_sk
+and sr_returned_date_sk   = d2.d_date_sk
+and ss_customer_sk = sr_customer_sk
+and ss_store_sk = s_store_sk
+group by
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+order by s_store_name
+        ,s_company_id
+        ,s_street_number
+        ,s_street_name
+        ,s_street_type
+        ,s_suite_number
+        ,s_city
+        ,s_county
+        ,s_state
+        ,s_zip
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   store_sales
+  ,store_returns
+  ,store
+  ,date_dim d1
+  ,date_dim d2
+where
+    d2.d_year = 2000
+and d2.d_moy  = 9
+and ss_ticket_number = sr_ticket_number
+and ss_item_sk = sr_item_sk
+and ss_sold_date_sk   = d1.d_date_sk
+and sr_returned_date_sk   = d2.d_date_sk
+and ss_customer_sk = sr_customer_sk
+and ss_store_sk = s_store_sk
+group by
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+order by s_store_name
+        ,s_company_id
+        ,s_street_number
+        ,s_street_name
+        ,s_street_type
+        ,s_suite_number
+        ,s_city
+        ,s_county
+        ,s_state
+        ,s_zip
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14])
+    HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}], agg#0=[sum($10)], agg#1=[sum($11)], agg#2=[sum($12)], agg#3=[sum($13)], agg#4=[sum($14)])
+      HiveProject($f0=[$11], $f1=[$12], $f2=[$13], $f3=[$14], $f4=[$15], $f5=[$16], $f6=[$17], $f7=[$18], $f8=[$19], $f9=[$20], $f10=[CASE(<=(-($5, $0), 30), 1, 0)], $f11=[CASE(AND(>(-($5, $0), 30), <=(-($5, $0), 60)), 1, 0)], $f12=[CASE(AND(>(-($5, $0), 60), <=(-($5, $0), 90)), 1, 0)], $f13=[CASE(AND(>(-($5, $0), 90), <=(-($5, $0), 120)), 1, 0)], $f14=[CASE(>(-($5, $0), 120), 1, 0)])
+        HiveJoin(condition=[=($3, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[AND(AND(=($4, $8), =($1, $6)), =($2, $7))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9])
+              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($7), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[AND(=($6, 2000), =($8, 9))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+          HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_id=[$16], s_street_number=[$18], s_street_name=[$19], s_street_type=[$20], s_suite_number=[$21], s_city=[$22], s_county=[$23], s_state=[$24], s_zip=[$25])
+            HiveTableScan(table=[[default, store]], table:alias=[store])
+


[24/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query15.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query15.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query15.q.out
new file mode 100644
index 0000000..b41b4e3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query15.q.out
@@ -0,0 +1,142 @@
+PREHOOK: query: explain
+select  ca_zip
+       ,sum(cs_sales_price)
+ from catalog_sales
+     ,customer
+     ,customer_address
+     ,date_dim
+ where cs_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
+                                   '85392', '85460', '80348', '81792')
+ 	      or ca_state in ('CA','WA','GA')
+ 	      or cs_sales_price > 500)
+ 	and cs_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip
+ order by ca_zip
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  ca_zip
+       ,sum(cs_sales_price)
+ from catalog_sales
+     ,customer
+     ,customer_address
+     ,date_dim
+ where cs_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
+                                   '85392', '85460', '80348', '81792')
+ 	      or ca_state in ('CA','WA','GA')
+ 	      or cs_sales_price > 500)
+ 	and cs_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip
+ order by ca_zip
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 7 <- Reducer 10 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 8 <- Map 7 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_97]
+        Limit [LIM_96] (rows=100 width=201)
+          Number of rows:100
+          Select Operator [SEL_95] (rows=2555 width=201)
+            Output:["_col0","_col1"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_94]
+              Group By Operator [GBY_93] (rows=2555 width=201)
+                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_24]
+                  PartitionCols:_col0
+                  Group By Operator [GBY_23] (rows=43435 width=201)
+                    Output:["_col0","_col1"],aggregations:["sum(_col8)"],keys:_col3
+                    Top N Key Operator [TNK_43] (rows=20154874 width=205)
+                      keys:_col3,sort order:+,top n:100
+                      Select Operator [SEL_22] (rows=20154874 width=205)
+                        Output:["_col3","_col8"]
+                        Filter Operator [FIL_21] (rows=20154874 width=205)
+                          predicate:(_col4 or _col5 or _col9)
+                          Merge Join Operator [MERGEJOIN_76] (rows=20154874 width=205)
+                            Conds:RS_18._col0=RS_19._col1(Inner),Output:["_col3","_col4","_col5","_col8","_col9"]
+                          <-Reducer 2 [SIMPLE_EDGE]
+                            SHUFFLE [RS_18]
+                              PartitionCols:_col0
+                              Merge Join Operator [MERGEJOIN_74] (rows=80000000 width=101)
+                                Conds:RS_79._col1=RS_81._col0(Inner),Output:["_col0","_col3","_col4","_col5"]
+                              <-Map 1 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_79]
+                                  PartitionCols:_col1
+                                  Select Operator [SEL_78] (rows=80000000 width=8)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_77] (rows=80000000 width=8)
+                                      predicate:c_current_addr_sk is not null
+                                      TableScan [TS_0] (rows=80000000 width=8)
+                                        default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk"]
+                              <-Map 6 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_81]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_80] (rows=40000000 width=101)
+                                    Output:["_col0","_col1","_col2","_col3"]
+                                    TableScan [TS_3] (rows=40000000 width=179)
+                                      default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state","ca_zip"]
+                          <-Reducer 8 [SIMPLE_EDGE]
+                            SHUFFLE [RS_19]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_75] (rows=20154874 width=111)
+                                Conds:RS_92._col0=RS_84._col0(Inner),Output:["_col1","_col2","_col3"]
+                              <-Map 9 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_84]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_83] (rows=130 width=4)
+                                    Output:["_col0"]
+                                    Filter Operator [FIL_82] (rows=130 width=12)
+                                      predicate:((d_qoy = 2) and (d_year = 2000))
+                                      TableScan [TS_8] (rows=73049 width=12)
+                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                              <-Map 7 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_92]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_91] (rows=285117831 width=123)
+                                    Output:["_col0","_col1","_col2","_col3"]
+                                    Filter Operator [FIL_90] (rows=285117831 width=119)
+                                      predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_12_date_dim_d_date_sk_min) AND DynamicValue(RS_12_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_12_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                      TableScan [TS_5] (rows=287989836 width=119)
+                                        default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_sales_price"]
+                                      <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                        BROADCAST [RS_89]
+                                          Group By Operator [GBY_88] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                          <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_87]
+                                              Group By Operator [GBY_86] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                Select Operator [SEL_85] (rows=130 width=4)
+                                                  Output:["_col0"]
+                                                   Please refer to the previous Select Operator [SEL_83]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query16.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query16.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query16.q.out
new file mode 100644
index 0000000..3143be8
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query16.q.out
@@ -0,0 +1,244 @@
+PREHOOK: query: explain
+select  
+   count(distinct cs_order_number) as `order count`
+  ,sum(cs_ext_ship_cost) as `total shipping cost`
+  ,sum(cs_net_profit) as `total net profit`
+from
+   catalog_sales cs1
+  ,date_dim
+  ,customer_address
+  ,call_center
+where
+    d_date between '2001-4-01' and 
+           (cast('2001-4-01' as date) + 60 days)
+and cs1.cs_ship_date_sk = d_date_sk
+and cs1.cs_ship_addr_sk = ca_address_sk
+and ca_state = 'NY'
+and cs1.cs_call_center_sk = cc_call_center_sk
+and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish',
+                  'Daviess County'
+)
+and exists (select *
+            from catalog_sales cs2
+            where cs1.cs_order_number = cs2.cs_order_number
+              and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
+and not exists(select *
+               from catalog_returns cr1
+               where cs1.cs_order_number = cr1.cr_order_number)
+order by count(distinct cs_order_number)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+   count(distinct cs_order_number) as `order count`
+  ,sum(cs_ext_ship_cost) as `total shipping cost`
+  ,sum(cs_net_profit) as `total net profit`
+from
+   catalog_sales cs1
+  ,date_dim
+  ,customer_address
+  ,call_center
+where
+    d_date between '2001-4-01' and 
+           (cast('2001-4-01' as date) + 60 days)
+and cs1.cs_ship_date_sk = d_date_sk
+and cs1.cs_ship_addr_sk = ca_address_sk
+and ca_state = 'NY'
+and cs1.cs_call_center_sk = cc_call_center_sk
+and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish',
+                  'Daviess County'
+)
+and exists (select *
+            from catalog_sales cs2
+            where cs1.cs_order_number = cs2.cs_order_number
+              and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
+and not exists(select *
+               from catalog_returns cr1
+               where cs1.cs_order_number = cr1.cr_order_number)
+order by count(distinct cs_order_number)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 12 (BROADCAST_EDGE), Reducer 14 (BROADCAST_EDGE), Reducer 16 (BROADCAST_EDGE)
+Map 17 <- Reducer 10 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Map 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 11 (SIMPLE_EDGE)
+Reducer 3 <- Map 13 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 15 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 17 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Map 18 (SIMPLE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 9 vectorized
+      File Output Operator [FS_169]
+        Limit [LIM_168] (rows=1 width=240)
+          Number of rows:100
+          Select Operator [SEL_167] (rows=1 width=240)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 8 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_166]
+              Select Operator [SEL_165] (rows=1 width=240)
+                Output:["_col1","_col2","_col3"]
+                Group By Operator [GBY_164] (rows=1 width=232)
+                  Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"]
+                <-Reducer 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                  PARTITION_ONLY_SHUFFLE [RS_163]
+                    Group By Operator [GBY_162] (rows=1 width=232)
+                      Output:["_col0","_col1","_col2"],aggregations:["count(_col0)","sum(_col1)","sum(_col2)"]
+                      Group By Operator [GBY_161] (rows=5150256 width=228)
+                        Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                      <-Reducer 6 [SIMPLE_EDGE]
+                        SHUFFLE [RS_69]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_68] (rows=5150256 width=228)
+                            Output:["_col0","_col2","_col3"],aggregations:["sum(_col5)","sum(_col6)"],keys:_col4
+                            Select Operator [SEL_37] (rows=5150256 width=218)
+                              Output:["_col4","_col5","_col6"]
+                              Filter Operator [FIL_36] (rows=5150256 width=218)
+                                predicate:_col14 is null
+                                Merge Join Operator [MERGEJOIN_125] (rows=13282454 width=218)
+                                  Conds:RS_33._col4=RS_160._col0(Left Outer),Output:["_col4","_col5","_col6","_col14"]
+                                <-Map 18 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_160]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_159] (rows=28798881 width=8)
+                                      Output:["_col0","_col1"]
+                                      TableScan [TS_25] (rows=28798881 width=4)
+                                        default@catalog_returns,cr1,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_order_number"]
+                                <-Reducer 5 [ONE_TO_ONE_EDGE]
+                                  FORWARD [RS_33]
+                                    PartitionCols:_col4
+                                    Select Operator [SEL_32] (rows=5150256 width=200)
+                                      Output:["_col4","_col5","_col6"]
+                                      Merge Join Operator [MERGEJOIN_124] (rows=5150256 width=202)
+                                        Conds:RS_29._col4=RS_158._col0(Left Semi),Output:["_col3","_col4","_col5","_col6","_col14"],residual filter predicates:{(_col3 <> _col14)}
+                                      <-Reducer 4 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_29]
+                                          PartitionCols:_col4
+                                          Merge Join Operator [MERGEJOIN_123] (rows=5150256 width=200)
+                                            Conds:RS_18._col2=RS_144._col0(Inner),Output:["_col3","_col4","_col5","_col6"]
+                                          <-Map 15 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_144]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_143] (rows=10 width=102)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_142] (rows=10 width=102)
+                                                  predicate:(cc_county) IN ('Ziebach County', 'Levy County', 'Huron County', 'Franklin Parish', 'Daviess County')
+                                                  TableScan [TS_9] (rows=60 width=102)
+                                                    default@call_center,call_center,Tbl:COMPLETE,Col:COMPLETE,Output:["cc_call_center_sk","cc_county"]
+                                          <-Reducer 3 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_18]
+                                              PartitionCols:_col2
+                                              Merge Join Operator [MERGEJOIN_122] (rows=30901534 width=230)
+                                                Conds:RS_15._col1=RS_136._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6"]
+                                              <-Map 13 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_136]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_135] (rows=784314 width=90)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_134] (rows=784314 width=90)
+                                                      predicate:(ca_state = 'NY')
+                                                      TableScan [TS_6] (rows=40000000 width=90)
+                                                        default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
+                                              <-Reducer 2 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_15]
+                                                  PartitionCols:_col1
+                                                  Merge Join Operator [MERGEJOIN_121] (rows=31519516 width=234)
+                                                    Conds:RS_152._col0=RS_128._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                  <-Map 11 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_128]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_127] (rows=8116 width=98)
+                                                        Output:["_col0"]
+                                                        Filter Operator [FIL_126] (rows=8116 width=98)
+                                                          predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'2001-04-01 00:00:00' AND TIMESTAMP'2001-05-31 00:00:00'
+                                                          TableScan [TS_3] (rows=73049 width=98)
+                                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_152]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_151] (rows=283695062 width=243)
+                                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                        Filter Operator [FIL_150] (rows=283695062 width=243)
+                                                          predicate:((cs_call_center_sk BETWEEN DynamicValue(RS_19_call_center_cc_call_center_sk_min) AND DynamicValue(RS_19_call_center_cc_call_center_sk_max) and in_bloom_filter(cs_call_center_sk, DynamicValue(RS_19_call_center_cc_call_center_sk_bloom_filter))) and (cs_ship_addr_sk BETWEEN DynamicValue(RS_16_customer_address_ca_address_sk_min) AND DynamicValue(RS_16_customer_address_ca_address_sk_max) and in_bloom_filter(cs_ship_addr_sk, DynamicValue(RS_16_customer_address_ca_address_sk_bloom_filter))) and (cs_ship_date_sk BETWEEN DynamicValue(RS_13_date_dim_d_date_sk_min) AND DynamicValue(RS_13_date_dim_d_date_sk_max) and in_bloom_filter(cs_ship_date_sk, DynamicValue(RS_13_date_dim_d_date_sk_bloom_filter))) and cs_call_center_sk is not null and cs_ship_addr_sk is not null and cs_ship_date_sk is not null)
+                                                          TableScan [TS_0] (rows=287989836 width=243)
+                                                            default@catalog_sales,cs1,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_ship_date_sk","cs_ship_addr_sk","cs_call_center_sk","cs_warehouse_sk","cs_order_number","cs_ext_ship_cost","cs_net_profit"]
+                                                          <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                                            BROADCAST [RS_133]
+                                                              Group By Operator [GBY_132] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                              <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_131]
+                                                                  Group By Operator [GBY_130] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                    Select Operator [SEL_129] (rows=8116 width=4)
+                                                                      Output:["_col0"]
+                                                                       Please refer to the previous Select Operator [SEL_127]
+                                                          <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                            BROADCAST [RS_141]
+                                                              Group By Operator [GBY_140] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                              <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_139]
+                                                                  Group By Operator [GBY_138] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                    Select Operator [SEL_137] (rows=784314 width=4)
+                                                                      Output:["_col0"]
+                                                                       Please refer to the previous Select Operator [SEL_135]
+                                                          <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                            BROADCAST [RS_149]
+                                                              Group By Operator [GBY_148] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                              <-Map 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_147]
+                                                                  Group By Operator [GBY_146] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                    Select Operator [SEL_145] (rows=10 width=4)
+                                                                      Output:["_col0"]
+                                                                       Please refer to the previous Select Operator [SEL_143]
+                                      <-Map 17 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_158]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_157] (rows=286548719 width=7)
+                                            Output:["_col0","_col1"],keys:_col0, _col1
+                                            Select Operator [SEL_156] (rows=286548719 width=7)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_155] (rows=286548719 width=7)
+                                                predicate:((cs_order_number BETWEEN DynamicValue(RS_29_cs1_cs_order_number_min) AND DynamicValue(RS_29_cs1_cs_order_number_max) and in_bloom_filter(cs_order_number, DynamicValue(RS_29_cs1_cs_order_number_bloom_filter))) and cs_warehouse_sk is not null)
+                                                TableScan [TS_22] (rows=287989836 width=7)
+                                                  default@catalog_sales,cs2,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_warehouse_sk","cs_order_number"]
+                                                <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_154]
+                                                    Group By Operator [GBY_153] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_111]
+                                                        Group By Operator [GBY_110] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_109] (rows=5150256 width=8)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_123]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query17.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query17.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query17.q.out
new file mode 100644
index 0000000..e796101
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query17.q.out
@@ -0,0 +1,319 @@
+PREHOOK: query: explain
+select  i_item_id
+       ,i_item_desc
+       ,s_state
+       ,count(ss_quantity) as store_sales_quantitycount
+       ,avg(ss_quantity) as store_sales_quantityave
+       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
+       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
+       ,count(sr_return_quantity) as_store_returns_quantitycount
+       ,avg(sr_return_quantity) as_store_returns_quantityave
+       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
+       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
+       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
+ from store_sales
+     ,store_returns
+     ,catalog_sales
+     ,date_dim d1
+     ,date_dim d2
+     ,date_dim d3
+     ,store
+     ,item
+ where d1.d_quarter_name = '2000Q1'
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+ group by i_item_id
+         ,i_item_desc
+         ,s_state
+ order by i_item_id
+         ,i_item_desc
+         ,s_state
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_id
+       ,i_item_desc
+       ,s_state
+       ,count(ss_quantity) as store_sales_quantitycount
+       ,avg(ss_quantity) as store_sales_quantityave
+       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
+       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
+       ,count(sr_return_quantity) as_store_returns_quantitycount
+       ,avg(sr_return_quantity) as_store_returns_quantityave
+       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
+       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
+       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
+ from store_sales
+     ,store_returns
+     ,catalog_sales
+     ,date_dim d1
+     ,date_dim d2
+     ,date_dim d3
+     ,store
+     ,item
+ where d1.d_quarter_name = '2000Q1'
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+ group by i_item_id
+         ,i_item_desc
+         ,s_state
+ order by i_item_id
+         ,i_item_desc
+         ,s_state
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 12 (BROADCAST_EDGE), Reducer 13 (BROADCAST_EDGE), Reducer 16 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Map 19 <- Reducer 14 (BROADCAST_EDGE), Reducer 16 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Reducer 10 <- Map 19 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Reducer 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 20 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 18 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 11 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 21 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_259]
+        Limit [LIM_258] (rows=100 width=466)
+          Number of rows:100
+          Select Operator [SEL_257] (rows=4815969644 width=466)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_256]
+              Select Operator [SEL_255] (rows=4815969644 width=466)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                Group By Operator [GBY_254] (rows=4815969644 width=466)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","count(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)","sum(VALUE._col7)","count(VALUE._col8)","sum(VALUE._col9)","sum(VALUE._col10)","sum(VALUE._col11)"],keys:KEY._col0, KEY._col1, KEY._col2
+                <-Reducer 5 [SIMPLE_EDGE]
+                  SHUFFLE [RS_48]
+                    PartitionCols:_col0, _col1, _col2
+                    Group By Operator [GBY_47] (rows=4815969644 width=466)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"],aggregations:["count(_col3)","sum(_col3)","sum(_col7)","sum(_col6)","count(_col4)","sum(_col4)","sum(_col9)","sum(_col8)","count(_col5)","sum(_col5)","sum(_col11)","sum(_col10)"],keys:_col0, _col1, _col2
+                      Top N Key Operator [TNK_91] (rows=4815969644 width=381)
+                        keys:_col0, _col1, _col2,sort order:+++,top n:100
+                        Select Operator [SEL_45] (rows=4815969644 width=381)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                          Merge Join Operator [MERGEJOIN_211] (rows=4815969644 width=381)
+                            Conds:RS_42._col3=RS_253._col0(Inner),Output:["_col5","_col8","_col9","_col13","_col19","_col22"]
+                          <-Map 21 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_253]
+                              PartitionCols:_col0
+                              Select Operator [SEL_252] (rows=1704 width=90)
+                                Output:["_col0","_col1"]
+                                TableScan [TS_31] (rows=1704 width=90)
+                                  default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
+                          <-Reducer 4 [SIMPLE_EDGE]
+                            SHUFFLE [RS_42]
+                              PartitionCols:_col3
+                              Merge Join Operator [MERGEJOIN_210] (rows=4815969644 width=299)
+                                Conds:RS_39._col1, _col2, _col4=RS_40._col6, _col7, _col8(Inner),Output:["_col3","_col5","_col8","_col9","_col13","_col19"]
+                              <-Reducer 11 [SIMPLE_EDGE]
+                                SHUFFLE [RS_40]
+                                  PartitionCols:_col6, _col7, _col8
+                                  Merge Join Operator [MERGEJOIN_209] (rows=540026342 width=19)
+                                    Conds:RS_27._col2, _col1=RS_28._col1, _col2(Inner),Output:["_col3","_col6","_col7","_col8","_col9"]
+                                  <-Reducer 10 [SIMPLE_EDGE]
+                                    PARTITION_ONLY_SHUFFLE [RS_27]
+                                      PartitionCols:_col2, _col1
+                                      Merge Join Operator [MERGEJOIN_207] (rows=14254135 width=11)
+                                        Conds:RS_242._col0=RS_220._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_220]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_216] (rows=3652 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_213] (rows=3652 width=94)
+                                              predicate:(d_quarter_name) IN ('2000Q1', '2000Q2', '2000Q3')
+                                              TableScan [TS_3] (rows=73049 width=94)
+                                                default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_quarter_name"]
+                                      <-Map 19 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_242]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_241] (rows=285117831 width=15)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_240] (rows=285117831 width=15)
+                                              predicate:((cs_bill_customer_sk BETWEEN DynamicValue(RS_28_store_returns_sr_customer_sk_min) AND DynamicValue(RS_28_store_returns_sr_customer_sk_max) and in_bloom_filter(cs_bill_customer_sk, DynamicValue(RS_28_store_returns_sr_customer_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_28_store_returns_sr_item_sk_min) AND DynamicValue(RS_28_store_returns_sr_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_28_store_returns_sr_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_25_d3_d_date_sk_min) AND DynamicValue(RS_25_d3_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_25_d3_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                              TableScan [TS_8] (rows=287989836 width=15)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_quantity"]
+                                              <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_234]
+                                                  Group By Operator [GBY_232] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_109]
+                                                      Group By Operator [GBY_108] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_107] (rows=2681277 width=8)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_208] (rows=2681277 width=10)
+                                                            Conds:RS_231._col0=RS_222._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                          <-Map 8 [SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_222]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_217] (rows=3652 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_214] (rows=3652 width=94)
+                                                                  predicate:(d_quarter_name) IN ('2000Q1', '2000Q2', '2000Q3')
+                                                                   Please refer to the previous TableScan [TS_3]
+                                                          <-Map 20 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_231]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_230] (rows=53632139 width=19)
+                                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                                Filter Operator [FIL_229] (rows=53632139 width=19)
+                                                                  predicate:(sr_customer_sk is not null and sr_returned_date_sk is not null)
+                                                                  TableScan [TS_14] (rows=57591150 width=19)
+                                                                    default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number","sr_return_quantity"]
+                                              <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_239]
+                                                  Group By Operator [GBY_237] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_124]
+                                                      Group By Operator [GBY_123] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_122] (rows=2681277 width=2)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_208]
+                                              <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_236]
+                                                  Group By Operator [GBY_235] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_226]
+                                                      Group By Operator [GBY_224] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_221] (rows=3652 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_216]
+                                  <-Reducer 15 [SIMPLE_EDGE]
+                                    PARTITION_ONLY_SHUFFLE [RS_28]
+                                      PartitionCols:_col1, _col2
+                                       Please refer to the previous Merge Join Operator [MERGEJOIN_208]
+                              <-Reducer 3 [SIMPLE_EDGE]
+                                SHUFFLE [RS_39]
+                                  PartitionCols:_col1, _col2, _col4
+                                  Merge Join Operator [MERGEJOIN_206] (rows=27749405 width=294)
+                                    Conds:RS_36._col1=RS_251._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col8","_col9"]
+                                  <-Map 18 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_251]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_250] (rows=462000 width=288)
+                                        Output:["_col0","_col1","_col2"]
+                                        TableScan [TS_6] (rows=462000 width=288)
+                                          default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_item_desc"]
+                                  <-Reducer 2 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_36]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_205] (rows=27749405 width=10)
+                                        Conds:RS_249._col0=RS_218._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_218]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_215] (rows=101 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_212] (rows=101 width=94)
+                                              predicate:(d_quarter_name = '2000Q1')
+                                               Please refer to the previous TableScan [TS_3]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_249]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_248] (rows=501694138 width=23)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                            Filter Operator [FIL_247] (rows=501694138 width=23)
+                                              predicate:((ss_customer_sk BETWEEN DynamicValue(RS_27_catalog_sales_cs_bill_customer_sk_min) AND DynamicValue(RS_27_catalog_sales_cs_bill_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_27_catalog_sales_cs_bill_customer_sk_bloom_filter))) and (ss_customer_sk BETWEEN DynamicValue(RS_28_store_returns_sr_customer_sk_min) AND DynamicValue(RS_28_store_returns_sr_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_28_store_returns_sr_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_27_catalog_sales_cs_item_sk_min) AND DynamicValue(RS_27_catalog_sales_cs_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_27_catalog_sales_cs_item_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_28_store_returns_sr_item_sk_min) AND DynamicValue(RS_28_store_returns_sr_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_28_store_returns_sr_item_sk_bloom_filter))) and (ss_sold_date
 _sk BETWEEN DynamicValue(RS_34_d1_d_date_sk_min) AND DynamicValue(RS_34_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_34_d1_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                              TableScan [TS_0] (rows=575995635 width=23)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_quantity"]
+                                              <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_233]
+                                                   Please refer to the previous Group By Operator [GBY_232]
+                                              <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_238]
+                                                   Please refer to the previous Group By Operator [GBY_237]
+                                              <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_244]
+                                                  Group By Operator [GBY_243] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_114]
+                                                      Group By Operator [GBY_113] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_112] (rows=14254135 width=8)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_207]
+                                              <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_246]
+                                                  Group By Operator [GBY_245] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_129]
+                                                      Group By Operator [GBY_128] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_127] (rows=14254135 width=7)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_207]
+                                              <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_228]
+                                                  Group By Operator [GBY_227] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_225]
+                                                      Group By Operator [GBY_223] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_219] (rows=101 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_215]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out
new file mode 100644
index 0000000..ff4c05f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out
@@ -0,0 +1,239 @@
+PREHOOK: query: explain
+select  i_item_id,
+        ca_country,
+        ca_state, 
+        ca_county,
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
+ from catalog_sales, customer_demographics cd1, 
+      customer_demographics cd2, customer, customer_address, date_dim, item
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd1.cd_demo_sk and
+       cs_bill_customer_sk = c_customer_sk and
+       cd1.cd_gender = 'M' and 
+       cd1.cd_education_status = 'College' and
+       c_current_cdemo_sk = cd2.cd_demo_sk and
+       c_current_addr_sk = ca_address_sk and
+       c_birth_month in (9,5,12,4,1,10) and
+       d_year = 2001 and
+       ca_state in ('ND','WI','AL'
+                   ,'NC','OK','MS','TN')
+ group by rollup (i_item_id, ca_country, ca_state, ca_county)
+ order by ca_country,
+        ca_state, 
+        ca_county,
+	i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_id,
+        ca_country,
+        ca_state, 
+        ca_county,
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
+ from catalog_sales, customer_demographics cd1, 
+      customer_demographics cd2, customer, customer_address, date_dim, item
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd1.cd_demo_sk and
+       cs_bill_customer_sk = c_customer_sk and
+       cd1.cd_gender = 'M' and 
+       cd1.cd_education_status = 'College' and
+       c_current_cdemo_sk = cd2.cd_demo_sk and
+       c_current_addr_sk = ca_address_sk and
+       c_birth_month in (9,5,12,4,1,10) and
+       d_year = 2001 and
+       ca_state in ('ND','WI','AL'
+                   ,'NC','OK','MS','TN')
+ group by rollup (i_item_id, ca_country, ca_state, ca_county)
+ order by ca_country,
+        ca_state, 
+        ca_county,
+	i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 10 <- Reducer 15 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
+Reducer 12 <- Map 16 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Map 18 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 15 <- Map 14 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 9 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 13 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 3 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_179]
+        Limit [LIM_178] (rows=100 width=1165)
+          Number of rows:100
+          Select Operator [SEL_177] (rows=10969055 width=1165)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_176]
+              Select Operator [SEL_175] (rows=10969055 width=1165)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+                Group By Operator [GBY_174] (rows=10969055 width=1229)
+                  Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","sum(VALUE._col6)","count(VALUE._col7)","sum(VALUE._col8)","count(VALUE._col9)","sum(VALUE._col10)","count(VALUE._col11)","sum(VALUE._col12)","count(VALUE._col13)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                <-Reducer 4 [SIMPLE_EDGE]
+                  SHUFFLE [RS_40]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4
+                    Group By Operator [GBY_39] (rows=10969055 width=1229)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"],aggregations:["sum(_col15)","count(_col15)","sum(_col16)","count(_col16)","sum(_col17)","count(_col17)","sum(_col18)","count(_col18)","sum(_col19)","count(_col19)","sum(_col3)","count(_col3)","sum(_col22)","count(_col22)"],keys:_col5, _col6, _col7, _col10, 0L
+                      Merge Join Operator [MERGEJOIN_142] (rows=2193811 width=811)
+                        Conds:RS_35._col0=RS_36._col3(Inner),Output:["_col3","_col5","_col6","_col7","_col10","_col15","_col16","_col17","_col18","_col19","_col22"]
+                      <-Reducer 3 [SIMPLE_EDGE]
+                        PARTITION_ONLY_SHUFFLE [RS_35]
+                          PartitionCols:_col0
+                          Merge Join Operator [MERGEJOIN_138] (rows=4959744 width=368)
+                            Conds:RS_32._col1=RS_150._col0(Inner),Output:["_col0","_col3","_col5","_col6","_col7"]
+                          <-Map 9 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_150]
+                              PartitionCols:_col0
+                              Select Operator [SEL_149] (rows=1861800 width=4)
+                                Output:["_col0"]
+                                TableScan [TS_6] (rows=1861800 width=4)
+                                  default@customer_demographics,cd2,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk"]
+                          <-Reducer 2 [SIMPLE_EDGE]
+                            SHUFFLE [RS_32]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_137] (rows=4890586 width=371)
+                                Conds:RS_145._col2=RS_148._col0(Inner),Output:["_col0","_col1","_col3","_col5","_col6","_col7"]
+                              <-Map 1 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_145]
+                                  PartitionCols:_col2
+                                  Select Operator [SEL_144] (rows=35631408 width=119)
+                                    Output:["_col0","_col1","_col2","_col3"]
+                                    Filter Operator [FIL_143] (rows=35631408 width=19)
+                                      predicate:((c_birth_month) IN (9, 5, 12, 4, 1, 10) and c_current_addr_sk is not null and c_current_cdemo_sk is not null)
+                                      TableScan [TS_0] (rows=80000000 width=19)
+                                        default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk","c_birth_month","c_birth_year"]
+                              <-Map 8 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_148]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_147] (rows=5490196 width=285)
+                                    Output:["_col0","_col1","_col2","_col3"]
+                                    Filter Operator [FIL_146] (rows=5490196 width=285)
+                                      predicate:(ca_state) IN ('ND', 'WI', 'AL', 'NC', 'OK', 'MS', 'TN')
+                                      TableScan [TS_3] (rows=40000000 width=285)
+                                        default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_county","ca_state","ca_country"]
+                      <-Reducer 13 [SIMPLE_EDGE]
+                        SHUFFLE [RS_36]
+                          PartitionCols:_col3
+                          Select Operator [SEL_28] (rows=15983481 width=735)
+                            Output:["_col1","_col3","_col6","_col7","_col8","_col9","_col10","_col13"]
+                            Merge Join Operator [MERGEJOIN_141] (rows=15983481 width=735)
+                              Conds:RS_25._col3=RS_173._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col8","_col11","_col13"]
+                            <-Map 18 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_173]
+                                PartitionCols:_col0
+                                Select Operator [SEL_172] (rows=462000 width=104)
+                                  Output:["_col0","_col1"]
+                                  TableScan [TS_17] (rows=462000 width=104)
+                                    default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                            <-Reducer 12 [SIMPLE_EDGE]
+                              SHUFFLE [RS_25]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_140] (rows=15983481 width=639)
+                                  Conds:RS_22._col2=RS_161._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col11"]
+                                <-Map 16 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_161]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_160] (rows=103433 width=116)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_159] (rows=103433 width=187)
+                                        predicate:((cd_education_status = 'College') and (cd_gender = 'M'))
+                                        TableScan [TS_14] (rows=1861800 width=187)
+                                          default@customer_demographics,cd1,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_education_status","cd_dep_count"]
+                                <-Reducer 11 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_22]
+                                    PartitionCols:_col2
+                                    Merge Join Operator [MERGEJOIN_139] (rows=100578970 width=565)
+                                      Conds:RS_171._col0=RS_153._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                    <-Map 14 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_153]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_152] (rows=652 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_151] (rows=652 width=8)
+                                            predicate:(d_year = 2001)
+                                            TableScan [TS_11] (rows=73049 width=8)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                    <-Map 10 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_171]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_170] (rows=283692098 width=573)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                          Filter Operator [FIL_169] (rows=283692098 width=466)
+                                            predicate:((cs_bill_cdemo_sk BETWEEN DynamicValue(RS_23_cd1_cd_demo_sk_min) AND DynamicValue(RS_23_cd1_cd_demo_sk_max) and in_bloom_filter(cs_bill_cdemo_sk, DynamicValue(RS_23_cd1_cd_demo_sk_bloom_filter))) and (cs_bill_customer_sk BETWEEN DynamicValue(RS_35_customer_c_customer_sk_min) AND DynamicValue(RS_35_customer_c_customer_sk_max) and in_bloom_filter(cs_bill_customer_sk, DynamicValue(RS_35_customer_c_customer_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_20_date_dim_d_date_sk_min) AND DynamicValue(RS_20_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_20_date_dim_d_date_sk_bloom_filter))) and cs_bill_cdemo_sk is not null and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                            TableScan [TS_8] (rows=287989836 width=466)
+                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_bill_cdemo_sk","cs_item_sk","cs_quantity","cs_list_price","cs_sales_price","cs_coupon_amt","cs_net_profit"]
+                                            <-Reducer 15 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_158]
+                                                Group By Operator [GBY_157] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 14 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_156]
+                                                    Group By Operator [GBY_155] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_154] (rows=652 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_152]
+                                            <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_166]
+                                                Group By Operator [GBY_165] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_164]
+                                                    Group By Operator [GBY_163] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_162] (rows=103433 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_160]
+                                            <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_168]
+                                                Group By Operator [GBY_167] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=4890586)"]
+                                                <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+                                                  PARTITION_ONLY_SHUFFLE [RS_123]
+                                                    Group By Operator [GBY_122] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=4890586)"]
+                                                      Select Operator [SEL_121] (rows=4959744 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Merge Join Operator [MERGEJOIN_138]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query19.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query19.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query19.q.out
new file mode 100644
index 0000000..7eb52ef
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query19.q.out
@@ -0,0 +1,196 @@
+PREHOOK: query: explain
+select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item,customer,customer_address,store
+ where d_date_sk = ss_sold_date_sk
+   and ss_item_sk = i_item_sk
+   and i_manager_id=7
+   and d_moy=11
+   and d_year=1999
+   and ss_customer_sk = c_customer_sk 
+   and c_current_addr_sk = ca_address_sk
+   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
+   and ss_store_sk = s_store_sk 
+ group by i_brand
+      ,i_brand_id
+      ,i_manufact_id
+      ,i_manufact
+ order by ext_price desc
+         ,i_brand
+         ,i_brand_id
+         ,i_manufact_id
+         ,i_manufact
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item,customer,customer_address,store
+ where d_date_sk = ss_sold_date_sk
+   and ss_item_sk = i_item_sk
+   and i_manager_id=7
+   and d_moy=11
+   and d_year=1999
+   and ss_customer_sk = c_customer_sk 
+   and c_current_addr_sk = ca_address_sk
+   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
+   and ss_store_sk = s_store_sk 
+ group by i_brand
+      ,i_brand_id
+      ,i_manufact_id
+      ,i_manufact
+ order by ext_price desc
+         ,i_brand
+         ,i_brand_id
+         ,i_manufact_id
+         ,i_manufact
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 8 <- Reducer 12 (BROADCAST_EDGE), Reducer 14 (BROADCAST_EDGE)
+Reducer 10 <- Map 13 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 15 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 9 <- Map 11 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_153]
+        Limit [LIM_152] (rows=100 width=419)
+          Number of rows:100
+          Select Operator [SEL_151] (rows=2098703 width=418)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_150]
+              Select Operator [SEL_149] (rows=2098703 width=418)
+                Output:["_col2","_col3","_col4","_col5","_col6"]
+                Group By Operator [GBY_148] (rows=2098703 width=314)
+                  Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+                <-Reducer 4 [SIMPLE_EDGE]
+                  SHUFFLE [RS_35]
+                    PartitionCols:_col0, _col1, _col2, _col3
+                    Group By Operator [GBY_34] (rows=2098703 width=314)
+                      Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col8)"],keys:_col12, _col11, _col13, _col14
+                      Select Operator [SEL_33] (rows=2098703 width=570)
+                        Output:["_col8","_col11","_col12","_col13","_col14"]
+                        Filter Operator [FIL_32] (rows=2098703 width=570)
+                          predicate:(_col3 <> _col16)
+                          Merge Join Operator [MERGEJOIN_121] (rows=2098703 width=570)
+                            Conds:RS_29._col7=RS_147._col0(Inner),Output:["_col3","_col8","_col11","_col12","_col13","_col14","_col16"]
+                          <-Map 15 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_147]
+                              PartitionCols:_col0
+                              Select Operator [SEL_146] (rows=1704 width=188)
+                                Output:["_col0","_col1"]
+                                TableScan [TS_21] (rows=1704 width=93)
+                                  default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_zip"]
+                          <-Reducer 3 [SIMPLE_EDGE]
+                            SHUFFLE [RS_29]
+                              PartitionCols:_col7
+                              Merge Join Operator [MERGEJOIN_120] (rows=2098703 width=386)
+                                Conds:RS_26._col0=RS_27._col2(Inner),Output:["_col3","_col7","_col8","_col11","_col12","_col13","_col14"]
+                              <-Reducer 10 [SIMPLE_EDGE]
+                                SHUFFLE [RS_27]
+                                  PartitionCols:_col2
+                                  Merge Join Operator [MERGEJOIN_119] (rows=2098703 width=202)
+                                    Conds:RS_17._col1=RS_137._col0(Inner),Output:["_col2","_col3","_col4","_col7","_col8","_col9","_col10"]
+                                  <-Map 13 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_137]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_136] (rows=7333 width=206)
+                                        Output:["_col0","_col1","_col2","_col3","_col4"]
+                                        Filter Operator [FIL_135] (rows=7333 width=210)
+                                          predicate:(i_manager_id = 7)
+                                          TableScan [TS_11] (rows=462000 width=210)
+                                            default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand_id","i_brand","i_manufact_id","i_manufact","i_manager_id"]
+                                  <-Reducer 9 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_17]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_118] (rows=13737330 width=4)
+                                        Conds:RS_145._col0=RS_129._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                      <-Map 11 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_129]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_128] (rows=50 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_127] (rows=50 width=12)
+                                              predicate:((d_moy = 11) and (d_year = 1999))
+                                              TableScan [TS_8] (rows=73049 width=12)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_145]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_144] (rows=501694138 width=122)
+                                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                                            Filter Operator [FIL_143] (rows=501694138 width=122)
+                                              predicate:((ss_item_sk BETWEEN DynamicValue(RS_18_item_i_item_sk_min) AND DynamicValue(RS_18_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_18_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                              TableScan [TS_5] (rows=575995635 width=122)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_store_sk","ss_ext_sales_price"]
+                                              <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_134]
+                                                  Group By Operator [GBY_133] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_132]
+                                                      Group By Operator [GBY_131] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_130] (rows=50 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_128]
+                                              <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_142]
+                                                  Group By Operator [GBY_141] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_140]
+                                                      Group By Operator [GBY_139] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_138] (rows=7333 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_136]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_26]
+                                  PartitionCols:_col0
+                                  Merge Join Operator [MERGEJOIN_117] (rows=80000000 width=188)
+                                    Conds:RS_124._col1=RS_126._col0(Inner),Output:["_col0","_col3"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_124]
+                                      PartitionCols:_col1
+                                      Select Operator [SEL_123] (rows=80000000 width=8)
+                                        Output:["_col0","_col1"]
+                                        Filter Operator [FIL_122] (rows=80000000 width=8)
+                                          predicate:c_current_addr_sk is not null
+                                          TableScan [TS_0] (rows=80000000 width=8)
+                                            default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk"]
+                                  <-Map 7 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_126]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_125] (rows=40000000 width=188)
+                                        Output:["_col0","_col1"]
+                                        TableScan [TS_3] (rows=40000000 width=93)
+                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_zip"]
+


[56/75] [abbrv] hive git commit: HIVE-20765 : fetch partitions for txn stats validation in get_aggr_stats with one call (Sergey Shelukhin, reviewed by Ashutosh Chauhan, and Vihang Karajgaonkar)

Posted by se...@apache.org.
HIVE-20765 : fetch partitions for txn stats validation in get_aggr_stats with one call (Sergey Shelukhin, reviewed by Ashutosh Chauhan, and Vihang Karajgaonkar)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/cbe3228c
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/cbe3228c
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/cbe3228c

Branch: refs/heads/master-tez092
Commit: cbe3228c29e2db6ae5cffcb94cdcf79063859ffe
Parents: b4302bb
Author: sergey <se...@apache.org>
Authored: Mon Oct 22 14:06:48 2018 -0700
Committer: sergey <se...@apache.org>
Committed: Mon Oct 22 14:06:48 2018 -0700

----------------------------------------------------------------------
 .../hadoop/hive/metastore/ObjectStore.java      | 22 +++++++++++++-------
 .../metastore/PartitionProjectionEvaluator.java |  8 +++++--
 2 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/cbe3228c/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index b98b4b4..ddd64e7 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -9052,21 +9052,27 @@ public class ObjectStore implements RawStore, Configurable {
         return null;
       }
 
-      MTable table = getMTable(catName, dbName, tblName);
+      Table table = getTable(catName, dbName, tblName);
       boolean isTxn = TxnUtils.isTransactionalTable(table.getParameters());
       if (isTxn && !areTxnStatsSupported) {
         return null;
       }
+      GetPartitionsFilterSpec fs = new GetPartitionsFilterSpec();
+      fs.setFilterMode(PartitionFilterMode.BY_NAMES);
+      fs.setFilters(partNames);
+      GetPartitionsProjectionSpec ps = new GetPartitionsProjectionSpec();
+      ps.setIncludeParamKeyPattern(StatsSetupConst.COLUMN_STATS_ACCURATE + '%');
+      ps.setFieldList(Lists.newArrayList("writeId", "parameters", "values"));
+      List<Partition> parts = getPartitionSpecsByFilterAndProjection(table, ps, fs);
 
       // Loop through the given "partNames" list
       // checking isolation-level-compliance of each partition column stats.
-      for (String partName : partNames) {
-        MPartition mpart = getMPartition(
-            catName, dbName, tblName, Warehouse.getPartValuesFromPartName(partName));
-        if (!isCurrentStatsValidForTheQuery(mpart, writeIdList, false)) {
-          LOG.debug("The current metastore transactional partition column statistics " +
-                  "for " + dbName + "." + tblName + "." + mpart.getPartitionName() + " is not valid " +
-                  "for the current query.");
+      for (Partition part : parts) {
+
+        if (!isCurrentStatsValidForTheQuery(part, part.getWriteId(), writeIdList, false)) {
+          String partName = Warehouse.makePartName(table.getPartitionKeys(), part.getValues());
+          LOG.debug("The current metastore transactional partition column statistics for " + dbName
+              + "." + tblName + "." + partName + " is not valid for the current query");
           return null;
         }
       }

http://git-wip-us.apache.org/repos/asf/hive/blob/cbe3228c/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PartitionProjectionEvaluator.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PartitionProjectionEvaluator.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PartitionProjectionEvaluator.java
index e918a33..c3a0093 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PartitionProjectionEvaluator.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PartitionProjectionEvaluator.java
@@ -26,6 +26,7 @@ import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.Partition;
@@ -38,6 +39,7 @@ import org.slf4j.LoggerFactory;
 
 import javax.jdo.PersistenceManager;
 import javax.jdo.Query;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -369,8 +371,8 @@ public class PartitionProjectionEvaluator {
     int numColumns = buildQueryForSingleValuedFields(partitionIds, queryTextBuilder);
     String queryText = queryTextBuilder.toString();
 
-    try (Query query = pm.newQuery("javax.jdo.query.SQL", queryText)) {
-
+    Query<?> query = pm.newQuery("javax.jdo.query.SQL", queryText);
+    try {
       long start = LOG.isDebugEnabled() ? System.nanoTime() : 0;
       List<Object> sqlResult = MetastoreDirectSqlUtils.executeWithArray(query, null, queryText);
       long queryTime = LOG.isDebugEnabled() ? System.nanoTime() : 0;
@@ -456,6 +458,8 @@ public class PartitionProjectionEvaluator {
     } catch (Exception e) {
       LOG.error("Exception received while getting partitions using projected fields", e);
       throw new MetaException(e.getMessage());
+    } finally {
+      query.closeAll();
     }
   }
 


[30/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query68.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query68.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query68.q.out
new file mode 100644
index 0000000..e5c1822
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query68.q.out
@@ -0,0 +1,127 @@
+PREHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,extended_price
+       ,extended_tax
+       ,list_price
+ from (select ss_ticket_number
+             ,ss_customer_sk
+             ,ca_city bought_city
+             ,sum(ss_ext_sales_price) extended_price 
+             ,sum(ss_ext_list_price) list_price
+             ,sum(ss_ext_tax) extended_tax 
+       from store_sales
+           ,date_dim
+           ,store
+           ,household_demographics
+           ,customer_address 
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_store_sk = store.s_store_sk  
+        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+        and store_sales.ss_addr_sk = customer_address.ca_address_sk
+        and date_dim.d_dom between 1 and 2 
+        and (household_demographics.hd_dep_count = 2 or
+             household_demographics.hd_vehicle_count= 1)
+        and date_dim.d_year in (1998,1998+1,1998+2)
+        and store.s_city in ('Cedar Grove','Wildwood')
+       group by ss_ticket_number
+               ,ss_customer_sk
+               ,ss_addr_sk,ca_city) dn
+      ,customer
+      ,customer_address current_addr
+ where ss_customer_sk = c_customer_sk
+   and customer.c_current_addr_sk = current_addr.ca_address_sk
+   and current_addr.ca_city <> bought_city
+ order by c_last_name
+         ,ss_ticket_number
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,extended_price
+       ,extended_tax
+       ,list_price
+ from (select ss_ticket_number
+             ,ss_customer_sk
+             ,ca_city bought_city
+             ,sum(ss_ext_sales_price) extended_price 
+             ,sum(ss_ext_list_price) list_price
+             ,sum(ss_ext_tax) extended_tax 
+       from store_sales
+           ,date_dim
+           ,store
+           ,household_demographics
+           ,customer_address 
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_store_sk = store.s_store_sk  
+        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+        and store_sales.ss_addr_sk = customer_address.ca_address_sk
+        and date_dim.d_dom between 1 and 2 
+        and (household_demographics.hd_dep_count = 2 or
+             household_demographics.hd_vehicle_count= 1)
+        and date_dim.d_year in (1998,1998+1,1998+2)
+        and store.s_city in ('Cedar Grove','Wildwood')
+       group by ss_ticket_number
+               ,ss_customer_sk
+               ,ss_addr_sk,ca_city) dn
+      ,customer
+      ,customer_address current_addr
+ where ss_customer_sk = c_customer_sk
+   and customer.c_current_addr_sk = current_addr.ca_address_sk
+   and current_addr.ca_city <> bought_city
+ order by c_last_name
+         ,ss_ticket_number
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$4], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], ca_city=[$5], bought_city=[$8], ss_ticket_number=[$6], extended_price=[$9], extended_tax=[$11], list_price=[$10])
+    HiveJoin(condition=[AND(<>($5, $8), =($7, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9])
+          HiveFilter(condition=[IS NOT NULL($4)])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ca_address_sk=[$0], ca_city=[$6])
+          HiveTableScan(table=[[default, customer_address]], table:alias=[current_addr])
+      HiveProject(ss_ticket_number=[$3], ss_customer_sk=[$1], bought_city=[$0], extended_price=[$4], list_price=[$5], extended_tax=[$6])
+        HiveAggregate(group=[{1, 3, 5, 7}], agg#0=[sum($8)], agg#1=[sum($9)], agg#2=[sum($10)])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ca_address_sk=[$0], ca_city=[$6])
+              HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($4, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_ext_sales_price=[$15], ss_ext_list_price=[$17], ss_ext_tax=[$18])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($6), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(IN($6, 1998, 1999, 2000), BETWEEN(false, $9, 1, 2))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0])
+                  HiveFilter(condition=[IN($22, _UTF-16LE'Cedar Grove', _UTF-16LE'Wildwood')])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(hd_demo_sk=[$0])
+                HiveFilter(condition=[OR(=($3, 2), =($4, 1))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query69.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query69.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query69.q.out
new file mode 100644
index 0000000..1eb6a11
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query69.q.out
@@ -0,0 +1,155 @@
+PREHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_state in ('CO','IL','MN') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_moy between 1 and 1+2) and
+   (not exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2) and
+    not exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_state in ('CO','IL','MN') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_moy between 1 and 1+2) and
+   (not exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2) and
+    not exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$4], sort4=[$6], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject(cd_gender=[$0], cd_marital_status=[$1], cd_education_status=[$2], cnt1=[$5], cd_purchase_estimate=[$3], cnt2=[$5], cd_credit_rating=[$4], cnt3=[$5])
+    HiveAggregate(group=[{6, 7, 8, 9, 10}], agg#0=[count()])
+      HiveFilter(condition=[IS NULL($14)])
+        HiveJoin(condition=[=($0, $13)], joinType=[left], algorithm=[none], cost=[not available])
+          HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$1], c_current_addr_sk=[$2], ca_address_sk=[$3], ca_state=[$4], cd_demo_sk=[$5], cd_gender=[$6], cd_marital_status=[$7], cd_education_status=[$8], cd_purchase_estimate=[$9], cd_credit_rating=[$10], ws_bill_customer_sk0=[$11], $f1=[$12])
+            HiveFilter(condition=[IS NULL($12)])
+              HiveJoin(condition=[=($0, $11)], joinType=[left], algorithm=[none], cost=[not available])
+                HiveSemiJoin(condition=[=($0, $11)], joinType=[inner])
+                  HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, customer]], table:alias=[c])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                        HiveFilter(condition=[IN($8, _UTF-16LE'CO', _UTF-16LE'IL', _UTF-16LE'MN')])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
+                    HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_education_status=[$3], cd_purchase_estimate=[$4], cd_credit_rating=[$5])
+                      HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+                  HiveProject(ss_customer_sk0=[$1])
+                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                        HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), BETWEEN(false, $8, 1, 3))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(ws_bill_customer_sk0=[$0], $f1=[true])
+                  HiveAggregate(group=[{1}])
+                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), BETWEEN(false, $8, 1, 3))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(cs_ship_customer_sk0=[$0], $f1=[true])
+            HiveAggregate(group=[{1}])
+              HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_ship_customer_sk=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[AND(=($6, 1999), BETWEEN(false, $8, 1, 3))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query7.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query7.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query7.q.out
new file mode 100644
index 0000000..bdd86fc
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query7.q.out
@@ -0,0 +1,75 @@
+PREHOOK: query: explain cbo
+select  i_item_id, 
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4 
+ from store_sales, customer_demographics, date_dim, item, promotion
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       ss_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
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id, 
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4 
+ from store_sales, customer_demographics, date_dim, item, promotion
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       ss_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
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[/(CAST($1):DOUBLE, $2)], $f2=[/($3, $4)], $f3=[/($5, $6)], $f4=[/($7, $8)])
+    HiveAggregate(group=[{1}], agg#0=[sum($6)], agg#1=[count($6)], agg#2=[sum($7)], agg#3=[count($7)], agg#4=[sum($9)], agg#5=[count($9)], agg#6=[sum($8)], agg#7=[count($8)])
+      HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_item_id=[$1])
+          HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveJoin(condition=[=($3, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_cdemo_sk=[$4], ss_promo_sk=[$8], ss_quantity=[$10], ss_list_price=[$12], ss_sales_price=[$13], ss_coupon_amt=[$19])
+                HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($8))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(cd_demo_sk=[$0])
+                HiveFilter(condition=[AND(=($1, _UTF-16LE'F'), =($2, _UTF-16LE'W'), =($3, _UTF-16LE'Primary'))])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[=($6, 1998)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(p_promo_sk=[$0])
+            HiveFilter(condition=[OR(=($9, _UTF-16LE'N'), =($14, _UTF-16LE'N'))])
+              HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query70.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query70.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query70.q.out
new file mode 100644
index 0000000..7103b15
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query70.q.out
@@ -0,0 +1,119 @@
+PREHOOK: query: explain cbo
+select  
+    sum(ss_net_profit) as total_sum
+   ,s_state
+   ,s_county
+   ,grouping(s_state)+grouping(s_county) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(s_state)+grouping(s_county),
+ 	case when grouping(s_county) = 0 then s_state end 
+ 	order by sum(ss_net_profit) desc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,store
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ss_sold_date_sk
+ and s_store_sk  = ss_store_sk
+ and s_state in
+             ( select s_state
+               from  (select s_state as s_state,
+ 			    rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
+                      from   store_sales, store, date_dim
+                      where  d_month_seq between 1212 and 1212+11
+ 			    and d_date_sk = ss_sold_date_sk
+ 			    and s_store_sk  = ss_store_sk
+                      group by s_state
+                     ) tmp1 
+               where ranking <= 5
+             )
+ group by rollup(s_state,s_county)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then s_state end
+  ,rank_within_parent
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+    sum(ss_net_profit) as total_sum
+   ,s_state
+   ,s_county
+   ,grouping(s_state)+grouping(s_county) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(s_state)+grouping(s_county),
+ 	case when grouping(s_county) = 0 then s_state end 
+ 	order by sum(ss_net_profit) desc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,store
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ss_sold_date_sk
+ and s_store_sk  = ss_store_sk
+ and s_state in
+             ( select s_state
+               from  (select s_state as s_state,
+ 			    rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
+                      from   store_sales, store, date_dim
+                      where  d_month_seq between 1212 and 1212+11
+ 			    and d_date_sk = ss_sold_date_sk
+ 			    and s_store_sk  = ss_store_sk
+                      group by s_state
+                     ) tmp1 
+               where ranking <= 5
+             )
+ group by rollup(s_state,s_county)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then s_state end
+  ,rank_within_parent
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(total_sum=[$0], s_state=[$1], s_county=[$2], lochierarchy=[$3], rank_within_parent=[$4])
+  HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(total_sum=[$2], s_state=[$0], s_county=[$1], lochierarchy=[+(grouping($3, 1), grouping($3, 0))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($3, 1), grouping($3, 0)), CASE(=(grouping($3, 0), 0), $0, null) ORDER BY $2 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok_table_or_col s_state))=[CASE(=(+(grouping($3, 1), grouping($3, 0)), 0), $0, null)])
+      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], GROUPING__ID=[$3])
+        HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], GROUPING__ID=[GROUPING__ID()])
+          HiveProject($f0=[$7], $f1=[$6], $f2=[$2])
+            HiveJoin(condition=[=($7, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                    HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                HiveProject(s_store_sk=[$0], s_county=[$23], s_state=[$24])
+                  HiveFilter(condition=[IS NOT NULL($24)])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(s_state=[$0])
+                HiveFilter(condition=[<=($1, 5)])
+                  HiveProject((tok_table_or_col s_state)=[$0], rank_window_0=[$1])
+                    HiveProject((tok_table_or_col s_state)=[$0], rank_window_0=[rank() OVER (PARTITION BY $0 ORDER BY $1 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], window_col_0=[$1])
+                      HiveProject(s_state=[$0], $f1=[$1])
+                        HiveAggregate(group=[{5}], agg#0=[sum($2)])
+                          HiveJoin(condition=[=($4, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_net_profit=[$22])
+                                HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                              HiveProject(d_date_sk=[$0])
+                                HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                            HiveProject(s_store_sk=[$0], s_state=[$24])
+                              HiveFilter(condition=[IS NOT NULL($24)])
+                                HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query71.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query71.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query71.q.out
new file mode 100644
index 0000000..b5764f1
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query71.q.out
@@ -0,0 +1,130 @@
+PREHOOK: query: explain cbo
+select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
+ 	sum(ext_price) ext_price
+ from item, (select ws_ext_sales_price as ext_price, 
+                        ws_sold_date_sk as sold_date_sk,
+                        ws_item_sk as sold_item_sk,
+                        ws_sold_time_sk as time_sk  
+                 from web_sales,date_dim
+                 where d_date_sk = ws_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select cs_ext_sales_price as ext_price,
+                        cs_sold_date_sk as sold_date_sk,
+                        cs_item_sk as sold_item_sk,
+                        cs_sold_time_sk as time_sk
+                 from catalog_sales,date_dim
+                 where d_date_sk = cs_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select ss_ext_sales_price as ext_price,
+                        ss_sold_date_sk as sold_date_sk,
+                        ss_item_sk as sold_item_sk,
+                        ss_sold_time_sk as time_sk
+                 from store_sales,date_dim
+                 where d_date_sk = ss_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 ) as tmp,time_dim
+ where
+   sold_item_sk = i_item_sk
+   and i_manager_id=1
+   and time_sk = t_time_sk
+   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
+ group by i_brand, i_brand_id,t_hour,t_minute
+ order by ext_price desc, i_brand_id
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
+ 	sum(ext_price) ext_price
+ from item, (select ws_ext_sales_price as ext_price, 
+                        ws_sold_date_sk as sold_date_sk,
+                        ws_item_sk as sold_item_sk,
+                        ws_sold_time_sk as time_sk  
+                 from web_sales,date_dim
+                 where d_date_sk = ws_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select cs_ext_sales_price as ext_price,
+                        cs_sold_date_sk as sold_date_sk,
+                        cs_item_sk as sold_item_sk,
+                        cs_sold_time_sk as time_sk
+                 from catalog_sales,date_dim
+                 where d_date_sk = cs_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select ss_ext_sales_price as ext_price,
+                        ss_sold_date_sk as sold_date_sk,
+                        ss_item_sk as sold_item_sk,
+                        ss_sold_time_sk as time_sk
+                 from store_sales,date_dim
+                 where d_date_sk = ss_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 ) as tmp,time_dim
+ where
+   sold_item_sk = i_item_sk
+   and i_manager_id=1
+   and time_sk = t_time_sk
+   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
+ group by i_brand, i_brand_id,t_hour,t_minute
+ order by ext_price desc, i_brand_id
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(brand_id=[$0], brand=[$1], t_hour=[$2], t_minute=[$3], ext_price=[$4])
+  HiveSortLimit(sort0=[$4], sort1=[$5], dir0=[DESC-nulls-last], dir1=[ASC])
+    HiveProject(brand_id=[$2], brand=[$3], t_hour=[$0], t_minute=[$1], ext_price=[$4], (tok_table_or_col i_brand_id)=[$2])
+      HiveAggregate(group=[{1, 2, 7, 8}], agg#0=[sum($3)])
+        HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(t_time_sk=[$0], t_hour=[$3], t_minute=[$4])
+            HiveFilter(condition=[IN($9, _UTF-16LE'breakfast', _UTF-16LE'dinner')])
+              HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+          HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ext_price=[$0], sold_item_sk=[$1], time_sk=[$2])
+              HiveUnion(all=[true])
+                HiveProject(ext_price=[$3], sold_item_sk=[$2], time_sk=[$1])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_sold_time_sk=[$1], ws_item_sk=[$3], ws_ext_sales_price=[$23])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($8, 12), =($6, 2001))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(ext_price=[$3], sold_item_sk=[$2], time_sk=[$1])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cs_sold_date_sk=[$0], cs_sold_time_sk=[$1], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($8, 12), =($6, 2001))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(ext_price=[$3], sold_item_sk=[$2], time_sk=[$1])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_sold_time_sk=[$1], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($8, 12), =($6, 2001))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8])
+              HiveFilter(condition=[=($20, 1)])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query72.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query72.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query72.q.out
new file mode 100644
index 0000000..5e6950f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query72.q.out
@@ -0,0 +1,125 @@
+PREHOOK: query: explain cbo
+select  i_item_desc
+      ,w_warehouse_name
+      ,d1.d_week_seq
+      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
+      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
+      ,count(*) total_cnt
+from catalog_sales
+join inventory on (cs_item_sk = inv_item_sk)
+join warehouse on (w_warehouse_sk=inv_warehouse_sk)
+join item on (i_item_sk = cs_item_sk)
+join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk)
+join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk)
+join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk)
+join date_dim d2 on (inv_date_sk = d2.d_date_sk)
+join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk)
+left outer join promotion on (cs_promo_sk=p_promo_sk)
+left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number)
+where d1.d_week_seq = d2.d_week_seq
+  and inv_quantity_on_hand < cs_quantity 
+  and d3.d_date > d1.d_date + 5
+  and hd_buy_potential = '1001-5000'
+  and d1.d_year = 2001
+  and hd_buy_potential = '1001-5000'
+  and cd_marital_status = 'M'
+  and d1.d_year = 2001
+group by i_item_desc,w_warehouse_name,d1.d_week_seq
+order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_desc
+      ,w_warehouse_name
+      ,d1.d_week_seq
+      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
+      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
+      ,count(*) total_cnt
+from catalog_sales
+join inventory on (cs_item_sk = inv_item_sk)
+join warehouse on (w_warehouse_sk=inv_warehouse_sk)
+join item on (i_item_sk = cs_item_sk)
+join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk)
+join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk)
+join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk)
+join date_dim d2 on (inv_date_sk = d2.d_date_sk)
+join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk)
+left outer join promotion on (cs_promo_sk=p_promo_sk)
+left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number)
+where d1.d_week_seq = d2.d_week_seq
+  and inv_quantity_on_hand < cs_quantity 
+  and d3.d_date > d1.d_date + 5
+  and hd_buy_potential = '1001-5000'
+  and d1.d_year = 2001
+  and hd_buy_potential = '1001-5000'
+  and cd_marital_status = 'M'
+  and d1.d_year = 2001
+group by i_item_desc,w_warehouse_name,d1.d_week_seq
+order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$5], sort1=[$0], sort2=[$1], sort3=[$2], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5])
+    HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)], agg#1=[count($4)], agg#2=[count()])
+      HiveProject($f0=[$15], $f1=[$13], $f2=[$19], $f3=[CASE(IS NULL($25), 1, 0)], $f4=[CASE(IS NOT NULL($25), 1, 0)])
+        HiveJoin(condition=[AND(=($26, $4), =($27, $6))], joinType=[left], algorithm=[none], cost=[not available])
+          HiveProject(cs_sold_date_sk=[$10], cs_ship_date_sk=[$11], cs_bill_cdemo_sk=[$12], cs_bill_hdemo_sk=[$13], cs_item_sk=[$14], cs_promo_sk=[$15], cs_order_number=[$16], cs_quantity=[$17], inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3], w_warehouse_sk=[$4], w_warehouse_name=[$5], i_item_sk=[$8], i_item_desc=[$9], cd_demo_sk=[$21], hd_demo_sk=[$22], d_date_sk=[$18], d_week_seq=[$19], +=[$20], d_date_sk0=[$24], d_week_seq0=[$25], d_date_sk1=[$6], CAST=[$7], p_promo_sk=[$23])
+            HiveJoin(condition=[AND(=($0, $24), =($19, $25))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[AND(=($14, $1), <($3, $17))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($4, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3])
+                    HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                  HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+                    HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+                HiveProject(d_date_sk=[$0], CAST=[$1], i_item_sk=[$2], i_item_desc=[$3], cs_sold_date_sk=[$4], cs_ship_date_sk=[$5], cs_bill_cdemo_sk=[$6], cs_bill_hdemo_sk=[$7], cs_item_sk=[$8], cs_promo_sk=[$9], cs_order_number=[$10], cs_quantity=[$11], d_date_sk0=[$12], d_week_seq=[$13], +=[$14], cd_demo_sk=[$15], hd_demo_sk=[$16], p_promo_sk=[$17])
+                  HiveJoin(condition=[AND(=($5, $0), >($1, $14))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(d_date_sk=[$0], CAST=[CAST($2):DOUBLE])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_item_desc=[$4])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($5, $13)], joinType=[left], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($3, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(cs_sold_date_sk=[$0], cs_ship_date_sk=[$2], cs_bill_cdemo_sk=[$4], cs_bill_hdemo_sk=[$5], cs_item_sk=[$15], cs_promo_sk=[$16], cs_order_number=[$17], cs_quantity=[$18])
+                                HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($5), IS NOT NULL($0), IS NOT NULL($2))])
+                                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                              HiveProject(d_date_sk=[$0], d_week_seq=[$4], +=[+(CAST($2):DOUBLE, 5)])
+                                HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($4))])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                            HiveProject(cd_demo_sk=[$0])
+                              HiveFilter(condition=[=($2, _UTF-16LE'M')])
+                                HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+                          HiveProject(hd_demo_sk=[$0])
+                            HiveFilter(condition=[=($2, _UTF-16LE'1001-5000')])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                        HiveProject(p_promo_sk=[$0])
+                          HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+              HiveProject(d_date_sk=[$0], d_week_seq=[$4])
+                HiveFilter(condition=[IS NOT NULL($4)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+          HiveProject(cr_item_sk=[$2], cr_order_number=[$16])
+            HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query73.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query73.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query73.q.out
new file mode 100644
index 0000000..38af7c0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query73.q.out
@@ -0,0 +1,92 @@
+PREHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag 
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and date_dim.d_dom between 1 and 2 
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and case when household_demographics.hd_vehicle_count > 0 then 
+             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County')
+    group by ss_ticket_number,ss_customer_sk) dj,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 1 and 5
+    order by cnt desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag 
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and date_dim.d_dom between 1 and 2 
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and case when household_demographics.hd_vehicle_count > 0 then 
+             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County')
+    group by ss_ticket_number,ss_customer_sk) dj,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 1 and 5
+    order by cnt desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$5], dir0=[DESC-nulls-last])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], c_salutation=[$1], c_preferred_cust_flag=[$4], ss_ticket_number=[$5], cnt=[$7])
+    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(c_customer_sk=[$0], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10])
+        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+      HiveProject(ss_ticket_number=[$0], ss_customer_sk=[$1], $f2=[$2])
+        HiveFilter(condition=[BETWEEN(false, $2, 1, 5)])
+          HiveProject(ss_ticket_number=[$1], ss_customer_sk=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 4}], agg#0=[count()])
+              HiveJoin(condition=[=($3, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($2, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_store_sk=[$7], ss_ticket_number=[$9])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($3))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(IN($6, 2000, 2001, 2002), BETWEEN(false, $9, 1, 2))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(hd_demo_sk=[$0])
+                    HiveFilter(condition=[AND(IN($2, _UTF-16LE'>10000', _UTF-16LE'unknown'), >($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1), null))])
+                      HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(s_store_sk=[$0])
+                  HiveFilter(condition=[IN($23, _UTF-16LE'Mobile County', _UTF-16LE'Maverick County', _UTF-16LE'Huron County', _UTF-16LE'Kittitas County')])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query74.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query74.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query74.q.out
new file mode 100644
index 0000000..c16cab0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query74.q.out
@@ -0,0 +1,187 @@
+PREHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ss_net_paid) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ws_net_paid) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         )
+  select 
+        t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.year = 2001
+         and t_s_secyear.year = 2001+1
+         and t_w_firstyear.year = 2001
+         and t_w_secyear.year = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by 2,1,3
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ss_net_paid) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ws_net_paid) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         )
+  select 
+        t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.year = 2001
+         and t_s_secyear.year = 2001+1
+         and t_w_firstyear.year = 2001
+         and t_w_secyear.year = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by 2,1,3
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], sort1=[$0], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(customer_id=[$0], customer_first_name=[$1], customer_last_name=[$2])
+    HiveJoin(condition=[AND(=($0, $6), CASE($8, CASE($11, >(/($5, $10), /($3, $7)), >(null, /($3, $7))), CASE($11, >(/($5, $10), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(c_customer_id=[$0], c_first_name=[$1], c_last_name=[$2], $f3=[$3])
+        HiveAggregate(group=[{1, 2, 3}], agg#0=[max($6)])
+          HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_net_paid=[$20])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2002))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f4=[$3])
+            HiveAggregate(group=[{1, 2, 3}], agg#0=[max($6)])
+              HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_net_paid=[$29])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2002))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(customer_id=[$0], year_total=[$3], CAST=[CAST(IS NOT NULL($3)):BOOLEAN])
+            HiveFilter(condition=[>($3, 0)])
+              HiveAggregate(group=[{1, 2, 3}], agg#0=[max($6)])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_net_paid=[$20])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2001))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(customer_id=[$0], year_total=[$3], CAST=[CAST(IS NOT NULL($3)):BOOLEAN])
+          HiveFilter(condition=[>($3, 0)])
+            HiveAggregate(group=[{1, 2, 3}], agg#0=[max($6)])
+              HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_net_paid=[$29])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(IN($6, 2001, 2002), =($6, 2001))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query75.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query75.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query75.q.out
new file mode 100644
index 0000000..50a9dfc
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query75.q.out
@@ -0,0 +1,272 @@
+PREHOOK: query: explain cbo
+WITH all_sales AS (
+ SELECT d_year
+       ,i_brand_id
+       ,i_class_id
+       ,i_category_id
+       ,i_manufact_id
+       ,SUM(sales_cnt) AS sales_cnt
+       ,SUM(sales_amt) AS sales_amt
+ FROM (SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt
+             ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt
+       FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk
+                          JOIN date_dim ON d_date_sk=cs_sold_date_sk
+                          LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number 
+                                                    AND cs_item_sk=cr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt
+             ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt
+       FROM store_sales JOIN item ON i_item_sk=ss_item_sk
+                        JOIN date_dim ON d_date_sk=ss_sold_date_sk
+                        LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number 
+                                                AND ss_item_sk=sr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt
+             ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt
+       FROM web_sales JOIN item ON i_item_sk=ws_item_sk
+                      JOIN date_dim ON d_date_sk=ws_sold_date_sk
+                      LEFT JOIN web_returns ON (ws_order_number=wr_order_number 
+                                            AND ws_item_sk=wr_item_sk)
+       WHERE i_category='Sports') sales_detail
+ GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+ SELECT  prev_yr.d_year AS prev_year
+                          ,curr_yr.d_year AS year
+                          ,curr_yr.i_brand_id
+                          ,curr_yr.i_class_id
+                          ,curr_yr.i_category_id
+                          ,curr_yr.i_manufact_id
+                          ,prev_yr.sales_cnt AS prev_yr_cnt
+                          ,curr_yr.sales_cnt AS curr_yr_cnt
+                          ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff
+                          ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff
+ FROM all_sales curr_yr, all_sales prev_yr
+ WHERE curr_yr.i_brand_id=prev_yr.i_brand_id
+   AND curr_yr.i_class_id=prev_yr.i_class_id
+   AND curr_yr.i_category_id=prev_yr.i_category_id
+   AND curr_yr.i_manufact_id=prev_yr.i_manufact_id
+   AND curr_yr.d_year=2002
+   AND prev_yr.d_year=2002-1
+   AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9
+ ORDER BY sales_cnt_diff
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+WITH all_sales AS (
+ SELECT d_year
+       ,i_brand_id
+       ,i_class_id
+       ,i_category_id
+       ,i_manufact_id
+       ,SUM(sales_cnt) AS sales_cnt
+       ,SUM(sales_amt) AS sales_amt
+ FROM (SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt
+             ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt
+       FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk
+                          JOIN date_dim ON d_date_sk=cs_sold_date_sk
+                          LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number 
+                                                    AND cs_item_sk=cr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt
+             ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt
+       FROM store_sales JOIN item ON i_item_sk=ss_item_sk
+                        JOIN date_dim ON d_date_sk=ss_sold_date_sk
+                        LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number 
+                                                AND ss_item_sk=sr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt
+             ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt
+       FROM web_sales JOIN item ON i_item_sk=ws_item_sk
+                      JOIN date_dim ON d_date_sk=ws_sold_date_sk
+                      LEFT JOIN web_returns ON (ws_order_number=wr_order_number 
+                                            AND ws_item_sk=wr_item_sk)
+       WHERE i_category='Sports') sales_detail
+ GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+ SELECT  prev_yr.d_year AS prev_year
+                          ,curr_yr.d_year AS year
+                          ,curr_yr.i_brand_id
+                          ,curr_yr.i_class_id
+                          ,curr_yr.i_category_id
+                          ,curr_yr.i_manufact_id
+                          ,prev_yr.sales_cnt AS prev_yr_cnt
+                          ,curr_yr.sales_cnt AS curr_yr_cnt
+                          ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff
+                          ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff
+ FROM all_sales curr_yr, all_sales prev_yr
+ WHERE curr_yr.i_brand_id=prev_yr.i_brand_id
+   AND curr_yr.i_class_id=prev_yr.i_class_id
+   AND curr_yr.i_category_id=prev_yr.i_category_id
+   AND curr_yr.i_manufact_id=prev_yr.i_manufact_id
+   AND curr_yr.d_year=2002
+   AND prev_yr.d_year=2002-1
+   AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9
+ ORDER BY sales_cnt_diff
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(prev_year=[CAST(2001):INTEGER], year=[CAST(2002):INTEGER], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], prev_yr_cnt=[$4], curr_yr_cnt=[$5], sales_cnt_diff=[$6], sales_amt_diff=[$7])
+  HiveSortLimit(sort0=[$6], dir0=[ASC], fetch=[100])
+    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], prev_yr_cnt=[$4], curr_yr_cnt=[$11], sales_cnt_diff=[-($11, $4)], sales_amt_diff=[-($12, $5)])
+      HiveJoin(condition=[AND(AND(AND(AND(=($7, $0), =($8, $1)), =($9, $2)), =($10, $3)), <(/($13, $6), 0.9))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], $f5=[$4], $f6=[$5], CAST=[CAST($4):DECIMAL(17, 2)])
+          HiveAggregate(group=[{0, 1, 2, 3}], agg#0=[sum($4)], agg#1=[sum($5)])
+            HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                  HiveUnion(all=[true])
+                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                      HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                          HiveUnion(all=[true])
+                            HiveProject(i_brand_id=[$11], i_class_id=[$12], i_category_id=[$13], i_manufact_id=[$14], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_quantity=[$17], cr_return_amount=[$18])
+                                  HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                                HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_ext_sales_price=[$23])
+                                      HiveFilter(condition=[IS NOT NULL($0)])
+                                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(d_date_sk=[$0])
+                                      HiveFilter(condition=[=($6, 2001)])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                            HiveProject(i_brand_id=[$11], i_class_id=[$12], i_category_id=[$13], i_manufact_id=[$14], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_quantity=[$10], sr_return_amt=[$11])
+                                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                                HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], ss_quantity=[$10], ss_ext_sales_price=[$15])
+                                      HiveFilter(condition=[IS NOT NULL($0)])
+                                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                    HiveProject(d_date_sk=[$0])
+                                      HiveFilter(condition=[=($6, 2001)])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveProject(i_brand_id=[$11], i_class_id=[$12], i_category_id=[$13], i_manufact_id=[$14], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                      HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                        HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15])
+                          HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                        HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], ws_quantity=[$18], ws_ext_sales_price=[$23])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[=($6, 2001)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_manufact_id=[$13])
+                            HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], $f5=[$4], $f6=[$5], CAST=[CAST($4):DECIMAL(17, 2)])
+          HiveAggregate(group=[{0, 1, 2, 3}], agg#0=[sum($4)], agg#1=[sum($5)])
+            HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                  HiveUnion(all=[true])
+                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                      HiveAggregate(group=[{0, 1, 2, 3, 4, 5}])
+                        HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], i_manufact_id=[$3], sales_cnt=[$4], sales_amt=[$5])
+                          HiveUnion(all=[true])
+                            HiveProject(i_brand_id=[$11], i_class_id=[$12], i_category_id=[$13], i_manufact_id=[$14], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_quantity=[$17], cr_return_amount=[$18])
+                                  HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                                HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_ext_sales_price=[$23])
+                                      HiveFilter(condition=[IS NOT NULL($0)])
+                                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(d_date_sk=[$0])
+                                      HiveFilter(condition=[=($6, 2002)])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                            HiveProject(i_brand_id=[$11], i_class_id=[$12], i_category_id=[$13], i_manufact_id=[$14], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_quantity=[$10], sr_return_amt=[$11])
+                                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                                HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], ss_quantity=[$10], ss_ext_sales_price=[$15])
+                                      HiveFilter(condition=[IS NOT NULL($0)])
+                                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                    HiveProject(d_date_sk=[$0])
+                                      HiveFilter(condition=[=($6, 2002)])
+                                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_manufact_id=[$13])
+                                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveProject(i_brand_id=[$11], i_class_id=[$12], i_category_id=[$13], i_manufact_id=[$14], sales_cnt=[-($7, CASE(IS NOT NULL($2), $2, 0))], sales_amt=[-($8, CASE(IS NOT NULL($3), $3, 0))])
+                      HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[right], algorithm=[none], cost=[not available])
+                        HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15])
+                          HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                        HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], ws_quantity=[$18], ws_ext_sales_price=[$23])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[=($6, 2002)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11], i_manufact_id=[$13])
+                            HiveFilter(condition=[AND(=($12, _UTF-16LE'Sports'), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($13))])
+                              HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query76.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query76.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query76.q.out
new file mode 100644
index 0000000..1f8c55a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query76.q.out
@@ -0,0 +1,95 @@
+PREHOOK: query: explain cbo
+select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
+        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
+         FROM store_sales, item, date_dim
+         WHERE ss_addr_sk IS NULL
+           AND ss_sold_date_sk=d_date_sk
+           AND ss_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
+         FROM web_sales, item, date_dim
+         WHERE ws_web_page_sk IS NULL
+           AND ws_sold_date_sk=d_date_sk
+           AND ws_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
+         FROM catalog_sales, item, date_dim
+         WHERE cs_warehouse_sk IS NULL
+           AND cs_sold_date_sk=d_date_sk
+           AND cs_item_sk=i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
+        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
+         FROM store_sales, item, date_dim
+         WHERE ss_addr_sk IS NULL
+           AND ss_sold_date_sk=d_date_sk
+           AND ss_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
+         FROM web_sales, item, date_dim
+         WHERE ws_web_page_sk IS NULL
+           AND ws_sold_date_sk=d_date_sk
+           AND ws_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
+         FROM catalog_sales, item, date_dim
+         WHERE cs_warehouse_sk IS NULL
+           AND cs_sold_date_sk=d_date_sk
+           AND cs_item_sk=i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject(channel=[$0], col_name=[$1], d_year=[$2], d_qoy=[$3], i_category=[$4], $f5=[$5], $f6=[$6])
+    HiveAggregate(group=[{0, 1, 2, 3, 4}], agg#0=[count()], agg#1=[sum($5)])
+      HiveProject(channel=[$0], col_name=[$1], d_year=[$2], d_qoy=[$3], i_category=[$4], ext_sales_price=[$5])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store'], col_name=[_UTF-16LE'ss_addr_sk'], d_year=[$1], d_qoy=[$2], i_category=[$4], ext_sales_price=[$7])
+            HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(d_date_sk=[$0], d_year=[$6], d_qoy=[$10])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(i_item_sk=[$0], i_category=[$12])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[AND(IS NULL($6), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(channel=[_UTF-16LE'web'], col_name=[_UTF-16LE'ws_web_page_sk'], d_year=[$6], d_qoy=[$7], i_category=[$4], ext_sales_price=[$2])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_sales_price=[$23])
+                  HiveFilter(condition=[AND(IS NULL($12), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(i_item_sk=[$0], i_category=[$12])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_year=[$6], d_qoy=[$10])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'catalog'], col_name=[_UTF-16LE'cs_warehouse_sk'], d_year=[$6], d_qoy=[$7], i_category=[$4], ext_sales_price=[$2])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                  HiveFilter(condition=[AND(IS NULL($14), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(i_item_sk=[$0], i_category=[$12])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_year=[$6], d_qoy=[$10])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[08/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query72.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query72.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query72.q.out
new file mode 100644
index 0000000..f27fbc9
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query72.q.out
@@ -0,0 +1,297 @@
+PREHOOK: query: explain
+select  i_item_desc
+      ,w_warehouse_name
+      ,d1.d_week_seq
+      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
+      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
+      ,count(*) total_cnt
+from catalog_sales
+join inventory on (cs_item_sk = inv_item_sk)
+join warehouse on (w_warehouse_sk=inv_warehouse_sk)
+join item on (i_item_sk = cs_item_sk)
+join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk)
+join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk)
+join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk)
+join date_dim d2 on (inv_date_sk = d2.d_date_sk)
+join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk)
+left outer join promotion on (cs_promo_sk=p_promo_sk)
+left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number)
+where d1.d_week_seq = d2.d_week_seq
+  and inv_quantity_on_hand < cs_quantity 
+  and d3.d_date > d1.d_date + 5
+  and hd_buy_potential = '1001-5000'
+  and d1.d_year = 2001
+  and hd_buy_potential = '1001-5000'
+  and cd_marital_status = 'M'
+  and d1.d_year = 2001
+group by i_item_desc,w_warehouse_name,d1.d_week_seq
+order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_desc
+      ,w_warehouse_name
+      ,d1.d_week_seq
+      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
+      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
+      ,count(*) total_cnt
+from catalog_sales
+join inventory on (cs_item_sk = inv_item_sk)
+join warehouse on (w_warehouse_sk=inv_warehouse_sk)
+join item on (i_item_sk = cs_item_sk)
+join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk)
+join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk)
+join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk)
+join date_dim d2 on (inv_date_sk = d2.d_date_sk)
+join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk)
+left outer join promotion on (cs_promo_sk=p_promo_sk)
+left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number)
+where d1.d_week_seq = d2.d_week_seq
+  and inv_quantity_on_hand < cs_quantity 
+  and d3.d_date > d1.d_date + 5
+  and hd_buy_potential = '1001-5000'
+  and d1.d_year = 2001
+  and hd_buy_potential = '1001-5000'
+  and cd_marital_status = 'M'
+  and d1.d_year = 2001
+group by i_item_desc,w_warehouse_name,d1.d_week_seq
+order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 9 <- Reducer 17 (BROADCAST_EDGE), Reducer 19 (BROADCAST_EDGE), Reducer 21 (BROADCAST_EDGE)
+Reducer 10 <- Map 16 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 18 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Map 20 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Map 22 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Map 23 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+Reducer 15 <- Map 24 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Map 18 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 21 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 15 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 25 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 26 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_293]
+        Limit [LIM_292] (rows=100 width=312)
+          Number of rows:100
+          Select Operator [SEL_291] (rows=384313734 width=312)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_290]
+              Group By Operator [GBY_289] (rows=384313734 width=312)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["count(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2
+              <-Reducer 5 [SIMPLE_EDGE]
+                SHUFFLE [RS_64]
+                  PartitionCols:_col0, _col1, _col2
+                  Group By Operator [GBY_63] (rows=610435044 width=312)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["count(_col3)","count(_col4)","count()"],keys:_col0, _col1, _col2
+                    Select Operator [SEL_61] (rows=1574305390 width=292)
+                      Output:["_col0","_col1","_col2","_col3","_col4"]
+                      Merge Join Operator [MERGEJOIN_246] (rows=1574305390 width=292)
+                        Conds:RS_58._col4, _col6=RS_288._col0, _col1(Left Outer),Output:["_col13","_col15","_col19","_col25"]
+                      <-Map 26 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_288]
+                          PartitionCols:_col0, _col1
+                          Select Operator [SEL_287] (rows=28798881 width=8)
+                            Output:["_col0","_col1"]
+                            TableScan [TS_56] (rows=28798881 width=8)
+                              default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_item_sk","cr_order_number"]
+                      <-Reducer 4 [SIMPLE_EDGE]
+                        SHUFFLE [RS_58]
+                          PartitionCols:_col4, _col6
+                          Select Operator [SEL_55] (rows=610435044 width=300)
+                            Output:["_col4","_col6","_col13","_col15","_col19","_col25"]
+                            Merge Join Operator [MERGEJOIN_245] (rows=610435044 width=300)
+                              Conds:RS_52._col0, _col19=RS_286._col0, _col1(Inner),Output:["_col5","_col9","_col14","_col16","_col19","_col23"]
+                            <-Map 25 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_286]
+                                PartitionCols:_col0, _col1
+                                Select Operator [SEL_285] (rows=73049 width=8)
+                                  Output:["_col0","_col1"]
+                                  Filter Operator [FIL_284] (rows=73049 width=8)
+                                    predicate:d_week_seq is not null
+                                    TableScan [TS_42] (rows=73049 width=8)
+                                      default@date_dim,d2,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_week_seq"]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_52]
+                                PartitionCols:_col0, _col19
+                                Filter Operator [FIL_51] (rows=545947820 width=311)
+                                  predicate:(_col3 < _col17)
+                                  Merge Join Operator [MERGEJOIN_244] (rows=1637843460 width=311)
+                                    Conds:RS_48._col1=RS_49._col8(Inner),Output:["_col0","_col3","_col5","_col9","_col14","_col16","_col17","_col19","_col23"]
+                                  <-Reducer 15 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_49]
+                                      PartitionCols:_col8
+                                      Select Operator [SEL_41] (rows=2726340 width=219)
+                                        Output:["_col3","_col8","_col10","_col11","_col13","_col17"]
+                                        Filter Operator [FIL_40] (rows=2726340 width=219)
+                                          predicate:(_col17 > _col10)
+                                          Merge Join Operator [MERGEJOIN_243] (rows=8179022 width=219)
+                                            Conds:RS_37._col1=RS_283._col0(Inner),Output:["_col4","_col6","_col7","_col9","_col10","_col13","_col15","_col17"]
+                                          <-Map 24 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_283]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_282] (rows=73049 width=12)
+                                                Output:["_col0","_col1"]
+                                                TableScan [TS_20] (rows=73049 width=98)
+                                                  default@date_dim,d3,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                          <-Reducer 14 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_37]
+                                              PartitionCols:_col1
+                                              Merge Join Operator [MERGEJOIN_242] (rows=8179022 width=214)
+                                                Conds:RS_34._col4=RS_281._col0(Inner),Output:["_col1","_col4","_col6","_col7","_col9","_col10","_col13","_col15"]
+                                              <-Map 23 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_281]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_280] (rows=462000 width=188)
+                                                    Output:["_col0","_col1"]
+                                                    TableScan [TS_18] (rows=462000 width=188)
+                                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_desc"]
+                                              <-Reducer 13 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_34]
+                                                  PartitionCols:_col4
+                                                  Merge Join Operator [MERGEJOIN_241] (rows=8179022 width=30)
+                                                    Conds:RS_31._col5=RS_279._col0(Left Outer),Output:["_col1","_col4","_col6","_col7","_col9","_col10","_col13"]
+                                                  <-Map 22 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_279]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_278] (rows=2300 width=4)
+                                                        Output:["_col0"]
+                                                        TableScan [TS_16] (rows=2300 width=4)
+                                                          default@promotion,promotion,Tbl:COMPLETE,Col:COMPLETE,Output:["p_promo_sk"]
+                                                  <-Reducer 12 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_31]
+                                                      PartitionCols:_col5
+                                                      Merge Join Operator [MERGEJOIN_240] (rows=8179022 width=29)
+                                                        Conds:RS_28._col3=RS_269._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col9","_col10"]
+                                                      <-Map 20 [SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_269]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_268] (rows=1440 width=4)
+                                                            Output:["_col0"]
+                                                            Filter Operator [FIL_267] (rows=1440 width=96)
+                                                              predicate:(hd_buy_potential = '1001-5000')
+                                                              TableScan [TS_13] (rows=7200 width=96)
+                                                                default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_buy_potential"]
+                                                      <-Reducer 11 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_28]
+                                                          PartitionCols:_col3
+                                                          Merge Join Operator [MERGEJOIN_239] (rows=40895108 width=35)
+                                                            Conds:RS_25._col2=RS_261._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col9","_col10"]
+                                                          <-Map 18 [SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_261]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_260] (rows=265971 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_259] (rows=265971 width=89)
+                                                                  predicate:(cd_marital_status = 'M')
+                                                                  TableScan [TS_10] (rows=1861800 width=89)
+                                                                    default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_marital_status"]
+                                                          <-Reducer 10 [SIMPLE_EDGE]
+                                                            SHUFFLE [RS_25]
+                                                              PartitionCols:_col2
+                                                              Merge Join Operator [MERGEJOIN_238] (rows=100076475 width=39)
+                                                                Conds:RS_277._col0=RS_253._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10"]
+                                                              <-Map 16 [SIMPLE_EDGE] vectorized
+                                                                PARTITION_ONLY_SHUFFLE [RS_253]
+                                                                  PartitionCols:_col0
+                                                                  Select Operator [SEL_252] (rows=652 width=16)
+                                                                    Output:["_col0","_col1","_col2"]
+                                                                    Filter Operator [FIL_251] (rows=652 width=106)
+                                                                      predicate:((d_year = 2001) and d_week_seq is not null)
+                                                                      TableScan [TS_7] (rows=73049 width=106)
+                                                                        default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date","d_week_seq","d_year"]
+                                                              <-Map 9 [SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_277]
+                                                                  PartitionCols:_col0
+                                                                  Select Operator [SEL_276] (rows=282274763 width=31)
+                                                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                                                    Filter Operator [FIL_275] (rows=282274763 width=31)
+                                                                      predicate:((cs_bill_cdemo_sk BETWEEN DynamicValue(RS_26_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_26_customer_demographics_cd_demo_sk_max) and in_bloom_filter(cs_bill_cdemo_sk, DynamicValue(RS_26_customer_demographics_cd_demo_sk_bloom_filter))) and (cs_bill_hdemo_sk BETWEEN DynamicValue(RS_29_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_29_household_demographics_hd_demo_sk_max) and in_bloom_filter(cs_bill_hdemo_sk, DynamicValue(RS_29_household_demographics_hd_demo_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_23_d1_d_date_sk_min) AND DynamicValue(RS_23_d1_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_23_d1_d_date_sk_bloom_filter))) and cs_bill_cdemo_sk is not null and cs_bill_hdemo_sk is not null and cs_ship_date_sk is not null and cs_sold_date_sk is not null)
+                                                                      TableScan [TS_4] (rows=287989836 width=31)
+                                                                        default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_ship_date_sk","cs_bill_cdemo_sk","cs_bill_hdemo_sk","cs_item_sk","cs_promo_sk","cs_order_number","cs_quantity"]
+                                                                      <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                                        BROADCAST [RS_258]
+                                                                          Group By Operator [GBY_257] (rows=1 width=12)
+                                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                          <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                            PARTITION_ONLY_SHUFFLE [RS_256]
+                                                                              Group By Operator [GBY_255] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                Select Operator [SEL_254] (rows=652 width=4)
+                                                                                  Output:["_col0"]
+                                                                                   Please refer to the previous Select Operator [SEL_252]
+                                                                      <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                                        BROADCAST [RS_266]
+                                                                          Group By Operator [GBY_265] (rows=1 width=12)
+                                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                          <-Map 18 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                            PARTITION_ONLY_SHUFFLE [RS_264]
+                                                                              Group By Operator [GBY_263] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                Select Operator [SEL_262] (rows=265971 width=4)
+                                                                                  Output:["_col0"]
+                                                                                   Please refer to the previous Select Operator [SEL_260]
+                                                                      <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                                                        BROADCAST [RS_274]
+                                                                          Group By Operator [GBY_273] (rows=1 width=12)
+                                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                          <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                            PARTITION_ONLY_SHUFFLE [RS_272]
+                                                                              Group By Operator [GBY_271] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                Select Operator [SEL_270] (rows=1440 width=4)
+                                                                                  Output:["_col0"]
+                                                                                   Please refer to the previous Select Operator [SEL_268]
+                                  <-Reducer 2 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_48]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_237] (rows=37584000 width=111)
+                                        Conds:RS_248._col2=RS_250._col0(Inner),Output:["_col0","_col1","_col3","_col5"]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_248]
+                                          PartitionCols:_col2
+                                          Select Operator [SEL_247] (rows=37584000 width=15)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            TableScan [TS_0] (rows=37584000 width=15)
+                                              default@inventory,inventory,Tbl:COMPLETE,Col:COMPLETE,Output:["inv_date_sk","inv_item_sk","inv_warehouse_sk","inv_quantity_on_hand"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_250]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_249] (rows=27 width=104)
+                                            Output:["_col0","_col1"]
+                                            TableScan [TS_2] (rows=27 width=104)
+                                              default@warehouse,warehouse,Tbl:COMPLETE,Col:COMPLETE,Output:["w_warehouse_sk","w_warehouse_name"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query73.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query73.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query73.q.out
new file mode 100644
index 0000000..45ddfd5
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query73.q.out
@@ -0,0 +1,197 @@
+PREHOOK: query: explain
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag 
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and date_dim.d_dom between 1 and 2 
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and case when household_demographics.hd_vehicle_count > 0 then 
+             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County')
+    group by ss_ticket_number,ss_customer_sk) dj,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 1 and 5
+    order by cnt desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag 
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and date_dim.d_dom between 1 and 2 
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and case when household_demographics.hd_vehicle_count > 0 then 
+             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County')
+    group by ss_ticket_number,ss_customer_sk) dj,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 1 and 5
+    order by cnt desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 4 <- Reducer 10 (BROADCAST_EDGE), Reducer 12 (BROADCAST_EDGE), Reducer 14 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 5 <- Map 4 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 6 <- Map 11 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 13 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 3 vectorized
+      File Output Operator [FS_134]
+        Select Operator [SEL_133] (rows=59862 width=364)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+        <-Reducer 2 [SIMPLE_EDGE]
+          SHUFFLE [RS_34]
+            Select Operator [SEL_33] (rows=59862 width=364)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+              Merge Join Operator [MERGEJOIN_99] (rows=59862 width=364)
+                Conds:RS_101._col0=RS_132._col1(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col7"]
+              <-Map 1 [SIMPLE_EDGE] vectorized
+                SHUFFLE [RS_101]
+                  PartitionCols:_col0
+                  Select Operator [SEL_100] (rows=80000000 width=356)
+                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                    TableScan [TS_0] (rows=80000000 width=356)
+                      default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_salutation","c_first_name","c_last_name","c_preferred_cust_flag"]
+              <-Reducer 8 [SIMPLE_EDGE] vectorized
+                SHUFFLE [RS_132]
+                  PartitionCols:_col1
+                  Filter Operator [FIL_131] (rows=59862 width=12)
+                    predicate:_col2 BETWEEN 1 AND 5
+                    Select Operator [SEL_130] (rows=1197233 width=12)
+                      Output:["_col0","_col1","_col2"]
+                      Group By Operator [GBY_129] (rows=1197233 width=12)
+                        Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                      <-Reducer 7 [SIMPLE_EDGE]
+                        SHUFFLE [RS_25]
+                          PartitionCols:_col0, _col1
+                          Group By Operator [GBY_24] (rows=1197233 width=12)
+                            Output:["_col0","_col1","_col2"],aggregations:["count()"],keys:_col1, _col4
+                            Merge Join Operator [MERGEJOIN_98] (rows=1197233 width=4)
+                              Conds:RS_20._col3=RS_120._col0(Inner),Output:["_col1","_col4"]
+                            <-Map 13 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_120]
+                                PartitionCols:_col0
+                                Select Operator [SEL_119] (rows=85 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_118] (rows=85 width=102)
+                                    predicate:(s_county) IN ('Mobile County', 'Maverick County', 'Huron County', 'Kittitas County')
+                                    TableScan [TS_11] (rows=1704 width=102)
+                                      default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_county"]
+                            <-Reducer 6 [SIMPLE_EDGE]
+                              SHUFFLE [RS_20]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_97] (rows=2973700 width=4)
+                                  Conds:RS_17._col2=RS_112._col0(Inner),Output:["_col1","_col3","_col4"]
+                                <-Map 11 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_112]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_111] (rows=480 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_110] (rows=480 width=104)
+                                        predicate:((hd_buy_potential) IN ('>10000', 'unknown') and (hd_vehicle_count > 0) and CASE WHEN ((hd_vehicle_count > 0)) THEN (((UDFToDouble(hd_dep_count) / UDFToDouble(hd_vehicle_count)) > 1.0D)) ELSE (null) END)
+                                        TableScan [TS_8] (rows=7200 width=104)
+                                          default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_buy_potential","hd_dep_count","hd_vehicle_count"]
+                                <-Reducer 5 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_17]
+                                    PartitionCols:_col2
+                                    Merge Join Operator [MERGEJOIN_96] (rows=44605486 width=10)
+                                      Conds:RS_128._col0=RS_104._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                    <-Map 9 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_104]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_103] (rows=170 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_102] (rows=170 width=12)
+                                            predicate:((d_year) IN (2000, 2001, 2002) and d_dom BETWEEN 1 AND 2)
+                                            TableScan [TS_5] (rows=73049 width=12)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_dom"]
+                                    <-Map 4 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_128]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_127] (rows=479121995 width=19)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                          Filter Operator [FIL_126] (rows=479121995 width=19)
+                                            predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_18_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_18_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_18_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_21_store_s_store_sk_min) AND DynamicValue(RS_21_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_21_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_hdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                            TableScan [TS_2] (rows=575995635 width=19)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_hdemo_sk","ss_store_sk","ss_ticket_number"]
+                                            <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_109]
+                                                Group By Operator [GBY_108] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_107]
+                                                    Group By Operator [GBY_106] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_105] (rows=170 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_103]
+                                            <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_117]
+                                                Group By Operator [GBY_116] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_115]
+                                                    Group By Operator [GBY_114] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_113] (rows=480 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_111]
+                                            <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_125]
+                                                Group By Operator [GBY_124] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_123]
+                                                    Group By Operator [GBY_122] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_121] (rows=85 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_119]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query74.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query74.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query74.q.out
new file mode 100644
index 0000000..39b3f0a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query74.q.out
@@ -0,0 +1,397 @@
+PREHOOK: query: explain
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ss_net_paid) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ws_net_paid) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         )
+  select 
+        t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.year = 2001
+         and t_s_secyear.year = 2001+1
+         and t_w_firstyear.year = 2001
+         and t_w_secyear.year = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by 2,1,3
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ss_net_paid) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ws_net_paid) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         )
+  select 
+        t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.year = 2001
+         and t_s_secyear.year = 2001+1
+         and t_w_firstyear.year = 2001
+         and t_w_secyear.year = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by 2,1,3
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 23 (BROADCAST_EDGE)
+Map 13 <- Reducer 25 (BROADCAST_EDGE)
+Map 17 <- Reducer 22 (BROADCAST_EDGE)
+Map 9 <- Reducer 24 (BROADCAST_EDGE)
+Reducer 10 <- Map 21 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 26 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE)
+Reducer 14 <- Map 13 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 15 <- Map 26 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
+Reducer 18 <- Map 17 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 19 <- Map 26 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 23 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 24 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 26 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 12 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 16 (SIMPLE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 20 (SIMPLE_EDGE), Reducer 6 (ONE_TO_ONE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_348]
+        Limit [LIM_347] (rows=100 width=280)
+          Number of rows:100
+          Select Operator [SEL_346] (rows=12248093 width=280)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 7 [SIMPLE_EDGE]
+            SHUFFLE [RS_89]
+              Select Operator [SEL_88] (rows=12248093 width=280)
+                Output:["_col0","_col1","_col2"]
+                Filter Operator [FIL_87] (rows=12248093 width=736)
+                  predicate:CASE WHEN (_col4) THEN (CASE WHEN (_col7) THEN (((_col1 / _col6) > (_col11 / _col3))) ELSE ((null > (_col11 / _col3))) END) ELSE (CASE WHEN (_col7) THEN (((_col1 / _col6) > null)) ELSE (null) END) END
+                  Merge Join Operator [MERGEJOIN_283] (rows=24496186 width=736)
+                    Conds:RS_84._col2=RS_345._col0(Inner),Output:["_col1","_col3","_col4","_col6","_col7","_col8","_col9","_col10","_col11"]
+                  <-Reducer 20 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_345]
+                      PartitionCols:_col0
+                      Group By Operator [GBY_344] (rows=80000000 width=392)
+                        Output:["_col0","_col1","_col2","_col3"],aggregations:["max(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                      <-Reducer 19 [SIMPLE_EDGE]
+                        SHUFFLE [RS_75]
+                          PartitionCols:_col0, _col1, _col2
+                          Group By Operator [GBY_74] (rows=80000000 width=392)
+                            Output:["_col0","_col1","_col2","_col3"],aggregations:["max(_col2)"],keys:_col5, _col6, _col7
+                            Merge Join Operator [MERGEJOIN_280] (rows=187573258 width=377)
+                              Conds:RS_70._col1=RS_312._col0(Inner),Output:["_col2","_col5","_col6","_col7"]
+                            <-Map 26 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_312]
+                                PartitionCols:_col0
+                                Select Operator [SEL_311] (rows=80000000 width=284)
+                                  Output:["_col0","_col1","_col2","_col3"]
+                                  TableScan [TS_65] (rows=80000000 width=284)
+                                    default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_customer_id","c_first_name","c_last_name"]
+                            <-Reducer 18 [SIMPLE_EDGE]
+                              SHUFFLE [RS_70]
+                                PartitionCols:_col1
+                                Merge Join Operator [MERGEJOIN_279] (rows=187573258 width=101)
+                                  Conds:RS_343._col0=RS_290._col0(Inner),Output:["_col1","_col2"]
+                                <-Map 21 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_290]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_287] (rows=652 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_284] (rows=652 width=8)
+                                        predicate:((d_year = 2002) and (d_year) IN (2001, 2002))
+                                        TableScan [TS_62] (rows=73049 width=8)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                <-Map 17 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_343]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_342] (rows=525327388 width=114)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_341] (rows=525327388 width=114)
+                                        predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_68_date_dim_d_date_sk_min) AND DynamicValue(RS_68_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_68_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                        TableScan [TS_59] (rows=575995635 width=114)
+                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_net_paid"]
+                                        <-Reducer 22 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_340]
+                                            Group By Operator [GBY_339] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_302]
+                                                Group By Operator [GBY_298] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_291] (rows=652 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_287]
+                  <-Reducer 6 [ONE_TO_ONE_EDGE]
+                    FORWARD [RS_84]
+                      PartitionCols:_col2
+                      Merge Join Operator [MERGEJOIN_282] (rows=20485011 width=444)
+                        Conds:RS_81._col2=RS_338._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col6","_col7"]
+                      <-Reducer 16 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_338]
+                          PartitionCols:_col0
+                          Select Operator [SEL_337] (rows=17130654 width=216)
+                            Output:["_col0","_col1","_col2"]
+                            Filter Operator [FIL_336] (rows=17130654 width=212)
+                              predicate:(_col3 > 0)
+                              Select Operator [SEL_335] (rows=51391963 width=212)
+                                Output:["_col0","_col3"]
+                                Group By Operator [GBY_334] (rows=51391963 width=392)
+                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["max(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                <-Reducer 15 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_55]
+                                    PartitionCols:_col0, _col1, _col2
+                                    Group By Operator [GBY_54] (rows=51391963 width=392)
+                                      Output:["_col0","_col1","_col2","_col3"],aggregations:["max(_col2)"],keys:_col5, _col6, _col7
+                                      Merge Join Operator [MERGEJOIN_278] (rows=51391963 width=391)
+                                        Conds:RS_50._col1=RS_315._col0(Inner),Output:["_col2","_col5","_col6","_col7"]
+                                      <-Map 26 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_315]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_311]
+                                      <-Reducer 14 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_50]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_277] (rows=51391963 width=115)
+                                            Conds:RS_333._col0=RS_296._col0(Inner),Output:["_col1","_col2"]
+                                          <-Map 21 [SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_296]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_289] (rows=652 width=4)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_286] (rows=652 width=8)
+                                                  predicate:((d_year = 2001) and (d_year) IN (2001, 2002))
+                                                   Please refer to the previous TableScan [TS_62]
+                                          <-Map 13 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_333]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_332] (rows=143930993 width=119)
+                                                Output:["_col0","_col1","_col2"]
+                                                Filter Operator [FIL_331] (rows=143930993 width=119)
+                                                  predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_48_date_dim_d_date_sk_min) AND DynamicValue(RS_48_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_48_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                  TableScan [TS_39] (rows=144002668 width=119)
+                                                    default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk","ws_net_paid"]
+                                                  <-Reducer 25 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_330]
+                                                      Group By Operator [GBY_329] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_305]
+                                                          Group By Operator [GBY_301] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_297] (rows=652 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_289]
+                      <-Reducer 5 [ONE_TO_ONE_EDGE]
+                        FORWARD [RS_81]
+                          PartitionCols:_col2
+                          Merge Join Operator [MERGEJOIN_281] (rows=31888273 width=328)
+                            Conds:RS_318._col0=RS_328._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                          <-Reducer 12 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_328]
+                              PartitionCols:_col0
+                              Select Operator [SEL_327] (rows=26666666 width=216)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_326] (rows=26666666 width=212)
+                                  predicate:(_col3 > 0)
+                                  Select Operator [SEL_325] (rows=80000000 width=212)
+                                    Output:["_col0","_col3"]
+                                    Group By Operator [GBY_324] (rows=80000000 width=392)
+                                      Output:["_col0","_col1","_col2","_col3"],aggregations:["max(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                    <-Reducer 11 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_35]
+                                        PartitionCols:_col0, _col1, _col2
+                                        Group By Operator [GBY_34] (rows=80000000 width=392)
+                                          Output:["_col0","_col1","_col2","_col3"],aggregations:["max(_col2)"],keys:_col5, _col6, _col7
+                                          Merge Join Operator [MERGEJOIN_276] (rows=187573258 width=377)
+                                            Conds:RS_30._col1=RS_314._col0(Inner),Output:["_col2","_col5","_col6","_col7"]
+                                          <-Map 26 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_314]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_311]
+                                          <-Reducer 10 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_30]
+                                              PartitionCols:_col1
+                                              Merge Join Operator [MERGEJOIN_275] (rows=187573258 width=101)
+                                                Conds:RS_323._col0=RS_294._col0(Inner),Output:["_col1","_col2"]
+                                              <-Map 21 [SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_294]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_288] (rows=652 width=4)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_285] (rows=652 width=8)
+                                                      predicate:((d_year = 2001) and (d_year) IN (2001, 2002))
+                                                       Please refer to the previous TableScan [TS_62]
+                                              <-Map 9 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_323]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_322] (rows=525327388 width=114)
+                                                    Output:["_col0","_col1","_col2"]
+                                                    Filter Operator [FIL_321] (rows=525327388 width=114)
+                                                      predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_28_date_dim_d_date_sk_min) AND DynamicValue(RS_28_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_28_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                      TableScan [TS_19] (rows=575995635 width=114)
+                                                        default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_net_paid"]
+                                                      <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                        BROADCAST [RS_320]
+                                                          Group By Operator [GBY_319] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                          <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_304]
+                                                              Group By Operator [GBY_300] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                Select Operator [SEL_295] (rows=652 width=4)
+                                                                  Output:["_col0"]
+                                                                   Please refer to the previous Select Operator [SEL_288]
+                          <-Reducer 4 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_318]
+                              PartitionCols:_col0
+                              Select Operator [SEL_317] (rows=51391963 width=212)
+                                Output:["_col0","_col1"]
+                                Group By Operator [GBY_316] (rows=51391963 width=392)
+                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["max(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                <-Reducer 3 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_16]
+                                    PartitionCols:_col0, _col1, _col2
+                                    Group By Operator [GBY_15] (rows=51391963 width=392)
+                                      Output:["_col0","_col1","_col2","_col3"],aggregations:["max(_col2)"],keys:_col5, _col6, _col7
+                                      Merge Join Operator [MERGEJOIN_274] (rows=51391963 width=391)
+                                        Conds:RS_11._col1=RS_313._col0(Inner),Output:["_col2","_col5","_col6","_col7"]
+                                      <-Map 26 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_313]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_311]
+                                      <-Reducer 2 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_11]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_273] (rows=51391963 width=115)
+                                            Conds:RS_310._col0=RS_292._col0(Inner),Output:["_col1","_col2"]
+                                          <-Map 21 [SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_292]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_287]
+                                          <-Map 1 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_310]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_309] (rows=143930993 width=119)
+                                                Output:["_col0","_col1","_col2"]
+                                                Filter Operator [FIL_308] (rows=143930993 width=119)
+                                                  predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_9_date_dim_d_date_sk_min) AND DynamicValue(RS_9_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_9_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                  TableScan [TS_0] (rows=144002668 width=119)
+                                                    default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk","ws_net_paid"]
+                                                  <-Reducer 23 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_307]
+                                                      Group By Operator [GBY_306] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_303]
+                                                          Group By Operator [GBY_299] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_293] (rows=652 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_287]
+


[28/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query83.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query83.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query83.q.out
new file mode 100644
index 0000000..ee94ea3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query83.q.out
@@ -0,0 +1,219 @@
+PREHOOK: query: explain cbo
+with sr_items as
+ (select i_item_id item_id,
+        sum(sr_return_quantity) sr_item_qty
+ from store_returns,
+      item,
+      date_dim
+ where sr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   sr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+        sum(cr_return_quantity) cr_item_qty
+ from catalog_returns,
+      item,
+      date_dim
+ where cr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   cr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+        sum(wr_return_quantity) wr_item_qty
+ from web_returns,
+      item,
+      date_dim
+ where wr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+		where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   wr_returned_date_sk   = d_date_sk
+ group by i_item_id)
+  select  sr_items.item_id
+       ,sr_item_qty
+       ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev
+       ,cr_item_qty
+       ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev
+       ,wr_item_qty
+       ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev
+       ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average
+ from sr_items
+     ,cr_items
+     ,wr_items
+ where sr_items.item_id=cr_items.item_id
+   and sr_items.item_id=wr_items.item_id 
+ order by sr_items.item_id
+         ,sr_item_qty
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@web_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with sr_items as
+ (select i_item_id item_id,
+        sum(sr_return_quantity) sr_item_qty
+ from store_returns,
+      item,
+      date_dim
+ where sr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   sr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+        sum(cr_return_quantity) cr_item_qty
+ from catalog_returns,
+      item,
+      date_dim
+ where cr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   cr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+        sum(wr_return_quantity) wr_item_qty
+ from web_returns,
+      item,
+      date_dim
+ where wr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+		where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   wr_returned_date_sk   = d_date_sk
+ group by i_item_id)
+  select  sr_items.item_id
+       ,sr_item_qty
+       ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev
+       ,cr_item_qty
+       ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev
+       ,wr_item_qty
+       ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev
+       ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average
+ from sr_items
+     ,cr_items
+     ,wr_items
+ where sr_items.item_id=cr_items.item_id
+   and sr_items.item_id=wr_items.item_id 
+ order by sr_items.item_id
+         ,sr_item_qty
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(item_id=[$0], sr_item_qty=[$4], sr_dev=[*(/(/($5, CAST(+(+($4, $1), $7)):DOUBLE), CAST(3):DOUBLE), CAST(100):DOUBLE)], cr_item_qty=[$1], cr_dev=[*(/(/($2, CAST(+(+($4, $1), $7)):DOUBLE), CAST(3):DOUBLE), CAST(100):DOUBLE)], wr_item_qty=[$7], wr_dev=[*(/(/($8, CAST(+(+($4, $1), $7)):DOUBLE), CAST(3):DOUBLE), CAST(100):DOUBLE)], average=[/(CAST(+(+($4, $1), $7)):DECIMAL(19, 0), 3)])
+    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(item_id=[$0], cr_item_qty=[$1], CAST=[CAST($1):DOUBLE])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cr_returned_date_sk=[$0], cr_item_sk=[$2], cr_return_quantity=[$17])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[IS NOT NULL($2)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveSemiJoin(condition=[=($1, $6)], joinType=[inner])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(d_date_sk=[$0], d_date_id=[$1], d_date=[$2], d_month_seq=[$3], d_week_seq=[$4], d_quarter_seq=[$5], d_year=[$6], d_dow=[$7], d_moy=[$8], d_dom=[$9], d_qoy=[$10], d_fy_year=[$11], d_fy_quarter_seq=[$12], d_fy_week_seq=[$13], d_day_name=[$14], d_quarter_name=[$15], d_holiday=[$16], d_weekend=[$17], d_following_holiday=[$18], d_first_dom=[$19], d_last_dom=[$20], d_same_day_ly=[$21], d_same_day_lq=[$22], d_current_day=[$23], d_current_week=[$24], d_current_month=[$25], d_current_quarter=[$26], d_current_year=[$27], BLOCK__OFFSET__INSIDE__FILE=[$28], INPUT__FILE__NAME=[$29], ROW__ID=[$30])
+                          HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(item_id=[$0], sr_item_qty=[$1], CAST=[CAST($1):DOUBLE])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_return_quantity=[$10])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[IS NOT NULL($2)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveSemiJoin(condition=[=($1, $6)], joinType=[inner])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(d_date_sk=[$0], d_date_id=[$1], d_date=[$2], d_month_seq=[$3], d_week_seq=[$4], d_quarter_seq=[$5], d_year=[$6], d_dow=[$7], d_moy=[$8], d_dom=[$9], d_qoy=[$10], d_fy_year=[$11], d_fy_quarter_seq=[$12], d_fy_week_seq=[$13], d_day_name=[$14], d_quarter_name=[$15], d_holiday=[$16], d_weekend=[$17], d_following_holiday=[$18], d_first_dom=[$19], d_last_dom=[$20], d_same_day_ly=[$21], d_same_day_lq=[$22], d_current_day=[$23], d_current_week=[$24], d_current_month=[$25], d_current_quarter=[$26], d_current_year=[$27], BLOCK__OFFSET__INSIDE__FILE=[$28], INPUT__FILE__NAME=[$29], ROW__ID=[$30])
+                          HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(item_id=[$0], wr_item_qty=[$1], CAST=[CAST($1):DOUBLE])
+        HiveAggregate(group=[{4}], agg#0=[sum($2)])
+          HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(wr_returned_date_sk=[$0], wr_item_sk=[$2], wr_return_quantity=[$14])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+            HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+              HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0], d_date=[$2])
+                  HiveFilter(condition=[IS NOT NULL($2)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(d_date=[$0])
+                  HiveAggregate(group=[{0}])
+                    HiveSemiJoin(condition=[=($1, $6)], joinType=[inner])
+                      HiveProject(d_date=[$2], d_week_seq=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(d_date_sk=[$0], d_date_id=[$1], d_date=[$2], d_month_seq=[$3], d_week_seq=[$4], d_quarter_seq=[$5], d_year=[$6], d_dow=[$7], d_moy=[$8], d_dom=[$9], d_qoy=[$10], d_fy_year=[$11], d_fy_quarter_seq=[$12], d_fy_week_seq=[$13], d_day_name=[$14], d_quarter_name=[$15], d_holiday=[$16], d_weekend=[$17], d_following_holiday=[$18], d_first_dom=[$19], d_last_dom=[$20], d_same_day_ly=[$21], d_same_day_lq=[$22], d_current_day=[$23], d_current_week=[$24], d_current_month=[$25], d_current_quarter=[$26], d_current_year=[$27], BLOCK__OFFSET__INSIDE__FILE=[$28], INPUT__FILE__NAME=[$29], ROW__ID=[$30])
+                        HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query84.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query84.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query84.q.out
new file mode 100644
index 0000000..43ea953
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query84.q.out
@@ -0,0 +1,83 @@
+PREHOOK: query: explain cbo
+select  c_customer_id as customer_id
+       ,c_last_name || ', ' || c_first_name as customername
+ from customer
+     ,customer_address
+     ,customer_demographics
+     ,household_demographics
+     ,income_band
+     ,store_returns
+ where ca_city	        =  'Hopewell'
+   and c_current_addr_sk = ca_address_sk
+   and ib_lower_bound   >=  32287
+   and ib_upper_bound   <=  32287 + 50000
+   and ib_income_band_sk = hd_income_band_sk
+   and cd_demo_sk = c_current_cdemo_sk
+   and hd_demo_sk = c_current_hdemo_sk
+   and sr_cdemo_sk = cd_demo_sk
+ order by c_customer_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@income_band
+PREHOOK: Input: default@store_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  c_customer_id as customer_id
+       ,c_last_name || ', ' || c_first_name as customername
+ from customer
+     ,customer_address
+     ,customer_demographics
+     ,household_demographics
+     ,income_band
+     ,store_returns
+ where ca_city	        =  'Hopewell'
+   and c_current_addr_sk = ca_address_sk
+   and ib_lower_bound   >=  32287
+   and ib_upper_bound   <=  32287 + 50000
+   and ib_income_band_sk = hd_income_band_sk
+   and cd_demo_sk = c_current_cdemo_sk
+   and hd_demo_sk = c_current_hdemo_sk
+   and sr_cdemo_sk = cd_demo_sk
+ order by c_customer_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@income_band
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(customer_id=[$0], customername=[$1])
+  HiveSortLimit(sort0=[$2], dir0=[ASC], fetch=[100])
+    HiveProject(customer_id=[$2], customername=[$6], c_customer_id=[$2])
+      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(sr_cdemo_sk=[$4])
+            HiveFilter(condition=[IS NOT NULL($4)])
+              HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+          HiveProject(cd_demo_sk=[$0])
+            HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+        HiveProject(c_customer_id=[$0], c_current_cdemo_sk=[$1], c_current_hdemo_sk=[$2], c_current_addr_sk=[$3], ||=[$4], ca_address_sk=[$5], hd_demo_sk=[$6], hd_income_band_sk=[$7], ib_income_band_sk=[$8])
+          HiveJoin(condition=[=($6, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($3, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_id=[$1], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4], ||=[||(||($9, _UTF-16LE', '), $8)])
+                HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2), IS NOT NULL($3))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0])
+                HiveFilter(condition=[=($6, _UTF-16LE'Hopewell')])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1], ib_income_band_sk=[$2])
+              HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1])
+                  HiveFilter(condition=[IS NOT NULL($1)])
+                    HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(ib_income_band_sk=[$0])
+                  HiveFilter(condition=[AND(>=($1, 32287), <=($2, 82287))])
+                    HiveTableScan(table=[[default, income_band]], table:alias=[income_band])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query85.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query85.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query85.q.out
new file mode 100644
index 0000000..1876936
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query85.q.out
@@ -0,0 +1,214 @@
+PREHOOK: query: explain cbo
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
+ from web_sales, web_returns, web_page, customer_demographics cd1,
+      customer_demographics cd2, customer_address, date_dim, reason 
+ where ws_web_page_sk = wp_web_page_sk
+   and ws_item_sk = wr_item_sk
+   and ws_order_number = wr_order_number
+   and ws_sold_date_sk = d_date_sk and d_year = 1998
+   and cd1.cd_demo_sk = wr_refunded_cdemo_sk 
+   and cd2.cd_demo_sk = wr_returning_cdemo_sk
+   and ca_address_sk = wr_refunded_addr_sk
+   and r_reason_sk = wr_reason_sk
+   and
+   (
+    (
+     cd1.cd_marital_status = 'M'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = '4 yr Degree'
+     and 
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 100.00 and 150.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'D'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Primary' 
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 50.00 and 100.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'U'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Advanced Degree'
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 150.00 and 200.00
+    )
+   )
+   and
+   (
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('KY', 'GA', 'NM')
+     and ws_net_profit between 100 and 200  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('MT', 'OR', 'IN')
+     and ws_net_profit between 150 and 300  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('WI', 'MO', 'WV')
+     and ws_net_profit between 50 and 250  
+    )
+   )
+group by r_reason_desc
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@reason
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
+ from web_sales, web_returns, web_page, customer_demographics cd1,
+      customer_demographics cd2, customer_address, date_dim, reason 
+ where ws_web_page_sk = wp_web_page_sk
+   and ws_item_sk = wr_item_sk
+   and ws_order_number = wr_order_number
+   and ws_sold_date_sk = d_date_sk and d_year = 1998
+   and cd1.cd_demo_sk = wr_refunded_cdemo_sk 
+   and cd2.cd_demo_sk = wr_returning_cdemo_sk
+   and ca_address_sk = wr_refunded_addr_sk
+   and r_reason_sk = wr_reason_sk
+   and
+   (
+    (
+     cd1.cd_marital_status = 'M'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = '4 yr Degree'
+     and 
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 100.00 and 150.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'D'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Primary' 
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 50.00 and 100.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'U'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Advanced Degree'
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 150.00 and 200.00
+    )
+   )
+   and
+   (
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('KY', 'GA', 'NM')
+     and ws_net_profit between 100 and 200  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('MT', 'OR', 'IN')
+     and ws_net_profit between 150 and 300  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('WI', 'MO', 'WV')
+     and ws_net_profit between 50 and 250  
+    )
+   )
+group by r_reason_desc
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@reason
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(_o__c0=[$0], _o__c1=[$1], _o__c2=[$2], _o__c3=[$3])
+  HiveSortLimit(sort0=[$7], sort1=[$4], sort2=[$5], sort3=[$6], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+    HiveProject(_o__c0=[substr($0, 1, 20)], _o__c1=[/(CAST($1):DOUBLE, $2)], _o__c2=[/($3, $4)], _o__c3=[/($5, $6)], (tok_function avg (tok_table_or_col ws_quantity))=[/(CAST($1):DOUBLE, $2)], (tok_function avg (tok_table_or_col wr_refunded_cash))=[/($3, $4)], (tok_function avg (tok_table_or_col wr_fee))=[/($5, $6)], (tok_function substr (tok_table_or_col r_reason_desc) 1 20)=[substr($0, 1, 20)])
+      HiveAggregate(group=[{14}], agg#0=[sum($30)], agg#1=[count($30)], agg#2=[sum($26)], agg#3=[count($26)], agg#4=[sum($25)], agg#5=[count($25)])
+        HiveJoin(condition=[AND(AND(AND(=($1, $17), =($2, $18)), =($0, $20)), OR(AND($3, $4, $34), AND($5, $6, $35), AND($7, $8, $36)))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3], ==[=($2, _UTF-16LE'M')], =4=[=($3, _UTF-16LE'4 yr Degree')], =5=[=($2, _UTF-16LE'D')], =6=[=($3, _UTF-16LE'Primary')], =7=[=($2, _UTF-16LE'U')], =8=[=($3, _UTF-16LE'Advanced Degree')])
+            HiveFilter(condition=[AND(IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'))])
+              HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+          HiveJoin(condition=[AND(=($0, $12), OR(AND($1, $22), AND($2, $23), AND($3, $24)))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ca_address_sk=[$0], IN=[IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM')], IN2=[IN($8, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN')], IN3=[IN($8, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV')])
+              HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'))])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveJoin(condition=[=($0, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(r_reason_sk=[$0], r_reason_desc=[$2])
+                HiveTableScan(table=[[default, reason]], table:alias=[reason])
+              HiveJoin(condition=[=($12, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[=($6, 1998)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
+                    HiveFilter(condition=[AND(IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'))])
+                      HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+                  HiveJoin(condition=[AND(=($9, $0), =($10, $5))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(wr_item_sk=[$2], wr_refunded_cdemo_sk=[$4], wr_refunded_addr_sk=[$6], wr_returning_cdemo_sk=[$8], wr_reason_sk=[$12], wr_order_number=[$13], wr_fee=[$18], wr_refunded_cash=[$20])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($8), IS NOT NULL($6), IS NOT NULL($12))])
+                        HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                    HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], ws_quantity=[$18], BETWEEN=[BETWEEN(false, $33, 100, 200)], BETWEEN6=[BETWEEN(false, $33, 150, 300)], BETWEEN7=[BETWEEN(false, $33, 50, 250)], BETWEEN8=[BETWEEN(false, $21, 100, 150)], BETWEEN9=[BETWEEN(false, $21, 50, 100)], BETWEEN10=[BETWEEN(false, $21, 150, 200)])
+                      HiveFilter(condition=[AND(OR(BETWEEN(false, $21, 100, 150), BETWEEN(false, $21, 50, 100), BETWEEN(false, $21, 150, 200)), OR(BETWEEN(false, $33, 100, 200), BETWEEN(false, $33, 150, 300), BETWEEN(false, $33, 50, 250)), IS NOT NULL($12), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query86.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query86.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query86.q.out
new file mode 100644
index 0000000..8e89983
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query86.q.out
@@ -0,0 +1,76 @@
+PREHOOK: query: explain cbo
+select   
+    sum(ws_net_paid) as total_sum
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ws_net_paid) desc) as rank_within_parent
+ from
+    web_sales
+   ,date_dim       d1
+   ,item
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ws_sold_date_sk
+ and i_item_sk  = ws_item_sk
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc,
+   case when lochierarchy = 0 then i_category end,
+   rank_within_parent
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select   
+    sum(ws_net_paid) as total_sum
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ws_net_paid) desc) as rank_within_parent
+ from
+    web_sales
+   ,date_dim       d1
+   ,item
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ws_sold_date_sk
+ and i_item_sk  = ws_item_sk
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc,
+   case when lochierarchy = 0 then i_category end,
+   rank_within_parent
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(total_sum=[$0], i_category=[$1], i_class=[$2], lochierarchy=[$3], rank_within_parent=[$4])
+  HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(total_sum=[$2], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($3, 1), grouping($3, 0))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($3, 1), grouping($3, 0)), CASE(=(grouping($3, 0), 0), $0, null) ORDER BY $2 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok_table_or_col i_category))=[CASE(=(+(grouping($3, 1), grouping($3, 0)), 0), $0, null)])
+      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], GROUPING__ID=[$3])
+        HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], GROUPING__ID=[GROUPING__ID()])
+          HiveProject($f0=[$2], $f1=[$1], $f2=[$5])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_class=[$10], i_category=[$12])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_net_paid=[$29])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query87.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query87.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query87.q.out
new file mode 100644
index 0000000..97c9edd
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query87.q.out
@@ -0,0 +1,111 @@
+PREHOOK: query: explain cbo
+select count(*) 
+from ((select distinct c_last_name, c_first_name, d_date
+       from store_sales, date_dim, customer
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from catalog_sales, date_dim, customer
+       where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+         and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from web_sales, date_dim, customer
+       where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+         and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+) cool_cust
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select count(*) 
+from ((select distinct c_last_name, c_first_name, d_date
+       from store_sales, date_dim, customer
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from catalog_sales, date_dim, customer
+       where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+         and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from web_sales, date_dim, customer
+       where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+         and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+) cool_cust
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveAggregate(group=[{}], agg#0=[count()])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveFilter(condition=[AND(>($3, 0), =(*($3, 2), $4))])
+      HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[sum($4)])
+        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f4=[$4], $f5=[*($3, $4)])
+          HiveUnion(all=[true])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[2], $f4=[$3])
+              HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                  HiveFilter(condition=[AND(>($3, 0), =(*($3, 2), $4))])
+                    HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[sum($4)])
+                      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f4=[$4], $f5=[*($3, $4)])
+                        HiveUnion(all=[true])
+                          HiveProject($f0=[$1], $f1=[$0], $f2=[$2], $f3=[2], $f4=[$3])
+                            HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                              HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                                HiveAggregate(group=[{1, 2, 6}])
+                                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                                        HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject($f0=[$1], $f1=[$0], $f2=[$2], $f3=[1], $f4=[$3])
+                            HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                              HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                                HiveAggregate(group=[{1, 2, 6}])
+                                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3])
+                                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                                        HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject($f0=[$1], $f1=[$0], $f2=[$2], $f3=[1], $f4=[$3])
+              HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                  HiveAggregate(group=[{1, 2, 6}])
+                    HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                        HiveProject(d_date_sk=[$0], d_date=[$2])
+                          HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query88.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query88.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query88.q.out
new file mode 100644
index 0000000..1ac8fe2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query88.q.out
@@ -0,0 +1,347 @@
+Warning: Shuffle Join MERGEJOIN[599][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[600][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[601][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[602][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 9' is a cross product
+Warning: Shuffle Join MERGEJOIN[603][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 10' is a cross product
+Warning: Shuffle Join MERGEJOIN[604][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6]] in Stage 'Reducer 11' is a cross product
+Warning: Shuffle Join MERGEJOIN[605][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7]] in Stage 'Reducer 12' is a cross product
+PREHOOK: query: explain cbo
+select  *
+from
+ (select count(*) h8_30_to_9
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk   
+     and ss_hdemo_sk = household_demographics.hd_demo_sk 
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 8
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
+     and store.s_store_name = 'ese') s1,
+ (select count(*) h9_to_9_30 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 9 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s2,
+ (select count(*) h9_30_to_10 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 9
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s3,
+ (select count(*) h10_to_10_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s4,
+ (select count(*) h10_30_to_11
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s5,
+ (select count(*) h11_to_11_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 11
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s6,
+ (select count(*) h11_30_to_12
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 11
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s7,
+ (select count(*) h12_to_12_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 12
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s8
+PREHOOK: type: QUERY
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from
+ (select count(*) h8_30_to_9
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk   
+     and ss_hdemo_sk = household_demographics.hd_demo_sk 
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 8
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
+     and store.s_store_name = 'ese') s1,
+ (select count(*) h9_to_9_30 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 9 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s2,
+ (select count(*) h9_30_to_10 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 9
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s3,
+ (select count(*) h10_to_10_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s4,
+ (select count(*) h10_30_to_11
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s5,
+ (select count(*) h11_to_11_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 11
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s6,
+ (select count(*) h11_30_to_12
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 11
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s7,
+ (select count(*) h12_to_12_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 12
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s8
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject($f0=[$0], $f00=[$7], $f01=[$6], $f02=[$5], $f03=[$4], $f04=[$3], $f05=[$2], $f06=[$1])
+  HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f0=[$0])
+                  HiveAggregate(group=[{}], agg#0=[count()])
+                    HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                            HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(hd_demo_sk=[$0])
+                            HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                        HiveProject(t_time_sk=[$0])
+                          HiveFilter(condition=[AND(=($3, 8), >=($4, 30))])
+                            HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                      HiveProject(s_store_sk=[$0])
+                        HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+                HiveProject($f0=[$0])
+                  HiveAggregate(group=[{}], agg#0=[count()])
+                    HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                            HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(hd_demo_sk=[$0])
+                            HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                        HiveProject(t_time_sk=[$0])
+                          HiveFilter(condition=[AND(=($3, 12), <($4, 30))])
+                            HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                      HiveProject(s_store_sk=[$0])
+                        HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject($f0=[$0])
+                HiveAggregate(group=[{}], agg#0=[count()])
+                  HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                          HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject(hd_demo_sk=[$0])
+                          HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                            HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                      HiveProject(t_time_sk=[$0])
+                        HiveFilter(condition=[AND(=($3, 11), >=($4, 30))])
+                          HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                    HiveProject(s_store_sk=[$0])
+                      HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+            HiveProject($f0=[$0])
+              HiveAggregate(group=[{}], agg#0=[count()])
+                HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                        HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(hd_demo_sk=[$0])
+                        HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                          HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                    HiveProject(t_time_sk=[$0])
+                      HiveFilter(condition=[AND(=($3, 11), <($4, 30))])
+                        HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                  HiveProject(s_store_sk=[$0])
+                    HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+                      HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveProject($f0=[$0])
+            HiveAggregate(group=[{}], agg#0=[count()])
+              HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                      HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(hd_demo_sk=[$0])
+                      HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                        HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                  HiveProject(t_time_sk=[$0])
+                    HiveFilter(condition=[AND(=($3, 10), >=($4, 30))])
+                      HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                HiveProject(s_store_sk=[$0])
+                  HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+        HiveProject($f0=[$0])
+          HiveAggregate(group=[{}], agg#0=[count()])
+            HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                    HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(hd_demo_sk=[$0])
+                    HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                      HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(t_time_sk=[$0])
+                  HiveFilter(condition=[AND(=($3, 10), <($4, 30))])
+                    HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+              HiveProject(s_store_sk=[$0])
+                HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+                  HiveTableScan(table=[[default, store]], table:alias=[store])
+      HiveProject($f0=[$0])
+        HiveAggregate(group=[{}], agg#0=[count()])
+          HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(hd_demo_sk=[$0])
+                  HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                    HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+              HiveProject(t_time_sk=[$0])
+                HiveFilter(condition=[AND(=($3, 9), >=($4, 30))])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(s_store_sk=[$0])
+              HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+                HiveTableScan(table=[[default, store]], table:alias=[store])
+    HiveProject($f0=[$0])
+      HiveAggregate(group=[{}], agg#0=[count()])
+        HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(hd_demo_sk=[$0])
+                HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+            HiveProject(t_time_sk=[$0])
+              HiveFilter(condition=[AND(=($3, 9), <($4, 30))])
+                HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+          HiveProject(s_store_sk=[$0])
+            HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query89.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query89.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query89.q.out
new file mode 100644
index 0000000..d9c7d42
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query89.q.out
@@ -0,0 +1,87 @@
+PREHOOK: query: explain cbo
+select  *
+from(
+select i_category, i_class, i_brand,
+       s_store_name, s_company_name,
+       d_moy,
+       sum(ss_sales_price) sum_sales,
+       avg(sum(ss_sales_price)) over
+         (partition by i_category, i_brand, s_store_name, s_company_name)
+         avg_monthly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+      ss_sold_date_sk = d_date_sk and
+      ss_store_sk = s_store_sk and
+      d_year in (2000) and
+        ((i_category in ('Home','Books','Electronics') and
+          i_class in ('wallpaper','parenting','musical')
+         )
+      or (i_category in ('Shoes','Jewelry','Men') and
+          i_class in ('womens','birdal','pants') 
+        ))
+group by i_category, i_class, i_brand,
+         s_store_name, s_company_name, d_moy) tmp1
+where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
+order by sum_sales - avg_monthly_sales, s_store_name
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from(
+select i_category, i_class, i_brand,
+       s_store_name, s_company_name,
+       d_moy,
+       sum(ss_sales_price) sum_sales,
+       avg(sum(ss_sales_price)) over
+         (partition by i_category, i_brand, s_store_name, s_company_name)
+         avg_monthly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+      ss_sold_date_sk = d_date_sk and
+      ss_store_sk = s_store_sk and
+      d_year in (2000) and
+        ((i_category in ('Home','Books','Electronics') and
+          i_class in ('wallpaper','parenting','musical')
+         )
+      or (i_category in ('Shoes','Jewelry','Men') and
+          i_class in ('womens','birdal','pants') 
+        ))
+group by i_category, i_class, i_brand,
+         s_store_name, s_company_name, d_moy) tmp1
+where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
+order by sum_sales - avg_monthly_sales, s_store_name
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], s_store_name=[$3], s_company_name=[$4], d_moy=[$5], sum_sales=[$6], avg_monthly_sales=[$7])
+  HiveSortLimit(sort0=[$8], sort1=[$3], dir0=[ASC], dir1=[ASC], fetch=[100])
+    HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], s_store_name=[$3], s_company_name=[$4], d_moy=[$5], sum_sales=[$6], avg_monthly_sales=[$7], (- (tok_table_or_col sum_sales) (tok_table_or_col avg_monthly_sales))=[-($6, $7)])
+      HiveFilter(condition=[CASE(<>($7, 0), >(/(ABS(-($6, $7)), $7), 0.1), null)])
+        HiveProject((tok_table_or_col i_category)=[$2], (tok_table_or_col i_class)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[avg($6) OVER (PARTITION BY $2, $0, $4, $5 ORDER BY $2 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $5 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+          HiveProject(i_brand=[$0], i_class=[$1], i_category=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+            HiveAggregate(group=[{5, 6, 7, 9, 11, 12}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12])
+                      HiveFilter(condition=[AND(IN($10, _UTF-16LE'wallpaper', _UTF-16LE'parenting', _UTF-16LE'musical', _UTF-16LE'womens', _UTF-16LE'birdal', _UTF-16LE'pants'), IN($12, _UTF-16LE'Home', _UTF-16LE'Books', _UTF-16LE'Electronics', _UTF-16LE'Shoes', _UTF-16LE'Jewelry', _UTF-16LE'Men'), OR(AND(IN($12, _UTF-16LE'Home', _UTF-16LE'Books', _UTF-16LE'Electronics'), IN($10, _UTF-16LE'wallpaper', _UTF-16LE'parenting', _UTF-16LE'musical')), AND(IN($12, _UTF-16LE'Shoes', _UTF-16LE'Jewelry', _UTF-16LE'Men'), IN($10, _UTF-16LE'womens', _UTF-16LE'birdal', _UTF-16LE'pants'))))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(d_date_sk=[$0], d_moy=[$8])
+                    HiveFilter(condition=[=($6, 2000)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                  HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query9.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query9.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query9.q.out
new file mode 100644
index 0000000..4a92def
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query9.q.out
@@ -0,0 +1,200 @@
+Warning: Shuffle Join MERGEJOIN[171][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[172][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 3' is a cross product
+Warning: Shuffle Join MERGEJOIN[173][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[174][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[175][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[176][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[177][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[178][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8]] in Stage 'Reducer 9' is a cross product
+Warning: Shuffle Join MERGEJOIN[179][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9]] in Stage 'Reducer 10' is a cross product
+Warning: Shuffle Join MERGEJOIN[180][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10]] in Stage 'Reducer 11' is a cross product
+Warning: Shuffle Join MERGEJOIN[181][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11]] in Stage 'Reducer 12' is a cross product
+Warning: Shuffle Join MERGEJOIN[182][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12]] in Stage 'Reducer 13' is a cross product
+Warning: Shuffle Join MERGEJOIN[183][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13]] in Stage 'Reducer 14' is a cross product
+Warning: Shuffle Join MERGEJOIN[184][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14]] in Stage 'Reducer 15' is a cross product
+Warning: Shuffle Join MERGEJOIN[185][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15]] in Stage 'Reducer 16' is a cross product
+PREHOOK: query: explain cbo
+select case when (select count(*) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@reason
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select case when (select count(*) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@reason
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(bucket1=[CASE($1, $2, $3)], bucket2=[CASE($4, $5, $6)], bucket3=[CASE($7, $8, $9)], bucket4=[CASE($10, $11, $12)], bucket5=[CASE($13, $14, $15)])
+  HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+    HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                              HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                                HiveProject(r_reason_sk=[1])
+                                  HiveFilter(condition=[=($0, 1)])
+                                    HiveTableScan(table=[[default, reason]], table:alias=[reason])
+                                HiveProject(>=[>($0, 409437)])
+                                  HiveAggregate(group=[{}], agg#0=[count()])
+                                    HiveFilter(condition=[BETWEEN(false, $10, 1, 20)])
+                                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                              HiveProject($f0=[/($0, $1)])
+                                HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                                  HiveFilter(condition=[BETWEEN(false, $10, 1, 20)])
+                                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject($f0=[/($0, $1)])
+                              HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+                                HiveFilter(condition=[BETWEEN(false, $10, 1, 20)])
+                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(>=[>($0, 4595804)])
+                            HiveAggregate(group=[{}], agg#0=[count()])
+                              HiveFilter(condition=[BETWEEN(false, $10, 21, 40)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject($f0=[/($0, $1)])
+                          HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                            HiveFilter(condition=[BETWEEN(false, $10, 21, 40)])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject($f0=[/($0, $1)])
+                        HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+                          HiveFilter(condition=[BETWEEN(false, $10, 21, 40)])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(>=[>($0, 7887297)])
+                      HiveAggregate(group=[{}], agg#0=[count()])
+                        HiveFilter(condition=[BETWEEN(false, $10, 41, 60)])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject($f0=[/($0, $1)])
+                    HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                      HiveFilter(condition=[BETWEEN(false, $10, 41, 60)])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+                    HiveFilter(condition=[BETWEEN(false, $10, 41, 60)])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(>=[>($0, 10872978)])
+                HiveAggregate(group=[{}], agg#0=[count()])
+                  HiveFilter(condition=[BETWEEN(false, $10, 61, 80)])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject($f0=[/($0, $1)])
+              HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                HiveFilter(condition=[BETWEEN(false, $10, 61, 80)])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject($f0=[/($0, $1)])
+            HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+              HiveFilter(condition=[BETWEEN(false, $10, 61, 80)])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+        HiveProject(>=[>($0, 43571537)])
+          HiveAggregate(group=[{}], agg#0=[count()])
+            HiveFilter(condition=[BETWEEN(false, $10, 81, 100)])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+      HiveProject($f0=[/($0, $1)])
+        HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+          HiveFilter(condition=[BETWEEN(false, $10, 81, 100)])
+            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+    HiveProject($f0=[/($0, $1)])
+      HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+        HiveFilter(condition=[BETWEEN(false, $10, 81, 100)])
+          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+


[54/75] [abbrv] hive git commit: HIVE-20679: DDL operations on hive might create large messages for DBNotification (Anishek Agarwal, reviewed by Sankar Hariappan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosIncrementalLoadAcidTables.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosIncrementalLoadAcidTables.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosIncrementalLoadAcidTables.java
index 3fe8b58..314ca48 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosIncrementalLoadAcidTables.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosIncrementalLoadAcidTables.java
@@ -17,32 +17,19 @@
  */
 package org.apache.hadoop.hive.ql.parse;
 
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsRequest;
-import org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsResponse;
-import org.apache.hadoop.hive.metastore.api.OpenTxnRequest;
-import org.apache.hadoop.hive.metastore.api.OpenTxnsResponse;
-import org.apache.hadoop.hive.metastore.txn.TxnDbUtil;
-import org.apache.hadoop.hive.metastore.txn.TxnStore;
-import org.apache.hadoop.hive.metastore.txn.TxnUtils;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder;
 import org.apache.hadoop.hive.shims.Utils;
-import org.apache.hadoop.hive.metastore.InjectableBehaviourObjectStore;
-import org.apache.hadoop.hive.metastore.InjectableBehaviourObjectStore.CallerArguments;
-import org.apache.hadoop.hive.metastore.InjectableBehaviourObjectStore.BehaviourInjection;
+
 import static org.apache.hadoop.hive.metastore.ReplChangeManager.SOURCE_OF_REPLICATION;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hive.ql.ErrorMsg;
-import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
+
 import org.junit.rules.TestName;
 
-import org.junit.rules.TestRule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -50,13 +37,11 @@ import org.junit.BeforeClass;
 import org.junit.AfterClass;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
-import javax.annotation.Nullable;
-import java.util.Collections;
+import java.util.Map;
+
 import com.google.common.collect.Lists;
-import org.junit.Ignore;
 
 /**
  * TestReplicationScenariosAcidTables - test replication for ACID tables
@@ -65,11 +50,9 @@ public class TestReplicationScenariosIncrementalLoadAcidTables {
   @Rule
   public final TestName testName = new TestName();
 
-  @Rule
-  public TestRule replV1BackwardCompat;
-
   protected static final Logger LOG = LoggerFactory.getLogger(TestReplicationScenariosIncrementalLoadAcidTables.class);
-  private static WarehouseInstance primary, replica, replicaNonAcid;
+  static WarehouseInstance primary;
+  private static WarehouseInstance replica, replicaNonAcid;
   private static HiveConf conf;
   private String primaryDbName, replicatedDbName, primaryDbNameExtra;
   private enum OperationType {
@@ -80,12 +63,21 @@ public class TestReplicationScenariosIncrementalLoadAcidTables {
 
   @BeforeClass
   public static void classLevelSetup() throws Exception {
-    conf = new HiveConf(TestReplicationScenariosAcidTables.class);
+    HashMap<String, String> overrides = new HashMap<>();
+    overrides.put(MetastoreConf.ConfVars.EVENT_MESSAGE_FACTORY.getHiveName(),
+        GzipJSONMessageEncoder.class.getCanonicalName());
+
+    internalBeforeClassSetup(overrides, TestReplicationScenariosAcidTables.class);
+  }
+
+  static void internalBeforeClassSetup(Map<String, String> overrides, Class clazz)
+      throws Exception {
+    conf = new HiveConf(clazz);
     conf.set("dfs.client.use.datanode.hostname", "true");
     conf.set("hadoop.proxyuser." + Utils.getUGI().getShortUserName() + ".hosts", "*");
     MiniDFSCluster miniDFSCluster =
            new MiniDFSCluster.Builder(conf).numDataNodes(1).format(true).build();
-    HashMap<String, String> overridesForHiveConf = new HashMap<String, String>() {{
+    HashMap<String, String> acidConfs = new HashMap<String, String>() {{
         put("fs.defaultFS", miniDFSCluster.getFileSystem().getUri().toString());
         put("hive.support.concurrency", "true");
         put("hive.txn.manager", "org.apache.hadoop.hive.ql.lockmgr.DbTxnManager");
@@ -97,9 +89,11 @@ public class TestReplicationScenariosIncrementalLoadAcidTables {
         put("mapred.input.dir.recursive", "true");
         put("hive.metastore.disallow.incompatible.col.type.changes", "false");
     }};
-    primary = new WarehouseInstance(LOG, miniDFSCluster, overridesForHiveConf);
-    replica = new WarehouseInstance(LOG, miniDFSCluster, overridesForHiveConf);
-    HashMap<String, String> overridesForHiveConf1 = new HashMap<String, String>() {{
+
+    acidConfs.putAll(overrides);
+    primary = new WarehouseInstance(LOG, miniDFSCluster, acidConfs);
+    replica = new WarehouseInstance(LOG, miniDFSCluster, acidConfs);
+    Map<String, String> overridesForHiveConf1 = new HashMap<String, String>() {{
         put("fs.defaultFS", miniDFSCluster.getFileSystem().getUri().toString());
         put("hive.support.concurrency", "false");
         put("hive.txn.manager", "org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager");
@@ -116,7 +110,6 @@ public class TestReplicationScenariosIncrementalLoadAcidTables {
 
   @Before
   public void setup() throws Throwable {
-    replV1BackwardCompat = primary.getReplivationV1CompatRule(new ArrayList<>());
     primaryDbName = testName.getMethodName() + "_" + +System.currentTimeMillis();
     replicatedDbName = "replicated_" + primaryDbName;
     primary.run("create database " + primaryDbName + " WITH DBPROPERTIES ( '" +

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
index 1e3478d..aae7bd7 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
@@ -100,7 +100,7 @@ public class WarehouseInstance implements Closeable {
     initialize(cmRootPath.toString(), warehouseRoot.toString(), overridesForHiveConf);
   }
 
-  public WarehouseInstance(Logger logger, MiniDFSCluster cluster,
+  WarehouseInstance(Logger logger, MiniDFSCluster cluster,
       Map<String, String> overridesForHiveConf) throws Exception {
     this(logger, cluster, overridesForHiveConf, null);
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java b/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java
index 66f3b78..a51b7e7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java
@@ -60,7 +60,7 @@ import org.apache.hadoop.hive.common.ValidWriteIdList;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hadoop.hive.ql.exec.Utilities;
 import org.apache.hadoop.hive.ql.hooks.Entity.Type;
 import org.apache.hadoop.hive.ql.hooks.ReadEntity;
@@ -997,12 +997,12 @@ public final class QueryResultsCache {
       String tableName;
 
       switch (event.getEventType()) {
-      case MessageFactory.ADD_PARTITION_EVENT:
-      case MessageFactory.ALTER_PARTITION_EVENT:
-      case MessageFactory.DROP_PARTITION_EVENT:
-      case MessageFactory.ALTER_TABLE_EVENT:
-      case MessageFactory.DROP_TABLE_EVENT:
-      case MessageFactory.INSERT_EVENT:
+      case MessageBuilder.ADD_PARTITION_EVENT:
+      case MessageBuilder.ALTER_PARTITION_EVENT:
+      case MessageBuilder.DROP_PARTITION_EVENT:
+      case MessageBuilder.ALTER_TABLE_EVENT:
+      case MessageBuilder.DROP_TABLE_EVENT:
+      case MessageBuilder.INSERT_EVENT:
         dbName = event.getDbName();
         tableName = event.getTableName();
         break;

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
index 4872080..c75bde5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
@@ -31,11 +31,9 @@ import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
 import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
 import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
 import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.AndFilter;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.DatabaseAndTableFilter;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.EventBoundaryFilter;
-import org.apache.hadoop.hive.metastore.messaging.event.filters.MessageFormatFilter;
 import org.apache.hadoop.hive.ql.DriverContext;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.exec.Task;
@@ -156,8 +154,7 @@ public class ReplDumpTask extends Task<ReplDumpWork> implements Serializable {
 
     IMetaStoreClient.NotificationFilter evFilter = new AndFilter(
         new DatabaseAndTableFilter(work.dbNameOrPattern, work.tableNameOrPattern),
-        new EventBoundaryFilter(work.eventFrom, work.eventTo),
-        new MessageFormatFilter(MessageFactory.getInstance().getMessageFormat()));
+        new EventBoundaryFilter(work.eventFrom, work.eventTo));
 
     EventUtils.MSClientNotificationFetcher evFetcher
         = new EventUtils.MSClientNotificationFetcher(hiveDb);

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/LoadConstraint.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/LoadConstraint.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/LoadConstraint.java
index d09b98c..8747727 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/LoadConstraint.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/LoadConstraint.java
@@ -30,7 +30,7 @@ import org.apache.hadoop.hive.metastore.messaging.AddNotNullConstraintMessage;
 import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage;
 import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage;
 import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.exec.Task;
 import org.apache.hadoop.hive.ql.exec.repl.bootstrap.events.ConstraintEvent;
@@ -63,7 +63,7 @@ public class LoadConstraint {
   private final ConstraintEvent event;
   private final String dbNameToLoadIn;
   private final TaskTracker tracker;
-  private final MessageDeserializer deserializer = MessageFactory.getInstance().getDeserializer();
+  private final MessageDeserializer deserializer = JSONMessageEncoder.getInstance().getDeserializer();
 
   public LoadConstraint(Context context, ConstraintEvent event, String dbNameToLoadIn,
       TaskTracker existingTracker) {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbortTxnHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbortTxnHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbortTxnHandler.java
index b9a5d21..5db3f26 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbortTxnHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbortTxnHandler.java
@@ -18,20 +18,26 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class AbortTxnHandler extends AbstractEventHandler {
+class AbortTxnHandler extends AbstractEventHandler<AbortTxnMessage> {
 
   AbortTxnHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  AbortTxnMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAbortTxnMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} ABORT_TXN message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} ABORT_TXN message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractConstraintEventHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractConstraintEventHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractConstraintEventHandler.java
index 3ed005c..672f402 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractConstraintEventHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractConstraintEventHandler.java
@@ -18,9 +18,10 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.EventMessage;
 import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
 
-abstract class AbstractConstraintEventHandler extends AbstractEventHandler {
+abstract class AbstractConstraintEventHandler<T extends EventMessage> extends AbstractEventHandler<T> {
   AbstractConstraintEventHandler(NotificationEvent event) {
     super(event);
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractEventHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractEventHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractEventHandler.java
index a70c673..b996703 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractEventHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AbstractEventHandler.java
@@ -18,20 +18,48 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.EventMessage;
 import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
+import org.apache.hadoop.hive.metastore.messaging.MessageEncoder;
 import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-abstract class AbstractEventHandler implements EventHandler {
+abstract class AbstractEventHandler<T extends EventMessage> implements EventHandler {
   static final Logger LOG = LoggerFactory.getLogger(AbstractEventHandler.class);
+  static final MessageEncoder jsonMessageEncoder = JSONMessageEncoder.getInstance();
 
   final NotificationEvent event;
   final MessageDeserializer deserializer;
+  final String eventMessageAsJSON;
+  final T eventMessage;
 
   AbstractEventHandler(NotificationEvent event) {
     this.event = event;
-    deserializer = MessageFactory.getInstance().getDeserializer();
+    try {
+      deserializer = MessageFactory.getInstance(event.getMessageFormat()).getDeserializer();
+    } catch (Exception e) {
+      String message =
+          "could not create appropriate messageFactory for format " + event.getMessageFormat();
+      LOG.error(message, e);
+      throw new IllegalStateException(message, e);
+    }
+    eventMessage = eventMessage(event.getMessage());
+    eventMessageAsJSON = eventMessageAsJSON(eventMessage);
+  }
+
+  /**
+   * This takes in the string representation of the message in the format as specified in rdbms backing metastore.
+   */
+  abstract T eventMessage(String stringRepresentation);
+
+  private String eventMessageAsJSON(T eventMessage) {
+    if (eventMessage == null) {
+      // this will only happen in case DefaultHandler is invoked
+      return null;
+    }
+    return jsonMessageEncoder.getSerializer().serialize(eventMessage);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddForeignKeyHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddForeignKeyHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddForeignKeyHandler.java
index 8fdf2f1..736a162 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddForeignKeyHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddForeignKeyHandler.java
@@ -18,21 +18,27 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AddForeignKeyMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-public class AddForeignKeyHandler extends AbstractConstraintEventHandler {
+public class AddForeignKeyHandler extends AbstractConstraintEventHandler<AddForeignKeyMessage> {
   AddForeignKeyHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  AddForeignKeyMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAddForeignKeyMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
     LOG.debug("Processing#{} ADD_FOREIGNKEY_MESSAGE message : {}", fromEventId(),
-        event.getMessage());
+        eventMessageAsJSON);
     if (shouldReplicate(withinContext)) {
       DumpMetaData dmd = withinContext.createDmd(this);
-      dmd.setPayload(event.getMessage());
+      dmd.setPayload(eventMessageAsJSON);
       dmd.write();
     }
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddNotNullConstraintHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddNotNullConstraintHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddNotNullConstraintHandler.java
index 335d4e6..c778198 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddNotNullConstraintHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddNotNullConstraintHandler.java
@@ -18,22 +18,28 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AddNotNullConstraintMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-public class AddNotNullConstraintHandler extends AbstractConstraintEventHandler {
+public class AddNotNullConstraintHandler extends AbstractConstraintEventHandler<AddNotNullConstraintMessage> {
   AddNotNullConstraintHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  AddNotNullConstraintMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAddNotNullConstraintMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
     LOG.debug("Processing#{} ADD_NOTNULLCONSTRAINT_MESSAGE message : {}", fromEventId(),
-        event.getMessage());
+        eventMessageAsJSON);
 
     if (shouldReplicate(withinContext)) {
       DumpMetaData dmd = withinContext.createDmd(this);
-      dmd.setPayload(event.getMessage());
+      dmd.setPayload(eventMessageAsJSON);
       dmd.write();
     }
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPartitionHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPartitionHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPartitionHandler.java
index 973a65b..5c16887 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPartitionHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPartitionHandler.java
@@ -21,6 +21,7 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
 import org.apache.hadoop.hive.metastore.messaging.AddPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.EventMessage;
 import org.apache.hadoop.hive.metastore.messaging.PartitionFiles;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.metadata.Partition;
@@ -42,10 +43,15 @@ class AddPartitionHandler extends AbstractEventHandler {
   }
 
   @Override
+  EventMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAddPartitionMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} ADD_PARTITION message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} ADD_PARTITION message : {}", fromEventId(), eventMessageAsJSON);
 
-    AddPartitionMessage apm = deserializer.getAddPartitionMessage(event.getMessage());
+    AddPartitionMessage apm = (AddPartitionMessage) eventMessage;
     org.apache.hadoop.hive.metastore.api.Table tobj = apm.getTableObj();
     if (tobj == null) {
       LOG.debug("Event#{} was a ADD_PTN_EVENT with no table listed");

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPrimaryKeyHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPrimaryKeyHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPrimaryKeyHandler.java
index cf45c68..f9c08c2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPrimaryKeyHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddPrimaryKeyHandler.java
@@ -18,22 +18,28 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-public class AddPrimaryKeyHandler extends AbstractConstraintEventHandler {
+public class AddPrimaryKeyHandler extends AbstractConstraintEventHandler<AddPrimaryKeyMessage> {
   AddPrimaryKeyHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  AddPrimaryKeyMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAddPrimaryKeyMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
     LOG.debug("Processing#{} ADD_PRIMARYKEY_MESSAGE message : {}", fromEventId(),
-        event.getMessage());
+        eventMessageAsJSON);
 
     if (shouldReplicate(withinContext)) {
       DumpMetaData dmd = withinContext.createDmd(this);
-      dmd.setPayload(event.getMessage());
+      dmd.setPayload(eventMessageAsJSON);
       dmd.write();
     }
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddUniqueConstraintHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddUniqueConstraintHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddUniqueConstraintHandler.java
index 58835a0..69caf08 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddUniqueConstraintHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AddUniqueConstraintHandler.java
@@ -18,22 +18,29 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-public class AddUniqueConstraintHandler extends AbstractConstraintEventHandler {
+public class AddUniqueConstraintHandler
+    extends AbstractConstraintEventHandler<AddUniqueConstraintMessage> {
   AddUniqueConstraintHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  AddUniqueConstraintMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAddUniqueConstraintMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
     LOG.debug("Processing#{} ADD_UNIQUECONSTRAINT_MESSAGE message : {}", fromEventId(),
-        event.getMessage());
+        eventMessageAsJSON);
 
     if (shouldReplicate(withinContext)) {
       DumpMetaData dmd = withinContext.createDmd(this);
-      dmd.setPayload(event.getMessage());
+      dmd.setPayload(eventMessageAsJSON);
       dmd.write();
     }
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AllocWriteIdHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AllocWriteIdHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AllocWriteIdHandler.java
index 38efbd7..7602d1f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AllocWriteIdHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AllocWriteIdHandler.java
@@ -18,19 +18,25 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AllocWriteIdMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class AllocWriteIdHandler extends AbstractEventHandler {
+class AllocWriteIdHandler extends AbstractEventHandler<AllocWriteIdMessage> {
   AllocWriteIdHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  AllocWriteIdMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAllocWriteIdMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} ALLOC_WRITE_ID message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} ALLOC_WRITE_ID message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterDatabaseHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterDatabaseHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterDatabaseHandler.java
index 3863c59..a31d1b8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterDatabaseHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterDatabaseHandler.java
@@ -18,20 +18,26 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class AlterDatabaseHandler extends AbstractEventHandler {
+class AlterDatabaseHandler extends AbstractEventHandler<AlterDatabaseMessage> {
 
   AlterDatabaseHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  AlterDatabaseMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAlterDatabaseMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} ALTER_DATABASE message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} ALTER_DATABASE message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterPartitionHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterPartitionHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterPartitionHandler.java
index cde4eed..d81408e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterPartitionHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterPartitionHandler.java
@@ -23,17 +23,15 @@ import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage;
 import org.apache.hadoop.hive.ql.metadata.Partition;
 import org.apache.hadoop.hive.ql.metadata.Table;
 import org.apache.hadoop.hive.ql.parse.EximUtil;
+import org.apache.hadoop.hive.ql.parse.repl.DumpType;
+import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
+import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.hadoop.hive.ql.parse.repl.DumpType;
-
-import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
-import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
-
-class AlterPartitionHandler extends AbstractEventHandler {
+class AlterPartitionHandler extends AbstractEventHandler<AlterPartitionMessage> {
   private final org.apache.hadoop.hive.metastore.api.Partition after;
   private final org.apache.hadoop.hive.metastore.api.Table tableObject;
   private final boolean isTruncateOp;
@@ -41,7 +39,7 @@ class AlterPartitionHandler extends AbstractEventHandler {
 
   AlterPartitionHandler(NotificationEvent event) throws Exception {
     super(event);
-    AlterPartitionMessage apm = deserializer.getAlterPartitionMessage(event.getMessage());
+    AlterPartitionMessage apm = eventMessage;
     tableObject = apm.getTableObj();
     org.apache.hadoop.hive.metastore.api.Partition before = apm.getPtnObjBefore();
     after = apm.getPtnObjAfter();
@@ -49,6 +47,11 @@ class AlterPartitionHandler extends AbstractEventHandler {
     scenario = scenarioType(before, after);
   }
 
+  @Override
+  AlterPartitionMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAlterPartitionMessage(stringRepresentation);
+  }
+
   private enum Scenario {
     ALTER {
       @Override
@@ -86,7 +89,7 @@ class AlterPartitionHandler extends AbstractEventHandler {
 
   @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} ALTER_PARTITION message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} ALTER_PARTITION message : {}", fromEventId(), eventMessageAsJSON);
 
     Table qlMdTable = new Table(tableObject);
     if (!Utils.shouldReplicate(withinContext.replicationSpec, qlMdTable, withinContext.hiveConf)) {
@@ -107,7 +110,7 @@ class AlterPartitionHandler extends AbstractEventHandler {
           withinContext.hiveConf);
     }
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterTableHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterTableHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterTableHandler.java
index 5f582b3..00fa370 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterTableHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterTableHandler.java
@@ -28,7 +28,7 @@ import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class AlterTableHandler extends AbstractEventHandler {
+class AlterTableHandler extends AbstractEventHandler<AlterTableMessage> {
   private final org.apache.hadoop.hive.metastore.api.Table before;
   private final org.apache.hadoop.hive.metastore.api.Table after;
   private final boolean isTruncateOp;
@@ -59,13 +59,17 @@ class AlterTableHandler extends AbstractEventHandler {
 
   AlterTableHandler(NotificationEvent event) throws Exception {
     super(event);
-    AlterTableMessage atm = deserializer.getAlterTableMessage(event.getMessage());
-    before = atm.getTableObjBefore();
-    after = atm.getTableObjAfter();
-    isTruncateOp = atm.getIsTruncateOp();
+    before = eventMessage.getTableObjBefore();
+    after = eventMessage.getTableObjAfter();
+    isTruncateOp = eventMessage.getIsTruncateOp();
     scenario = scenarioType(before, after);
   }
 
+  @Override
+  AlterTableMessage eventMessage(String stringRepresentation) {
+    return deserializer.getAlterTableMessage(stringRepresentation);
+  }
+
   private Scenario scenarioType(org.apache.hadoop.hive.metastore.api.Table before,
       org.apache.hadoop.hive.metastore.api.Table after) {
     if (before.getDbName().equals(after.getDbName())
@@ -78,7 +82,7 @@ class AlterTableHandler extends AbstractEventHandler {
 
   @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} ALTER_TABLE message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} ALTER_TABLE message : {}", fromEventId(), eventMessageAsJSON);
 
     Table qlMdTableBefore = new Table(before);
     if (!Utils
@@ -100,7 +104,7 @@ class AlterTableHandler extends AbstractEventHandler {
     }
  
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CommitTxnHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CommitTxnHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CommitTxnHandler.java
index 82a722f..620263f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CommitTxnHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CommitTxnHandler.java
@@ -40,12 +40,17 @@ import java.io.OutputStreamWriter;
 import java.util.ArrayList;
 import java.util.List;
 
-class CommitTxnHandler extends AbstractEventHandler {
+class CommitTxnHandler extends AbstractEventHandler<CommitTxnMessage> {
 
   CommitTxnHandler(NotificationEvent event) {
     super(event);
   }
 
+  @Override
+  CommitTxnMessage eventMessage(String stringRepresentation) {
+    return deserializer.getCommitTxnMessage(stringRepresentation);
+  }
+
   private BufferedWriter writer(Context withinContext, Path dataPath) throws IOException {
     Path filesPath = new Path(dataPath, EximUtil.FILES_NAME);
     FileSystem fs = dataPath.getFileSystem(withinContext.hiveConf);
@@ -97,23 +102,22 @@ class CommitTxnHandler extends AbstractEventHandler {
 
   @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} COMMIT_TXN message : {}", fromEventId(), event.getMessage());
-    String payload = event.getMessage();
+    LOG.info("Processing#{} COMMIT_TXN message : {}", fromEventId(), eventMessageAsJSON);
+    String payload = eventMessageAsJSON;
 
     if (!withinContext.hiveConf.getBoolVar(HiveConf.ConfVars.REPL_DUMP_METADATA_ONLY)) {
-      CommitTxnMessage commitTxnMessage = deserializer.getCommitTxnMessage(event.getMessage());
 
       String contextDbName =  withinContext.dbName == null ? null :
               StringUtils.normalizeIdentifier(withinContext.dbName);
       String contextTableName =  withinContext.tableName == null ? null :
               StringUtils.normalizeIdentifier(withinContext.tableName);
       List<WriteEventInfo> writeEventInfoList = HiveMetaStore.HMSHandler.getMSForConf(withinContext.hiveConf).
-              getAllWriteEventInfo(commitTxnMessage.getTxnId(), contextDbName, contextTableName);
+          getAllWriteEventInfo(eventMessage.getTxnId(), contextDbName, contextTableName);
       int numEntry = (writeEventInfoList != null ? writeEventInfoList.size() : 0);
       if (numEntry != 0) {
-        commitTxnMessage.addWriteEventInfo(writeEventInfoList);
-        payload = commitTxnMessage.toString();
-        LOG.debug("payload for commit txn event : " + payload);
+        eventMessage.addWriteEventInfo(writeEventInfoList);
+        payload = jsonMessageEncoder.getSerializer().serialize(eventMessage);
+        LOG.debug("payload for commit txn event : " + eventMessageAsJSON);
       }
 
       org.apache.hadoop.hive.ql.metadata.Table qlMdTablePrev = null;
@@ -128,7 +132,7 @@ class CommitTxnHandler extends AbstractEventHandler {
       // combination as primary key, so the entries with same table will come together. Only basic table metadata is
       // used during import, so we need not dump the latest table metadata.
       for (int idx = 0; idx < numEntry; idx++) {
-        qlMdTable = new org.apache.hadoop.hive.ql.metadata.Table(commitTxnMessage.getTableObj(idx));
+        qlMdTable = new org.apache.hadoop.hive.ql.metadata.Table(eventMessage.getTableObj(idx));
         if (qlMdTablePrev == null) {
           qlMdTablePrev = qlMdTable;
         }
@@ -141,13 +145,13 @@ class CommitTxnHandler extends AbstractEventHandler {
           qlMdTablePrev = qlMdTable;
         }
 
-        if (qlMdTable.isPartitioned() && (null != commitTxnMessage.getPartitionObj(idx))) {
+        if (qlMdTable.isPartitioned() && (null != eventMessage.getPartitionObj(idx))) {
           qlPtns.add(new org.apache.hadoop.hive.ql.metadata.Partition(qlMdTable,
-                  commitTxnMessage.getPartitionObj(idx)));
+              eventMessage.getPartitionObj(idx)));
         }
 
         filesTobeAdded.add(Lists.newArrayList(
-                ReplChangeManager.getListFromSeparatedString(commitTxnMessage.getFiles(idx))));
+            ReplChangeManager.getListFromSeparatedString(eventMessage.getFiles(idx))));
       }
 
       //Dump last table in the list

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateDatabaseHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateDatabaseHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateDatabaseHandler.java
index 21eb74b..7d64e49 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateDatabaseHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateDatabaseHandler.java
@@ -24,19 +24,22 @@ import org.apache.hadoop.hive.metastore.messaging.CreateDatabaseMessage;
 import org.apache.hadoop.hive.ql.parse.EximUtil;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 
-class CreateDatabaseHandler extends AbstractEventHandler {
+class CreateDatabaseHandler extends AbstractEventHandler<CreateDatabaseMessage> {
   CreateDatabaseHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  CreateDatabaseMessage eventMessage(String stringRepresentation) {
+    return deserializer.getCreateDatabaseMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} CREATE_DATABASE message : {}", fromEventId(), event.getMessage());
-    CreateDatabaseMessage createDatabaseMsg =
-        deserializer.getCreateDatabaseMessage(event.getMessage());
+    LOG.info("Processing#{} CREATE_DATABASE message : {}", fromEventId(), eventMessageAsJSON);
     Path metaDataPath = new Path(withinContext.eventRoot, EximUtil.METADATA_NAME);
     FileSystem fileSystem = metaDataPath.getFileSystem(withinContext.hiveConf);
-    EximUtil.createDbExportDump(fileSystem, metaDataPath, createDatabaseMsg.getDatabaseObject(),
+    EximUtil.createDbExportDump(fileSystem, metaDataPath, eventMessage.getDatabaseObject(),
         withinContext.replicationSpec);
     withinContext.createDmd(this).write();
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateFunctionHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateFunctionHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateFunctionHandler.java
index 5f0338e..5954e15 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateFunctionHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateFunctionHandler.java
@@ -27,21 +27,24 @@ import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.dump.io.FunctionSerializer;
 import org.apache.hadoop.hive.ql.parse.repl.dump.io.JsonWriter;
 
-class CreateFunctionHandler extends AbstractEventHandler {
+class CreateFunctionHandler extends AbstractEventHandler<CreateFunctionMessage> {
   CreateFunctionHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  CreateFunctionMessage eventMessage(String stringRepresentation) {
+    return deserializer.getCreateFunctionMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    CreateFunctionMessage createFunctionMessage =
-        deserializer.getCreateFunctionMessage(event.getMessage());
-    LOG.info("Processing#{} CREATE_MESSAGE message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} CREATE_MESSAGE message : {}", fromEventId(), eventMessageAsJSON);
     Path metadataPath = new Path(withinContext.eventRoot, EximUtil.METADATA_NAME);
     FileSystem fileSystem = metadataPath.getFileSystem(withinContext.hiveConf);
 
     try (JsonWriter jsonWriter = new JsonWriter(fileSystem, metadataPath)) {
-      new FunctionSerializer(createFunctionMessage.getFunctionObj(), withinContext.hiveConf)
+      new FunctionSerializer(eventMessage.getFunctionObj(), withinContext.hiveConf)
           .writeTo(jsonWriter, withinContext.replicationSpec);
     }
     withinContext.createDmd(this).write();

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateTableHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateTableHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateTableHandler.java
index 897ea7f..550a82d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateTableHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/CreateTableHandler.java
@@ -25,23 +25,26 @@ import org.apache.hadoop.hive.ql.metadata.Table;
 import org.apache.hadoop.hive.ql.parse.EximUtil;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
-import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
 import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 
-class CreateTableHandler extends AbstractEventHandler {
+class CreateTableHandler extends AbstractEventHandler<CreateTableMessage> {
 
   CreateTableHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  CreateTableMessage eventMessage(String stringRepresentation) {
+    return deserializer.getCreateTableMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    CreateTableMessage ctm = deserializer.getCreateTableMessage(event.getMessage());
-    LOG.info("Processing#{} CREATE_TABLE message : {}", fromEventId(), event.getMessage());
-    org.apache.hadoop.hive.metastore.api.Table tobj = ctm.getTableObj();
+    LOG.info("Processing#{} CREATE_TABLE message : {}", fromEventId(), eventMessageAsJSON);
+    org.apache.hadoop.hive.metastore.api.Table tobj = eventMessage.getTableObj();
 
     if (tobj == null) {
       LOG.debug("Event#{} was a CREATE_TABLE_EVENT with no table listed");
@@ -68,7 +71,7 @@ class CreateTableHandler extends AbstractEventHandler {
         withinContext.hiveConf);
 
     Path dataPath = new Path(withinContext.eventRoot, "data");
-    Iterable<String> files = ctm.getFiles();
+    Iterable<String> files = eventMessage.getFiles();
     if (files != null) {
       // encoded filename/checksum of files, write into _files
       try (BufferedWriter fileListWriter = writer(withinContext, dataPath)) {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DefaultHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DefaultHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DefaultHandler.java
index 8977f62..864cb98 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DefaultHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DefaultHandler.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
 
+import org.apache.hadoop.hive.metastore.messaging.EventMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
@@ -30,7 +31,15 @@ class DefaultHandler extends AbstractEventHandler {
   }
 
   @Override
+  EventMessage eventMessage(String stringRepresentation) {
+    return null;
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
+    // we specifically use the the message string from the original event since we dont know what type of message
+    // to convert this message to, this handler should not be called since with different message formats we need
+    // the ability to convert messages to a given message type.
     LOG.info("Dummy processing#{} message : {}", fromEventId(), event.getMessage());
     DumpMetaData dmd = withinContext.createDmd(this);
     dmd.setPayload(event.getMessage());

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropConstraintHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropConstraintHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropConstraintHandler.java
index 979e9a1..4c239e2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropConstraintHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropConstraintHandler.java
@@ -18,19 +18,26 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class DropConstraintHandler extends AbstractEventHandler {
+class DropConstraintHandler extends AbstractEventHandler<DropConstraintMessage> {
   DropConstraintHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  DropConstraintMessage eventMessage(String stringRepresentation) {
+    return deserializer.getDropConstraintMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} DROP_CONSTRAINT_MESSAGE message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} DROP_CONSTRAINT_MESSAGE message : {}", fromEventId(),
+        eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropDatabaseHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropDatabaseHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropDatabaseHandler.java
index 4eae778..f09f77d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropDatabaseHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropDatabaseHandler.java
@@ -18,19 +18,25 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.DropDatabaseMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class DropDatabaseHandler extends AbstractEventHandler {
+class DropDatabaseHandler extends AbstractEventHandler<DropDatabaseMessage> {
   DropDatabaseHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  DropDatabaseMessage eventMessage(String stringRepresentation) {
+    return deserializer.getDropDatabaseMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} DROP_DATABASE message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} DROP_DATABASE message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropFunctionHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropFunctionHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropFunctionHandler.java
index 352b0cc..6140c0c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropFunctionHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropFunctionHandler.java
@@ -18,20 +18,26 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.DropFunctionMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class DropFunctionHandler extends AbstractEventHandler {
+class DropFunctionHandler extends AbstractEventHandler<DropFunctionMessage> {
 
   DropFunctionHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  DropFunctionMessage eventMessage(String stringRepresentation) {
+    return deserializer.getDropFunctionMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} DROP_TABLE message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} DROP_TABLE message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropPartitionHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropPartitionHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropPartitionHandler.java
index 19b7044..e2a40d2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropPartitionHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropPartitionHandler.java
@@ -19,21 +19,27 @@ package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
 
+import org.apache.hadoop.hive.metastore.messaging.DropPartitionMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class DropPartitionHandler extends AbstractEventHandler {
+class DropPartitionHandler extends AbstractEventHandler<DropPartitionMessage> {
 
   DropPartitionHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  DropPartitionMessage eventMessage(String stringRepresentation) {
+    return deserializer.getDropPartitionMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} DROP_PARTITION message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} DROP_PARTITION message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropTableHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropTableHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropTableHandler.java
index cce0192..7d17de2 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropTableHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/DropTableHandler.java
@@ -19,21 +19,27 @@ package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
 
+import org.apache.hadoop.hive.metastore.messaging.DropTableMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class DropTableHandler extends AbstractEventHandler {
+class DropTableHandler extends AbstractEventHandler<DropTableMessage> {
 
   DropTableHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  DropTableMessage eventMessage(String stringRepresentation) {
+    return deserializer.getDropTableMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} DROP_TABLE message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} DROP_TABLE message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/EventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/EventHandlerFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/EventHandlerFactory.java
index a1d61f9..2a0379e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/EventHandlerFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/EventHandlerFactory.java
@@ -18,7 +18,7 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -33,27 +33,27 @@ public class EventHandlerFactory {
   private static Map<String, Class<? extends EventHandler>> registeredHandlers = new HashMap<>();
 
   static {
-    register(MessageFactory.ADD_PARTITION_EVENT, AddPartitionHandler.class);
-    register(MessageFactory.ALTER_DATABASE_EVENT, AlterDatabaseHandler.class);
-    register(MessageFactory.ALTER_PARTITION_EVENT, AlterPartitionHandler.class);
-    register(MessageFactory.ALTER_TABLE_EVENT, AlterTableHandler.class);
-    register(MessageFactory.CREATE_FUNCTION_EVENT, CreateFunctionHandler.class);
-    register(MessageFactory.CREATE_TABLE_EVENT, CreateTableHandler.class);
-    register(MessageFactory.DROP_PARTITION_EVENT, DropPartitionHandler.class);
-    register(MessageFactory.DROP_TABLE_EVENT, DropTableHandler.class);
-    register(MessageFactory.INSERT_EVENT, InsertHandler.class);
-    register(MessageFactory.DROP_FUNCTION_EVENT, DropFunctionHandler.class);
-    register(MessageFactory.ADD_PRIMARYKEY_EVENT, AddPrimaryKeyHandler.class);
-    register(MessageFactory.ADD_FOREIGNKEY_EVENT, AddForeignKeyHandler.class);
-    register(MessageFactory.ADD_UNIQUECONSTRAINT_EVENT, AddUniqueConstraintHandler.class);
-    register(MessageFactory.ADD_NOTNULLCONSTRAINT_EVENT, AddNotNullConstraintHandler.class);
-    register(MessageFactory.DROP_CONSTRAINT_EVENT, DropConstraintHandler.class);
-    register(MessageFactory.CREATE_DATABASE_EVENT, CreateDatabaseHandler.class);
-    register(MessageFactory.DROP_DATABASE_EVENT, DropDatabaseHandler.class);
-    register(MessageFactory.OPEN_TXN_EVENT, OpenTxnHandler.class);
-    register(MessageFactory.COMMIT_TXN_EVENT, CommitTxnHandler.class);
-    register(MessageFactory.ABORT_TXN_EVENT, AbortTxnHandler.class);
-    register(MessageFactory.ALLOC_WRITE_ID_EVENT, AllocWriteIdHandler.class);
+    register(MessageBuilder.ADD_PARTITION_EVENT, AddPartitionHandler.class);
+    register(MessageBuilder.ALTER_DATABASE_EVENT, AlterDatabaseHandler.class);
+    register(MessageBuilder.ALTER_PARTITION_EVENT, AlterPartitionHandler.class);
+    register(MessageBuilder.ALTER_TABLE_EVENT, AlterTableHandler.class);
+    register(MessageBuilder.CREATE_FUNCTION_EVENT, CreateFunctionHandler.class);
+    register(MessageBuilder.CREATE_TABLE_EVENT, CreateTableHandler.class);
+    register(MessageBuilder.DROP_PARTITION_EVENT, DropPartitionHandler.class);
+    register(MessageBuilder.DROP_TABLE_EVENT, DropTableHandler.class);
+    register(MessageBuilder.INSERT_EVENT, InsertHandler.class);
+    register(MessageBuilder.DROP_FUNCTION_EVENT, DropFunctionHandler.class);
+    register(MessageBuilder.ADD_PRIMARYKEY_EVENT, AddPrimaryKeyHandler.class);
+    register(MessageBuilder.ADD_FOREIGNKEY_EVENT, AddForeignKeyHandler.class);
+    register(MessageBuilder.ADD_UNIQUECONSTRAINT_EVENT, AddUniqueConstraintHandler.class);
+    register(MessageBuilder.ADD_NOTNULLCONSTRAINT_EVENT, AddNotNullConstraintHandler.class);
+    register(MessageBuilder.DROP_CONSTRAINT_EVENT, DropConstraintHandler.class);
+    register(MessageBuilder.CREATE_DATABASE_EVENT, CreateDatabaseHandler.class);
+    register(MessageBuilder.DROP_DATABASE_EVENT, DropDatabaseHandler.class);
+    register(MessageBuilder.OPEN_TXN_EVENT, OpenTxnHandler.class);
+    register(MessageBuilder.COMMIT_TXN_EVENT, CommitTxnHandler.class);
+    register(MessageBuilder.ABORT_TXN_EVENT, AbortTxnHandler.class);
+    register(MessageBuilder.ALLOC_WRITE_ID_EVENT, AllocWriteIdHandler.class);
   }
 
   static void register(String event, Class<? extends EventHandler> handlerClazz) {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/InsertHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/InsertHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/InsertHandler.java
index cf3822a..842e20a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/InsertHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/InsertHandler.java
@@ -36,19 +36,23 @@ import java.util.Collections;
 import java.util.List;
 
 
-class InsertHandler extends AbstractEventHandler {
+class InsertHandler extends AbstractEventHandler<InsertMessage> {
 
   InsertHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  InsertMessage eventMessage(String stringRepresentation) {
+    return deserializer.getInsertMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
     if (withinContext.hiveConf.getBoolVar(HiveConf.ConfVars.REPL_DUMP_METADATA_ONLY)) {
       return;
     }
-    InsertMessage insertMsg = deserializer.getInsertMessage(event.getMessage());
-    org.apache.hadoop.hive.ql.metadata.Table qlMdTable = tableObject(insertMsg);
+    org.apache.hadoop.hive.ql.metadata.Table qlMdTable = tableObject(eventMessage);
 
     if (!Utils.shouldReplicate(withinContext.replicationSpec, qlMdTable, withinContext.hiveConf)) {
       return;
@@ -58,18 +62,18 @@ class InsertHandler extends AbstractEventHandler {
     assert(!AcidUtils.isTransactionalTable(qlMdTable));
 
     List<Partition> qlPtns = null;
-    if (qlMdTable.isPartitioned() && (null != insertMsg.getPtnObj())) {
-      qlPtns = Collections.singletonList(partitionObject(qlMdTable, insertMsg));
+    if (qlMdTable.isPartitioned() && (null != eventMessage.getPtnObj())) {
+      qlPtns = Collections.singletonList(partitionObject(qlMdTable, eventMessage));
     }
     Path metaDataPath = new Path(withinContext.eventRoot, EximUtil.METADATA_NAME);
 
     // Mark the replace type based on INSERT-INTO or INSERT_OVERWRITE operation
-    withinContext.replicationSpec.setIsReplace(insertMsg.isReplace());
+    withinContext.replicationSpec.setIsReplace(eventMessage.isReplace());
     EximUtil.createExportDump(metaDataPath.getFileSystem(withinContext.hiveConf), metaDataPath,
         qlMdTable, qlPtns,
         withinContext.replicationSpec,
         withinContext.hiveConf);
-    Iterable<String> files = insertMsg.getFiles();
+    Iterable<String> files = eventMessage.getFiles();
 
     if (files != null) {
       Path dataPath;
@@ -93,9 +97,9 @@ class InsertHandler extends AbstractEventHandler {
       }
     }
 
-    LOG.info("Processing#{} INSERT message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} INSERT message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/OpenTxnHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/OpenTxnHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/OpenTxnHandler.java
index fe81fe1..215e726 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/OpenTxnHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/OpenTxnHandler.java
@@ -18,20 +18,26 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.OpenTxnMessage;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
 
-class OpenTxnHandler extends AbstractEventHandler {
+class OpenTxnHandler extends AbstractEventHandler<OpenTxnMessage> {
 
   OpenTxnHandler(NotificationEvent event) {
     super(event);
   }
 
   @Override
+  OpenTxnMessage eventMessage(String stringRepresentation) {
+    return deserializer.getOpenTxnMessage(stringRepresentation);
+  }
+
+  @Override
   public void handle(Context withinContext) throws Exception {
-    LOG.info("Processing#{} OPEN_TXN message : {}", fromEventId(), event.getMessage());
+    LOG.info("Processing#{} OPEN_TXN message : {}", fromEventId(), eventMessageAsJSON);
     DumpMetaData dmd = withinContext.createDmd(this);
-    dmd.setPayload(event.getMessage());
+    dmd.setPayload(eventMessageAsJSON);
     dmd.write();
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/io/ConstraintsSerializer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/io/ConstraintsSerializer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/io/ConstraintsSerializer.java
index 2848212..ae3db9c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/io/ConstraintsSerializer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/io/ConstraintsSerializer.java
@@ -26,7 +26,7 @@ import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
 import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
 import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
 import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 
@@ -52,16 +52,16 @@ public class ConstraintsSerializer implements JsonWriter.Serializer {
     String pksString, fksString, uksString, nnsString;
     pksString = fksString = uksString = nnsString = "";
     if (pks != null) {
-      pksString = MessageFactory.getInstance().buildAddPrimaryKeyMessage(pks).toString();
+      pksString = MessageBuilder.getInstance().buildAddPrimaryKeyMessage(pks).toString();
     }
     if (fks != null) {
-      fksString = MessageFactory.getInstance().buildAddForeignKeyMessage(fks).toString();
+      fksString = MessageBuilder.getInstance().buildAddForeignKeyMessage(fks).toString();
     }
     if (uks != null) {
-      uksString = MessageFactory.getInstance().buildAddUniqueConstraintMessage(uks).toString();
+      uksString = MessageBuilder.getInstance().buildAddUniqueConstraintMessage(uks).toString();
     }
     if (nns != null) {
-      nnsString = MessageFactory.getInstance().buildAddNotNullConstraintMessage(nns).toString();
+      nnsString = MessageBuilder.getInstance().buildAddNotNullConstraintMessage(nns).toString();
     }
     writer.jsonGenerator.writeStringField("pks", pksString);
     writer.jsonGenerator.writeStringField("uks", uksString);

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/AbstractMessageHandler.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/AbstractMessageHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/AbstractMessageHandler.java
index 5b26681..32ac6ee 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/AbstractMessageHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/AbstractMessageHandler.java
@@ -18,7 +18,7 @@
 package org.apache.hadoop.hive.ql.parse.repl.load.message;
 
 import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
 import org.apache.hadoop.hive.ql.hooks.ReadEntity;
 import org.apache.hadoop.hive.ql.hooks.WriteEntity;
 import org.apache.hadoop.hive.ql.parse.repl.load.UpdatedMetaDataTracker;
@@ -30,7 +30,7 @@ abstract class AbstractMessageHandler implements MessageHandler {
   final HashSet<ReadEntity> readEntitySet = new HashSet<>();
   final HashSet<WriteEntity> writeEntitySet = new HashSet<>();
   final UpdatedMetaDataTracker updatedMetadata = new UpdatedMetaDataTracker();
-  final MessageDeserializer deserializer = MessageFactory.getInstance().getDeserializer();
+  final MessageDeserializer deserializer = JSONMessageEncoder.getInstance().getDeserializer();
 
   @Override
   public Set<ReadEntity> readEntities() {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/events/TestEventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/events/TestEventHandlerFactory.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/events/TestEventHandlerFactory.java
index 7057890..6a3c563 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/events/TestEventHandlerFactory.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/repl/dump/events/TestEventHandlerFactory.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.ql.parse.repl.dump.events;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
 import org.apache.hadoop.hive.ql.parse.repl.DumpType;
 import org.junit.Test;
 
@@ -53,9 +54,11 @@ public class TestEventHandlerFactory {
 
   @Test
   public void shouldProvideDefaultHandlerWhenNothingRegisteredForThatEvent() {
+    NotificationEvent event = new NotificationEvent(Long.MAX_VALUE, Integer.MAX_VALUE,
+        "shouldGiveDefaultHandler", "s");
+    event.setMessageFormat(JSONMessageEncoder.FORMAT);
     EventHandler eventHandler =
-        EventHandlerFactory.handlerFor(new NotificationEvent(Long.MAX_VALUE, Integer.MAX_VALUE,
-            "shouldGiveDefaultHandler", "s"));
+        EventHandlerFactory.handlerFor(event);
     assertTrue(eventHandler instanceof DefaultHandler);
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
index 1795ef7..1d64cce 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
@@ -514,7 +514,7 @@ public class MetastoreConf {
             "Alternatively, configure hive.metastore.transactional.event.listeners to ensure both are invoked in same JDO transaction."),
     EVENT_MESSAGE_FACTORY("metastore.event.message.factory",
         "hive.metastore.event.message.factory",
-        "org.apache.hadoop.hive.metastore.messaging.json.JSONMessageFactory",
+        "org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder",
         "Factory class for making encoding and decoding messages in the events generated."),
     EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS("metastore.notification.parameters.exclude.patterns",
         "hive.metastore.notification.parameters.exclude.patterns", "",

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
index f24b419..1262c12 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java
@@ -30,38 +30,38 @@ public abstract class EventMessage {
    */
   public enum EventType {
 
-    CREATE_DATABASE(MessageFactory.CREATE_DATABASE_EVENT),
-    DROP_DATABASE(MessageFactory.DROP_DATABASE_EVENT),
-    CREATE_TABLE(MessageFactory.CREATE_TABLE_EVENT),
-    DROP_TABLE(MessageFactory.DROP_TABLE_EVENT),
-    ADD_PARTITION(MessageFactory.ADD_PARTITION_EVENT),
-    DROP_PARTITION(MessageFactory.DROP_PARTITION_EVENT),
-    ALTER_DATABASE(MessageFactory.ALTER_DATABASE_EVENT),
-    ALTER_TABLE(MessageFactory.ALTER_TABLE_EVENT),
-    ALTER_PARTITION(MessageFactory.ALTER_PARTITION_EVENT),
-    INSERT(MessageFactory.INSERT_EVENT),
-    CREATE_FUNCTION(MessageFactory.CREATE_FUNCTION_EVENT),
-    DROP_FUNCTION(MessageFactory.DROP_FUNCTION_EVENT),
-
-    ADD_PRIMARYKEY(MessageFactory.ADD_PRIMARYKEY_EVENT),
-    ADD_FOREIGNKEY(MessageFactory.ADD_FOREIGNKEY_EVENT),
-    ADD_UNIQUECONSTRAINT(MessageFactory.ADD_UNIQUECONSTRAINT_EVENT),
-    ADD_NOTNULLCONSTRAINT(MessageFactory.ADD_NOTNULLCONSTRAINT_EVENT),
-    DROP_CONSTRAINT(MessageFactory.DROP_CONSTRAINT_EVENT),
-    CREATE_ISCHEMA(MessageFactory.CREATE_ISCHEMA_EVENT),
-    ALTER_ISCHEMA(MessageFactory.ALTER_ISCHEMA_EVENT),
-    DROP_ISCHEMA(MessageFactory.DROP_ISCHEMA_EVENT),
-    ADD_SCHEMA_VERSION(MessageFactory.ADD_SCHEMA_VERSION_EVENT),
-    ALTER_SCHEMA_VERSION(MessageFactory.ALTER_SCHEMA_VERSION_EVENT),
-    DROP_SCHEMA_VERSION(MessageFactory.DROP_SCHEMA_VERSION_EVENT),
-    CREATE_CATALOG(MessageFactory.CREATE_CATALOG_EVENT),
-    DROP_CATALOG(MessageFactory.DROP_CATALOG_EVENT),
-    OPEN_TXN(MessageFactory.OPEN_TXN_EVENT),
-    COMMIT_TXN(MessageFactory.COMMIT_TXN_EVENT),
-    ABORT_TXN(MessageFactory.ABORT_TXN_EVENT),
-    ALLOC_WRITE_ID(MessageFactory.ALLOC_WRITE_ID_EVENT),
-    ALTER_CATALOG(MessageFactory.ALTER_CATALOG_EVENT),
-    ACID_WRITE(MessageFactory.ACID_WRITE_EVENT);
+    CREATE_DATABASE(MessageBuilder.CREATE_DATABASE_EVENT),
+    DROP_DATABASE(MessageBuilder.DROP_DATABASE_EVENT),
+    CREATE_TABLE(MessageBuilder.CREATE_TABLE_EVENT),
+    DROP_TABLE(MessageBuilder.DROP_TABLE_EVENT),
+    ADD_PARTITION(MessageBuilder.ADD_PARTITION_EVENT),
+    DROP_PARTITION(MessageBuilder.DROP_PARTITION_EVENT),
+    ALTER_DATABASE(MessageBuilder.ALTER_DATABASE_EVENT),
+    ALTER_TABLE(MessageBuilder.ALTER_TABLE_EVENT),
+    ALTER_PARTITION(MessageBuilder.ALTER_PARTITION_EVENT),
+    INSERT(MessageBuilder.INSERT_EVENT),
+    CREATE_FUNCTION(MessageBuilder.CREATE_FUNCTION_EVENT),
+    DROP_FUNCTION(MessageBuilder.DROP_FUNCTION_EVENT),
+
+    ADD_PRIMARYKEY(MessageBuilder.ADD_PRIMARYKEY_EVENT),
+    ADD_FOREIGNKEY(MessageBuilder.ADD_FOREIGNKEY_EVENT),
+    ADD_UNIQUECONSTRAINT(MessageBuilder.ADD_UNIQUECONSTRAINT_EVENT),
+    ADD_NOTNULLCONSTRAINT(MessageBuilder.ADD_NOTNULLCONSTRAINT_EVENT),
+    DROP_CONSTRAINT(MessageBuilder.DROP_CONSTRAINT_EVENT),
+    CREATE_ISCHEMA(MessageBuilder.CREATE_ISCHEMA_EVENT),
+    ALTER_ISCHEMA(MessageBuilder.ALTER_ISCHEMA_EVENT),
+    DROP_ISCHEMA(MessageBuilder.DROP_ISCHEMA_EVENT),
+    ADD_SCHEMA_VERSION(MessageBuilder.ADD_SCHEMA_VERSION_EVENT),
+    ALTER_SCHEMA_VERSION(MessageBuilder.ALTER_SCHEMA_VERSION_EVENT),
+    DROP_SCHEMA_VERSION(MessageBuilder.DROP_SCHEMA_VERSION_EVENT),
+    CREATE_CATALOG(MessageBuilder.CREATE_CATALOG_EVENT),
+    DROP_CATALOG(MessageBuilder.DROP_CATALOG_EVENT),
+    OPEN_TXN(MessageBuilder.OPEN_TXN_EVENT),
+    COMMIT_TXN(MessageBuilder.COMMIT_TXN_EVENT),
+    ABORT_TXN(MessageBuilder.ABORT_TXN_EVENT),
+    ALLOC_WRITE_ID(MessageBuilder.ALLOC_WRITE_ID_EVENT),
+    ALTER_CATALOG(MessageBuilder.ALTER_CATALOG_EVENT),
+    ACID_WRITE(MessageBuilder.ACID_WRITE_EVENT);
 
     private String typeString;
 


[74/75] [abbrv] hive git commit: HIVE-20605 : Merge branch 'master' into master-tez092

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/LlapTaskSchedulerService.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/ql/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/KillTriggerActionHandler.java
----------------------------------------------------------------------
diff --cc ql/src/java/org/apache/hadoop/hive/ql/exec/tez/KillTriggerActionHandler.java
index 40cafcc,ee539ba..728dae4
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/KillTriggerActionHandler.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/KillTriggerActionHandler.java
@@@ -32,20 -34,24 +34,24 @@@ public class KillTriggerActionHandler i
    private static final Logger LOG = LoggerFactory.getLogger(KillTriggerActionHandler.class);
  
    @Override
 -  public void applyAction(final Map<TezSessionState, Trigger> queriesViolated) {
 -    for (Map.Entry<TezSessionState, Trigger> entry : queriesViolated.entrySet()) {
 +  public void applyAction(final Map<TezSession, Trigger> queriesViolated) {
 +    for (Map.Entry<TezSession, Trigger> entry : queriesViolated.entrySet()) {
        switch (entry.getValue().getAction().getType()) {
          case KILL_QUERY:
 -          TezSessionState sessionState = entry.getKey();
 -          String queryId = sessionState.getWmContext().getQueryId();
 +          TezSession sessionState = entry.getKey();
            try {
-             // then session might have been released to pool or closed already
++            // if kill query is null then session might have been released to pool or closed already
++            // TODO: what's up with this hacky session-start code?
+             SessionState ss = new SessionState(new HiveConf());
+             ss.setIsHiveServerQuery(true);
+             SessionState.start(ss);
 -            KillQuery killQuery = sessionState.getKillQuery();
 -            // if kill query is null then session might have been released to pool or closed already
 -            if (killQuery != null) {
 -              sessionState.getKillQuery().killQuery(queryId, entry.getValue().getViolationMsg(),
 -                      sessionState.getConf());
 +            boolean wasKilled =  sessionState.killQuery(entry.getValue().getViolationMsg());
 +            if (!wasKilled) {
 +              LOG.info("Didn't kill the query {}", sessionState.getWmContext().getQueryId());
              }
            } catch (HiveException e) {
 -            LOG.warn("Unable to kill query {} for trigger violation");
 +            LOG.warn("Unable to kill query {} for trigger violation",
 +                sessionState.getWmContext().getQueryId());
            }
            break;
          default:

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/WorkloadManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/hive/blob/c55347d5/service/src/java/org/apache/hive/service/server/KillQueryImpl.java
----------------------------------------------------------------------
diff --cc service/src/java/org/apache/hive/service/server/KillQueryImpl.java
index 2c23253,c7f2c91..65a6158
--- a/service/src/java/org/apache/hive/service/server/KillQueryImpl.java
+++ b/service/src/java/org/apache/hive/service/server/KillQueryImpl.java
@@@ -96,42 -133,56 +133,66 @@@ public class KillQueryImpl implements K
    }
  
    @Override
-   public void killQuery(
-       String queryId, String errMsg, HiveConf conf, boolean isYarn) throws HiveException {
 -  public void killQuery(String queryIdOrTag, String errMsg, HiveConf conf) throws HiveException {
++  public void killQuery(String queryIdOrTag, String errMsg, HiveConf conf, boolean isYarn) throws HiveException {
      try {
-       String queryTag = null;
- 
-       Operation operation = operationManager.getOperationByQueryId(queryId);
-       if (operation == null) {
-         // Check if user has passed the query tag to kill the operation. This is possible if the application
-         // restarts and it does not have the proper query id. The tag can be used in that case to kill the query.
-         operation = operationManager.getOperationByQueryTag(queryId);
-         if (operation == null) {
-           LOG.info("Query not found: " + queryId);
-         }
+       TagOrId tagOrId = TagOrId.UNKNOWN;
+       Set<Operation> operationsToKill = new HashSet<Operation>();
+       if (operationManager.getOperationByQueryId(queryIdOrTag) != null) {
+         operationsToKill.add(operationManager.getOperationByQueryId(queryIdOrTag));
+         tagOrId = TagOrId.ID;
        } else {
-         // This is the normal flow, where the query is tagged and user wants to kill the query using the query id.
-         queryTag = operation.getQueryTag();
-       }
- 
-       if (queryTag == null) {
-         //use query id as tag if user wanted to kill only the yarn jobs after hive server restart. The yarn jobs are
-         //tagged with query id by default. This will cover the case where the application after restarts wants to kill
-         //the yarn jobs with query tag. The query tag can be passed as query id.
-         queryTag = queryId;
+         operationsToKill.addAll(operationManager.getOperationsByQueryTag(queryIdOrTag));
+         if (!operationsToKill.isEmpty()) {
+           tagOrId = TagOrId.TAG;
+         }
        }
- 
-       if (isYarn) {
-         LOG.info("Killing yarn jobs for query id : " + queryId + " using tag :" + queryTag);
-         killChildYarnJobs(conf, queryTag);
+       if (operationsToKill.isEmpty()) {
+         LOG.info("Query not found: " + queryIdOrTag);
        }
 +
-       if (operation != null) {
-         OperationHandle handle = operation.getHandle();
-         operationManager.cancelOperation(handle, errMsg);
+       boolean admin = isAdmin();
+       switch(tagOrId) {
+         case ID:
+           Operation operation = operationsToKill.iterator().next();
+           boolean canceled = cancelOperation(operation, admin, errMsg);
+           if (canceled) {
+             String queryTag = operation.getQueryTag();
+             if (queryTag == null) {
+               queryTag = queryIdOrTag;
+             }
 -            killChildYarnJobs(conf, queryTag);
++            if (isYarn) {
++              LOG.info("Killing yarn jobs for " + queryIdOrTag);
++              killChildYarnJobs(conf, queryTag);
++            }
+           } else {
+             // no privilege to cancel
+             throw new HiveSQLException("No privilege");
+           }
+           break;
+         case TAG:
+           int numCanceled = 0;
+           for (Operation operationToKill : operationsToKill) {
+             if (cancelOperation(operationToKill, admin, errMsg)) {
+               numCanceled++;
+             }
+           }
 -          killChildYarnJobs(conf, queryIdOrTag);
++          if (isYarn) {
++            LOG.info("Killing yarn jobs for " + queryIdOrTag);
++            killChildYarnJobs(conf, queryIdOrTag);
++          }
+           if (numCanceled == 0) {
+             throw new HiveSQLException("No privilege");
+           }
+           break;
+         case UNKNOWN:
 -          killChildYarnJobs(conf, queryIdOrTag);
++          if (isYarn) {
++            LOG.info("Killing yarn jobs for " + queryIdOrTag);
++            killChildYarnJobs(conf, queryIdOrTag);
++          }
+           break;
        }
      } catch (HiveSQLException e) {
-       LOG.error("Kill query failed for query " + queryId, e);
+       LOG.error("Kill query failed for query " + queryIdOrTag, e);
        throw new HiveException(e.getMessage(), e);
      }
    }


[23/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query2.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query2.q.out
new file mode 100644
index 0000000..baa714b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query2.q.out
@@ -0,0 +1,228 @@
+PREHOOK: query: explain
+with wscs as
+ (select sold_date_sk
+        ,sales_price
+  from (select ws_sold_date_sk sold_date_sk
+              ,ws_ext_sales_price sales_price
+        from web_sales) x
+        union all
+       (select cs_sold_date_sk sold_date_sk
+              ,cs_ext_sales_price sales_price
+        from catalog_sales)),
+ wswscs as 
+ (select d_week_seq,
+        sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
+ from wscs
+     ,date_dim
+ where d_date_sk = sold_date_sk
+ group by d_week_seq)
+ select d_week_seq1
+       ,round(sun_sales1/sun_sales2,2)
+       ,round(mon_sales1/mon_sales2,2)
+       ,round(tue_sales1/tue_sales2,2)
+       ,round(wed_sales1/wed_sales2,2)
+       ,round(thu_sales1/thu_sales2,2)
+       ,round(fri_sales1/fri_sales2,2)
+       ,round(sat_sales1/sat_sales2,2)
+ from
+ (select wswscs.d_week_seq d_week_seq1
+        ,sun_sales sun_sales1
+        ,mon_sales mon_sales1
+        ,tue_sales tue_sales1
+        ,wed_sales wed_sales1
+        ,thu_sales thu_sales1
+        ,fri_sales fri_sales1
+        ,sat_sales sat_sales1
+  from wswscs,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001) y,
+ (select wswscs.d_week_seq d_week_seq2
+        ,sun_sales sun_sales2
+        ,mon_sales mon_sales2
+        ,tue_sales tue_sales2
+        ,wed_sales wed_sales2
+        ,thu_sales thu_sales2
+        ,fri_sales fri_sales2
+        ,sat_sales sat_sales2
+  from wswscs
+      ,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001+1) z
+ where d_week_seq1=d_week_seq2-53
+ order by d_week_seq1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with wscs as
+ (select sold_date_sk
+        ,sales_price
+  from (select ws_sold_date_sk sold_date_sk
+              ,ws_ext_sales_price sales_price
+        from web_sales) x
+        union all
+       (select cs_sold_date_sk sold_date_sk
+              ,cs_ext_sales_price sales_price
+        from catalog_sales)),
+ wswscs as 
+ (select d_week_seq,
+        sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
+ from wscs
+     ,date_dim
+ where d_date_sk = sold_date_sk
+ group by d_week_seq)
+ select d_week_seq1
+       ,round(sun_sales1/sun_sales2,2)
+       ,round(mon_sales1/mon_sales2,2)
+       ,round(tue_sales1/tue_sales2,2)
+       ,round(wed_sales1/wed_sales2,2)
+       ,round(thu_sales1/thu_sales2,2)
+       ,round(fri_sales1/fri_sales2,2)
+       ,round(sat_sales1/sat_sales2,2)
+ from
+ (select wswscs.d_week_seq d_week_seq1
+        ,sun_sales sun_sales1
+        ,mon_sales mon_sales1
+        ,tue_sales tue_sales1
+        ,wed_sales wed_sales1
+        ,thu_sales thu_sales1
+        ,fri_sales fri_sales1
+        ,sat_sales sat_sales1
+  from wswscs,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001) y,
+ (select wswscs.d_week_seq d_week_seq2
+        ,sun_sales sun_sales2
+        ,mon_sales mon_sales2
+        ,tue_sales tue_sales2
+        ,wed_sales wed_sales2
+        ,thu_sales thu_sales2
+        ,fri_sales fri_sales2
+        ,sat_sales sat_sales2
+  from wswscs
+      ,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001+1) z
+ where d_week_seq1=d_week_seq2-53
+ order by d_week_seq1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Union 2 (CONTAINS)
+Map 9 <- Union 2 (CONTAINS)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Union 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 11 (SIMPLE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 5 (ONE_TO_ONE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Map 11 (SIMPLE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_173]
+        Select Operator [SEL_172] (rows=12881 width=788)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+        <-Reducer 6 [SIMPLE_EDGE]
+          SHUFFLE [RS_57]
+            Select Operator [SEL_56] (rows=12881 width=788)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+              Merge Join Operator [MERGEJOIN_146] (rows=12881 width=1572)
+                Conds:RS_53._col0=RS_54._col7(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10","_col11","_col12","_col13","_col14","_col15"]
+              <-Reducer 5 [ONE_TO_ONE_EDGE]
+                FORWARD [RS_53]
+                  PartitionCols:_col0
+                  Merge Join Operator [MERGEJOIN_143] (rows=652 width=788)
+                    Conds:RS_164._col0=RS_170._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                  <-Map 11 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_170]
+                      PartitionCols:_col0
+                      Select Operator [SEL_168] (rows=652 width=4)
+                        Output:["_col0"]
+                        Filter Operator [FIL_166] (rows=652 width=8)
+                          predicate:((d_year = 2001) and d_week_seq is not null)
+                          TableScan [TS_20] (rows=73049 width=8)
+                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_week_seq","d_year"]
+                  <-Reducer 4 [ONE_TO_ONE_EDGE] vectorized
+                    FORWARD [RS_164]
+                      PartitionCols:_col0
+                      Group By Operator [GBY_163] (rows=13152 width=788)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)"],keys:KEY._col0
+                      <-Reducer 3 [SIMPLE_EDGE]
+                        SHUFFLE [RS_17]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_16] (rows=3182784 width=788)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col1)","sum(_col2)","sum(_col3)","sum(_col4)","sum(_col5)","sum(_col6)","sum(_col7)"],keys:_col0
+                            Select Operator [SEL_14] (rows=430516591 width=143)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                              Merge Join Operator [MERGEJOIN_142] (rows=430516591 width=143)
+                                Conds:Union 2._col0=RS_162._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+                              <-Map 10 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_162]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_161] (rows=73049 width=36)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                    Filter Operator [FIL_160] (rows=73049 width=99)
+                                      predicate:d_week_seq is not null
+                                      TableScan [TS_8] (rows=73049 width=99)
+                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_week_seq","d_day_name"]
+                              <-Union 2 [SIMPLE_EDGE]
+                                <-Map 1 [CONTAINS] vectorized
+                                  Reduce Output Operator [RS_159]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_158] (rows=143966864 width=115)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_157] (rows=143966864 width=115)
+                                        predicate:ws_sold_date_sk is not null
+                                        TableScan [TS_147] (rows=144002668 width=115)
+                                          Output:["ws_sold_date_sk","ws_ext_sales_price"]
+                                <-Map 9 [CONTAINS] vectorized
+                                  Reduce Output Operator [RS_176]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_175] (rows=286549727 width=115)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_174] (rows=286549727 width=115)
+                                        predicate:cs_sold_date_sk is not null
+                                        TableScan [TS_152] (rows=287989836 width=115)
+                                          Output:["cs_sold_date_sk","cs_ext_sales_price"]
+              <-Reducer 8 [SIMPLE_EDGE]
+                SHUFFLE [RS_54]
+                  PartitionCols:_col7
+                  Select Operator [SEL_49] (rows=652 width=788)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                    Merge Join Operator [MERGEJOIN_145] (rows=652 width=788)
+                      Conds:RS_165._col0=RS_171._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                    <-Map 11 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_171]
+                        PartitionCols:_col0
+                        Select Operator [SEL_169] (rows=652 width=4)
+                          Output:["_col0"]
+                          Filter Operator [FIL_167] (rows=652 width=8)
+                            predicate:((d_year = 2002) and d_week_seq is not null)
+                             Please refer to the previous TableScan [TS_20]
+                    <-Reducer 4 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_165]
+                        PartitionCols:_col0
+                         Please refer to the previous Group By Operator [GBY_163]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query20.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query20.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query20.q.out
new file mode 100644
index 0000000..da3e262
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query20.q.out
@@ -0,0 +1,161 @@
+PREHOOK: query: explain
+select  i_item_desc 
+       ,i_category 
+       ,i_class 
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue 
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from	catalog_sales
+     ,item 
+     ,date_dim
+ where cs_item_sk = i_item_sk 
+   and i_category in ('Jewelry', 'Sports', 'Books')
+   and cs_sold_date_sk = d_date_sk
+ and d_date between cast('2001-01-12' as date) 
+ 				and (cast('2001-01-12' as date) + 30 days)
+ group by i_item_id
+         ,i_item_desc 
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_desc 
+       ,i_category 
+       ,i_class 
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue 
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from	catalog_sales
+     ,item 
+     ,date_dim
+ where cs_item_sk = i_item_sk 
+   and i_category in ('Jewelry', 'Sports', 'Books')
+   and cs_sold_date_sk = d_date_sk
+ and d_date between cast('2001-01-12' as date) 
+ 				and (cast('2001-01-12' as date) + 30 days)
+ group by i_item_id
+         ,i_item_desc 
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 3 <- Map 9 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 8 <- Map 7 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_86]
+        Limit [LIM_85] (rows=100 width=802)
+          Number of rows:100
+          Select Operator [SEL_84] (rows=138600 width=801)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_83]
+              Select Operator [SEL_82] (rows=138600 width=801)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                PTF Operator [PTF_81] (rows=138600 width=689)
+                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 ASC NULLS FIRST","partition by:":"_col1"}]
+                  Select Operator [SEL_80] (rows=138600 width=689)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                  <-Reducer 4 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_79]
+                      PartitionCols:_col1
+                      Group By Operator [GBY_78] (rows=138600 width=689)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                      <-Reducer 3 [SIMPLE_EDGE]
+                        SHUFFLE [RS_17]
+                          PartitionCols:_col0, _col1, _col2, _col3, _col4
+                          Group By Operator [GBY_16] (rows=138600 width=689)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)"],keys:_col9, _col8, _col5, _col6, _col7
+                            Merge Join Operator [MERGEJOIN_58] (rows=9551005 width=673)
+                              Conds:RS_12._col1=RS_69._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9"]
+                            <-Map 9 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_69]
+                                PartitionCols:_col0
+                                Select Operator [SEL_68] (rows=138600 width=581)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Filter Operator [FIL_67] (rows=138600 width=581)
+                                    predicate:(i_category) IN ('Jewelry', 'Sports', 'Books')
+                                    TableScan [TS_6] (rows=462000 width=581)
+                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_item_desc","i_current_price","i_class","i_category"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_12]
+                                PartitionCols:_col1
+                                Merge Join Operator [MERGEJOIN_57] (rows=31836679 width=110)
+                                  Conds:RS_77._col0=RS_61._col0(Inner),Output:["_col1","_col2"]
+                                <-Map 7 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_61]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_60] (rows=8116 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_59] (rows=8116 width=98)
+                                        predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'2001-01-12 00:00:00' AND TIMESTAMP'2001-02-11 00:00:00'
+                                        TableScan [TS_3] (rows=73049 width=98)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_77]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_76] (rows=286549727 width=119)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_75] (rows=286549727 width=119)
+                                        predicate:((cs_item_sk BETWEEN DynamicValue(RS_13_item_i_item_sk_min) AND DynamicValue(RS_13_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_13_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_10_date_dim_d_date_sk_min) AND DynamicValue(RS_10_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_10_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                        TableScan [TS_0] (rows=287989836 width=119)
+                                          default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_ext_sales_price"]
+                                        <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_74]
+                                            Group By Operator [GBY_73] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_72]
+                                                Group By Operator [GBY_71] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_70] (rows=138600 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_68]
+                                        <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_66]
+                                            Group By Operator [GBY_65] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_64]
+                                                Group By Operator [GBY_63] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_62] (rows=8116 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_60]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query21.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query21.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query21.q.out
new file mode 100644
index 0000000..67fdc85
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query21.q.out
@@ -0,0 +1,145 @@
+PREHOOK: query: explain
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
+	                then inv_quantity_on_hand 
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
+                      then inv_quantity_on_hand 
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0 
+             then inv_after / inv_before 
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
+	                then inv_quantity_on_hand 
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
+                      then inv_quantity_on_hand 
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0 
+             then inv_after / inv_before 
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 9 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_91]
+        Limit [LIM_90] (rows=100 width=216)
+          Number of rows:100
+          Select Operator [SEL_89] (rows=231983 width=216)
+            Output:["_col0","_col1","_col2","_col3"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_88]
+              Filter Operator [FIL_87] (rows=231983 width=216)
+                predicate:CASE WHEN ((_col2 > 0L)) THEN ((UDFToDouble(_col3) / UDFToDouble(_col2)) BETWEEN 0.666667D AND 1.5D) ELSE (null) END
+                Group By Operator [GBY_86] (rows=463966 width=216)
+                  Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1
+                <-Reducer 4 [SIMPLE_EDGE]
+                  SHUFFLE [RS_22]
+                    PartitionCols:_col0, _col1
+                    Group By Operator [GBY_21] (rows=463966 width=216)
+                      Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)","sum(_col3)"],keys:_col0, _col1
+                      Select Operator [SEL_19] (rows=463966 width=208)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Merge Join Operator [MERGEJOIN_75] (rows=463966 width=208)
+                          Conds:RS_16._col2=RS_85._col0(Inner),Output:["_col3","_col5","_col6","_col8","_col10"]
+                        <-Map 9 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_85]
+                            PartitionCols:_col0
+                            Select Operator [SEL_84] (rows=27 width=104)
+                              Output:["_col0","_col1"]
+                              TableScan [TS_8] (rows=27 width=104)
+                                default@warehouse,warehouse,Tbl:COMPLETE,Col:COMPLETE,Output:["w_warehouse_sk","w_warehouse_name"]
+                        <-Reducer 3 [SIMPLE_EDGE]
+                          SHUFFLE [RS_16]
+                            PartitionCols:_col2
+                            Merge Join Operator [MERGEJOIN_74] (rows=463966 width=112)
+                              Conds:RS_13._col1=RS_83._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col8"]
+                            <-Map 8 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_83]
+                                PartitionCols:_col0
+                                Select Operator [SEL_82] (rows=51333 width=104)
+                                  Output:["_col0","_col1"]
+                                  Filter Operator [FIL_81] (rows=51333 width=215)
+                                    predicate:i_current_price BETWEEN 0.99 AND 1.49
+                                    TableScan [TS_5] (rows=462000 width=215)
+                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_current_price"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_13]
+                                PartitionCols:_col1
+                                Merge Join Operator [MERGEJOIN_73] (rows=4175715 width=18)
+                                  Conds:RS_77._col0=RS_80._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_77]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_76] (rows=37584000 width=15)
+                                      Output:["_col0","_col1","_col2","_col3"]
+                                      TableScan [TS_0] (rows=37584000 width=15)
+                                        default@inventory,inventory,Tbl:COMPLETE,Col:COMPLETE,Output:["inv_date_sk","inv_item_sk","inv_warehouse_sk","inv_quantity_on_hand"]
+                                <-Map 7 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_80]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_79] (rows=8116 width=12)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_78] (rows=8116 width=98)
+                                        predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-03-09 00:00:00' AND TIMESTAMP'1998-05-08 00:00:00'
+                                        TableScan [TS_2] (rows=73049 width=98)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query22.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query22.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query22.q.out
new file mode 100644
index 0000000..cd3c0cc
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query22.q.out
@@ -0,0 +1,112 @@
+PREHOOK: query: explain
+select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,avg(inv_quantity_on_hand) qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1212 and 1212 + 11
+       group by rollup(i_product_name
+                       ,i_brand
+                       ,i_class
+                       ,i_category)
+order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,avg(inv_quantity_on_hand) qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1212 and 1212 + 11
+       group by rollup(i_product_name
+                       ,i_brand
+                       ,i_class
+                       ,i_category)
+order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 7 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_64]
+        Limit [LIM_63] (rows=100 width=397)
+          Number of rows:100
+          Select Operator [SEL_62] (rows=32730675 width=397)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_61]
+              Select Operator [SEL_60] (rows=32730675 width=397)
+                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Group By Operator [GBY_59] (rows=32730675 width=413)
+                  Output:["_col0","_col1","_col2","_col3","_col5","_col6"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                <-Reducer 3 [SIMPLE_EDGE]
+                  SHUFFLE [RS_15]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4
+                    Group By Operator [GBY_14] (rows=32730675 width=413)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col2)","count(_col2)"],keys:_col5, _col6, _col7, _col8, 0L
+                      Merge Join Operator [MERGEJOIN_51] (rows=6546135 width=391)
+                        Conds:RS_10._col1=RS_58._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8"]
+                      <-Map 7 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_58]
+                          PartitionCols:_col0
+                          Select Operator [SEL_57] (rows=462000 width=393)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            TableScan [TS_5] (rows=462000 width=393)
+                              default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand","i_class","i_category","i_product_name"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_10]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_50] (rows=6546135 width=6)
+                            Conds:RS_53._col0=RS_56._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_53]
+                              PartitionCols:_col0
+                              Select Operator [SEL_52] (rows=37584000 width=11)
+                                Output:["_col0","_col1","_col2"]
+                                TableScan [TS_0] (rows=37584000 width=11)
+                                  default@inventory,inventory,Tbl:COMPLETE,Col:COMPLETE,Output:["inv_date_sk","inv_item_sk","inv_quantity_on_hand"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_56]
+                              PartitionCols:_col0
+                              Select Operator [SEL_55] (rows=317 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_54] (rows=317 width=8)
+                                  predicate:d_month_seq BETWEEN 1212 AND 1223
+                                  TableScan [TS_2] (rows=73049 width=8)
+                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query23.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query23.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query23.q.out
new file mode 100644
index 0000000..c7b1c9a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query23.q.out
@@ -0,0 +1,540 @@
+Warning: Shuffle Join MERGEJOIN[445][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 19' is a cross product
+Warning: Shuffle Join MERGEJOIN[446][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 20' is a cross product
+Warning: Shuffle Join MERGEJOIN[448][tables = [$hdt$_2, $hdt$_3]] in Stage 'Reducer 24' is a cross product
+Warning: Shuffle Join MERGEJOIN[449][tables = [$hdt$_2, $hdt$_3, $hdt$_1]] in Stage 'Reducer 25' is a cross product
+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
+  *
+from
+ max_store_sales))
+  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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+  *
+from
+ max_store_sales))
+  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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 33 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Map 15 <- Reducer 29 (BROADCAST_EDGE)
+Map 37 <- Reducer 7 (BROADCAST_EDGE)
+Map 39 <- Reducer 36 (BROADCAST_EDGE)
+Map 41 <- Reducer 14 (BROADCAST_EDGE), Reducer 35 (BROADCAST_EDGE)
+Map 42 <- Reducer 13 (BROADCAST_EDGE)
+Reducer 10 <- Map 41 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE), Reducer 26 (ONE_TO_ONE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE), Reducer 34 (ONE_TO_ONE_EDGE), Union 5 (CONTAINS)
+Reducer 13 <- Reducer 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE), Map 28 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (CUSTOM_SIMPLE_EDGE), Reducer 22 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (CUSTOM_SIMPLE_EDGE), Reducer 38 (CUSTOM_SIMPLE_EDGE)
+Reducer 21 <- Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 23 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 24 <- Reducer 23 (CUSTOM_SIMPLE_EDGE), Reducer 27 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Reducer 24 (CUSTOM_SIMPLE_EDGE), Reducer 43 (CUSTOM_SIMPLE_EDGE)
+Reducer 26 <- Reducer 25 (SIMPLE_EDGE)
+Reducer 27 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 21 (ONE_TO_ONE_EDGE)
+Reducer 30 <- Map 28 (SIMPLE_EDGE), Map 39 (SIMPLE_EDGE)
+Reducer 31 <- Map 40 (SIMPLE_EDGE), Reducer 30 (SIMPLE_EDGE)
+Reducer 32 <- Reducer 31 (SIMPLE_EDGE)
+Reducer 33 <- Reducer 32 (CUSTOM_SIMPLE_EDGE)
+Reducer 34 <- Reducer 31 (SIMPLE_EDGE)
+Reducer 35 <- Reducer 34 (CUSTOM_SIMPLE_EDGE)
+Reducer 36 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 38 <- Map 37 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Reducer 32 (ONE_TO_ONE_EDGE), Union 5 (CONTAINS)
+Reducer 43 <- Map 42 (SIMPLE_EDGE)
+Reducer 6 <- Union 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_543]
+        Limit [LIM_542] (rows=1 width=112)
+          Number of rows:100
+          Group By Operator [GBY_541] (rows=1 width=112)
+            Output:["_col0"],aggregations:["sum(VALUE._col0)"]
+          <-Union 5 [CUSTOM_SIMPLE_EDGE]
+            <-Reducer 12 [CONTAINS]
+              Reduce Output Operator [RS_462]
+                Group By Operator [GBY_461] (rows=1 width=112)
+                  Output:["_col0"],aggregations:["sum(_col0)"]
+                  Select Operator [SEL_459] (rows=52 width=112)
+                    Output:["_col0"]
+                    Merge Join Operator [MERGEJOIN_458] (rows=52 width=2)
+                      Conds:RS_200._col1=RS_549._col0(Inner),Output:["_col3","_col4"]
+                    <-Reducer 34 [ONE_TO_ONE_EDGE] vectorized
+                      PARTITION_ONLY_SHUFFLE [RS_549]
+                        PartitionCols:_col0
+                        Select Operator [SEL_548] (rows=745 width=4)
+                          Output:["_col0"]
+                          Filter Operator [FIL_547] (rows=745 width=12)
+                            predicate:(_col1 > 4L)
+                            Group By Operator [GBY_546] (rows=2235 width=12)
+                              Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                            <-Reducer 31 [SIMPLE_EDGE]
+                              SHUFFLE [RS_190]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_87] (rows=2235 width=12)
+                                  Output:["_col0","_col1"],aggregations:["count()"],keys:_col4
+                                  Merge Join Operator [MERGEJOIN_439] (rows=19646398 width=4)
+                                    Conds:RS_83._col1=RS_491._col0(Inner),Output:["_col4"]
+                                  <-Map 40 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_491]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_490] (rows=462000 width=188)
+                                        Output:["_col0"]
+                                        TableScan [TS_78] (rows=462000 width=4)
+                                          default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk"]
+                                  <-Reducer 30 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_83]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_438] (rows=19646398 width=4)
+                                        Conds:RS_489._col0=RS_479._col0(Inner),Output:["_col1"]
+                                      <-Map 28 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_479]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_476] (rows=2609 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_475] (rows=2609 width=8)
+                                              predicate:(d_year) IN (1999, 2000, 2001, 2002)
+                                              TableScan [TS_9] (rows=73049 width=8)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                      <-Map 39 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_489]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_488] (rows=550076554 width=7)
+                                            Output:["_col0","_col1"]
+                                            Filter Operator [FIL_487] (rows=550076554 width=7)
+                                              predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_81_date_dim_d_date_sk_min) AND DynamicValue(RS_81_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_81_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                              TableScan [TS_72] (rows=575995635 width=7)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk"]
+                                              <-Reducer 36 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_486]
+                                                  Group By Operator [GBY_485] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_484]
+                                                      Group By Operator [GBY_482] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_480] (rows=2609 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_476]
+                    <-Reducer 11 [SIMPLE_EDGE]
+                      SHUFFLE [RS_200]
+                        PartitionCols:_col1
+                        Merge Join Operator [MERGEJOIN_450] (rows=3941102 width=118)
+                          Conds:RS_197._col2=RS_576._col0(Inner),Output:["_col1","_col3","_col4"]
+                        <-Reducer 10 [SIMPLE_EDGE]
+                          PARTITION_ONLY_SHUFFLE [RS_197]
+                            PartitionCols:_col2
+                            Merge Join Operator [MERGEJOIN_440] (rows=3941102 width=122)
+                              Conds:RS_557._col0=RS_467._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                            <-Map 8 [SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_467]
+                                PartitionCols:_col0
+                                Select Operator [SEL_464] (rows=50 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_463] (rows=50 width=12)
+                                    predicate:((d_moy = 1) and (d_year = 1999))
+                                    TableScan [TS_3] (rows=73049 width=12)
+                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                            <-Map 41 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_557]
+                                PartitionCols:_col0
+                                Select Operator [SEL_556] (rows=143930993 width=127)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                  Filter Operator [FIL_555] (rows=143930993 width=127)
+                                    predicate:((ws_item_sk BETWEEN DynamicValue(RS_201_item_i_item_sk_min) AND DynamicValue(RS_201_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_201_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_195_date_dim_d_date_sk_min) AND DynamicValue(RS_195_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_195_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                    TableScan [TS_102] (rows=144002668 width=127)
+                                      default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_customer_sk","ws_quantity","ws_list_price"]
+                                    <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_545]
+                                        Group By Operator [GBY_544] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_472]
+                                            Group By Operator [GBY_470] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_468] (rows=50 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_464]
+                                    <-Reducer 35 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_554]
+                                        Group By Operator [GBY_553] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Reducer 34 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_552]
+                                            Group By Operator [GBY_551] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_550] (rows=745 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_548]
+                        <-Reducer 26 [ONE_TO_ONE_EDGE] vectorized
+                          FORWARD [RS_576]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_575] (rows=235937 width=3)
+                              Output:["_col0"],keys:KEY._col0
+                            <-Reducer 25 [SIMPLE_EDGE]
+                              SHUFFLE [RS_171]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_170] (rows=235937 width=3)
+                                  Output:["_col0"],keys:_col2
+                                  Select Operator [SEL_169] (rows=471875 width=227)
+                                    Output:["_col2"]
+                                    Filter Operator [FIL_168] (rows=471875 width=227)
+                                      predicate:(_col3 > _col1)
+                                      Merge Join Operator [MERGEJOIN_449] (rows=1415626 width=227)
+                                        Conds:(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Reducer 24 [CUSTOM_SIMPLE_EDGE]
+                                        PARTITION_ONLY_SHUFFLE [RS_165]
+                                          Merge Join Operator [MERGEJOIN_448] (rows=1 width=112)
+                                            Conds:(Inner),Output:["_col1"]
+                                          <-Reducer 23 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_563]
+                                              Select Operator [SEL_562] (rows=1 width=8)
+                                                Filter Operator [FIL_561] (rows=1 width=8)
+                                                  predicate:(sq_count_check(_col0) <= 1)
+                                                  Group By Operator [GBY_560] (rows=1 width=8)
+                                                    Output:["_col0"],aggregations:["count()"]
+                                                    Select Operator [SEL_559] (rows=1 width=8)
+                                                      Group By Operator [GBY_558] (rows=1 width=8)
+                                                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                      <-Reducer 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_520]
+                                                          Group By Operator [GBY_516] (rows=1 width=8)
+                                                            Output:["_col0"],aggregations:["count(_col0)"]
+                                                            Select Operator [SEL_512] (rows=50562 width=112)
+                                                              Output:["_col0"]
+                                                              Group By Operator [GBY_509] (rows=50562 width=112)
+                                                                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                                                              <-Reducer 16 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_17]
+                                                                  PartitionCols:_col0
+                                                                  Group By Operator [GBY_16] (rows=455058 width=112)
+                                                                    Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col1
+                                                                    Merge Join Operator [MERGEJOIN_436] (rows=18762463 width=112)
+                                                                      Conds:RS_508._col0=RS_477._col0(Inner),Output:["_col1","_col2"]
+                                                                    <-Map 28 [SIMPLE_EDGE] vectorized
+                                                                      PARTITION_ONLY_SHUFFLE [RS_477]
+                                                                        PartitionCols:_col0
+                                                                         Please refer to the previous Select Operator [SEL_476]
+                                                                    <-Map 15 [SIMPLE_EDGE] vectorized
+                                                                      SHUFFLE [RS_508]
+                                                                        PartitionCols:_col0
+                                                                        Select Operator [SEL_507] (rows=525327388 width=119)
+                                                                          Output:["_col0","_col1","_col2"]
+                                                                          Filter Operator [FIL_506] (rows=525327388 width=118)
+                                                                            predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_13_date_dim_d_date_sk_min) AND DynamicValue(RS_13_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_13_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                                            TableScan [TS_6] (rows=575995635 width=118)
+                                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_quantity","ss_sales_price"]
+                                                                            <-Reducer 29 [BROADCAST_EDGE] vectorized
+                                                                              BROADCAST [RS_505]
+                                                                                Group By Operator [GBY_504] (rows=1 width=12)
+                                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                  PARTITION_ONLY_SHUFFLE [RS_483]
+                                                                                    Group By Operator [GBY_481] (rows=1 width=12)
+                                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                      Select Operator [SEL_478] (rows=2609 width=4)
+                                                                                        Output:["_col0"]
+                                                                                         Please refer to the previous Select Operator [SEL_476]
+                                          <-Reducer 27 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_566]
+                                              Select Operator [SEL_565] (rows=1 width=112)
+                                                Output:["_col0"]
+                                                Group By Operator [GBY_564] (rows=1 width=112)
+                                                  Output:["_col0"],aggregations:["max(VALUE._col0)"]
+                                                <-Reducer 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_521]
+                                                    Group By Operator [GBY_517] (rows=1 width=112)
+                                                      Output:["_col0"],aggregations:["max(_col1)"]
+                                                      Select Operator [SEL_513] (rows=50562 width=112)
+                                                        Output:["_col1"]
+                                                         Please refer to the previous Group By Operator [GBY_509]
+                                      <-Reducer 43 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_574]
+                                          Group By Operator [GBY_573] (rows=1415626 width=115)
+                                            Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                                          <-Map 42 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_572]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_571] (rows=550080312 width=115)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                                                Select Operator [SEL_570] (rows=550080312 width=114)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_569] (rows=550080312 width=114)
+                                                    predicate:((ss_customer_sk BETWEEN DynamicValue(RS_197_web_sales_ws_bill_customer_sk_min) AND DynamicValue(RS_197_web_sales_ws_bill_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_197_web_sales_ws_bill_customer_sk_bloom_filter))) and ss_customer_sk is not null)
+                                                    TableScan [TS_154] (rows=575995635 width=114)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_customer_sk","ss_quantity","ss_sales_price"]
+                                                    <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_568]
+                                                        Group By Operator [GBY_567] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+                                                          PARTITION_ONLY_SHUFFLE [RS_414]
+                                                            Group By Operator [GBY_413] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_412] (rows=3941102 width=7)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_440]
+            <-Reducer 4 [CONTAINS]
+              Reduce Output Operator [RS_457]
+                Group By Operator [GBY_456] (rows=1 width=112)
+                  Output:["_col0"],aggregations:["sum(_col0)"]
+                  Select Operator [SEL_454] (rows=102 width=112)
+                    Output:["_col0"]
+                    Merge Join Operator [MERGEJOIN_453] (rows=102 width=1)
+                      Conds:RS_98._col2=RS_495._col0(Inner),Output:["_col3","_col4"]
+                    <-Reducer 32 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_495]
+                        PartitionCols:_col0
+                        Select Operator [SEL_494] (rows=745 width=4)
+                          Output:["_col0"]
+                          Filter Operator [FIL_493] (rows=745 width=12)
+                            predicate:(_col1 > 4L)
+                            Group By Operator [GBY_492] (rows=2235 width=12)
+                              Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                            <-Reducer 31 [SIMPLE_EDGE]
+                              SHUFFLE [RS_88]
+                                PartitionCols:_col0
+                                 Please refer to the previous Group By Operator [GBY_87]
+                    <-Reducer 3 [SIMPLE_EDGE]
+                      SHUFFLE [RS_98]
+                        PartitionCols:_col2
+                        Merge Join Operator [MERGEJOIN_447] (rows=7751875 width=98)
+                          Conds:RS_95._col1=RS_540._col0(Inner),Output:["_col2","_col3","_col4"]
+                        <-Reducer 2 [SIMPLE_EDGE]
+                          PARTITION_ONLY_SHUFFLE [RS_95]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_435] (rows=7751875 width=101)
+                              Conds:RS_503._col0=RS_465._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                            <-Map 8 [SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_465]
+                                PartitionCols:_col0
+                                 Please refer to the previous Select Operator [SEL_464]
+                            <-Map 1 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_503]
+                                PartitionCols:_col0
+                                Select Operator [SEL_502] (rows=285117831 width=127)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                  Filter Operator [FIL_501] (rows=285117831 width=127)
+                                    predicate:((cs_item_sk BETWEEN DynamicValue(RS_99_item_i_item_sk_min) AND DynamicValue(RS_99_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_99_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_93_date_dim_d_date_sk_min) AND DynamicValue(RS_93_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_93_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                    TableScan [TS_0] (rows=287989836 width=127)
+                                      default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_quantity","cs_list_price"]
+                                    <-Reducer 33 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_500]
+                                        Group By Operator [GBY_499] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Reducer 32 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          FORWARD [RS_498]
+                                            Group By Operator [GBY_497] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_496] (rows=745 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_494]
+                                    <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_474]
+                                        Group By Operator [GBY_473] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_471]
+                                            Group By Operator [GBY_469] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_466] (rows=50 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_464]
+                        <-Reducer 21 [ONE_TO_ONE_EDGE] vectorized
+                          FORWARD [RS_540]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_539] (rows=235937 width=3)
+                              Output:["_col0"],keys:KEY._col0
+                            <-Reducer 20 [SIMPLE_EDGE]
+                              SHUFFLE [RS_69]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_68] (rows=235937 width=3)
+                                  Output:["_col0"],keys:_col2
+                                  Select Operator [SEL_67] (rows=471875 width=227)
+                                    Output:["_col2"]
+                                    Filter Operator [FIL_66] (rows=471875 width=227)
+                                      predicate:(_col3 > _col1)
+                                      Merge Join Operator [MERGEJOIN_446] (rows=1415626 width=227)
+                                        Conds:(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Reducer 19 [CUSTOM_SIMPLE_EDGE]
+                                        PARTITION_ONLY_SHUFFLE [RS_63]
+                                          Merge Join Operator [MERGEJOIN_445] (rows=1 width=112)
+                                            Conds:(Inner),Output:["_col1"]
+                                          <-Reducer 18 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_527]
+                                              Select Operator [SEL_526] (rows=1 width=8)
+                                                Filter Operator [FIL_525] (rows=1 width=8)
+                                                  predicate:(sq_count_check(_col0) <= 1)
+                                                  Group By Operator [GBY_524] (rows=1 width=8)
+                                                    Output:["_col0"],aggregations:["count()"]
+                                                    Select Operator [SEL_523] (rows=1 width=8)
+                                                      Group By Operator [GBY_522] (rows=1 width=8)
+                                                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                      <-Reducer 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_518]
+                                                          Group By Operator [GBY_514] (rows=1 width=8)
+                                                            Output:["_col0"],aggregations:["count(_col0)"]
+                                                            Select Operator [SEL_510] (rows=50562 width=112)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Group By Operator [GBY_509]
+                                          <-Reducer 22 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_530]
+                                              Select Operator [SEL_529] (rows=1 width=112)
+                                                Output:["_col0"]
+                                                Group By Operator [GBY_528] (rows=1 width=112)
+                                                  Output:["_col0"],aggregations:["max(VALUE._col0)"]
+                                                <-Reducer 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_519]
+                                                    Group By Operator [GBY_515] (rows=1 width=112)
+                                                      Output:["_col0"],aggregations:["max(_col1)"]
+                                                      Select Operator [SEL_511] (rows=50562 width=112)
+                                                        Output:["_col1"]
+                                                         Please refer to the previous Group By Operator [GBY_509]
+                                      <-Reducer 38 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_538]
+                                          Group By Operator [GBY_537] (rows=1415626 width=115)
+                                            Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                                          <-Map 37 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_536]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_535] (rows=550080312 width=115)
+                                                Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                                                Select Operator [SEL_534] (rows=550080312 width=114)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_533] (rows=550080312 width=114)
+                                                    predicate:((ss_customer_sk BETWEEN DynamicValue(RS_95_catalog_sales_cs_bill_customer_sk_min) AND DynamicValue(RS_95_catalog_sales_cs_bill_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_95_catalog_sales_cs_bill_customer_sk_bloom_filter))) and ss_customer_sk is not null)
+                                                    TableScan [TS_52] (rows=575995635 width=114)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_customer_sk","ss_quantity","ss_sales_price"]
+                                                    <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_532]
+                                                        Group By Operator [GBY_531] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                          PARTITION_ONLY_SHUFFLE [RS_341]
+                                                            Group By Operator [GBY_340] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_339] (rows=7751875 width=6)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_435]
+


[21/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query28.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query28.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query28.q.out
new file mode 100644
index 0000000..c7fd970
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query28.q.out
@@ -0,0 +1,296 @@
+Warning: Shuffle Join MERGEJOIN[102][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[103][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[104][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[105][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[106][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Map 1 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Map 1 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 1 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 1 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 10 (CUSTOM_SIMPLE_EDGE), Reducer 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Reducer 12 (CUSTOM_SIMPLE_EDGE), Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Reducer 14 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Reducer 16 (CUSTOM_SIMPLE_EDGE), Reducer 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Reducer 18 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 1 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 8
+      File Output Operator [FS_59]
+        Limit [LIM_58] (rows=1 width=768)
+          Number of rows:100
+          Select Operator [SEL_57] (rows=1 width=768)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"]
+            Merge Join Operator [MERGEJOIN_106] (rows=1 width=768)
+              Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"]
+            <-Reducer 18 [CUSTOM_SIMPLE_EDGE] vectorized
+              PARTITION_ONLY_SHUFFLE [RS_166]
+                Select Operator [SEL_165] (rows=1 width=128)
+                  Output:["_col0","_col1","_col2"]
+                  Group By Operator [GBY_164] (rows=1 width=128)
+                    Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                  <-Reducer 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                    PARTITION_ONLY_SHUFFLE [RS_163]
+                      Group By Operator [GBY_162] (rows=1 width=128)
+                        Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","count(_col2)","count(_col0)"]
+                        Group By Operator [GBY_161] (rows=7618989 width=226)
+                          Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                        <-Map 1 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_130]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_124] (rows=7618989 width=226)
+                              Output:["_col0","_col1","_col2"],aggregations:["sum(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                              Select Operator [SEL_118] (rows=15237978 width=324)
+                                Output:["ss_list_price"]
+                                Filter Operator [FIL_112] (rows=15237978 width=324)
+                                  predicate:((ss_list_price BETWEEN 91 AND 101 or ss_coupon_amt BETWEEN 1430 AND 2430 or ss_wholesale_cost BETWEEN 32 AND 52) and ss_quantity BETWEEN 6 AND 10)
+                                  TableScan [TS_0] (rows=575995635 width=324)
+                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_quantity","ss_wholesale_cost","ss_list_price","ss_coupon_amt"]
+            <-Reducer 7 [CUSTOM_SIMPLE_EDGE]
+              PARTITION_ONLY_SHUFFLE [RS_54]
+                Merge Join Operator [MERGEJOIN_105] (rows=1 width=640)
+                  Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+                <-Reducer 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                  PARTITION_ONLY_SHUFFLE [RS_160]
+                    Select Operator [SEL_159] (rows=1 width=128)
+                      Output:["_col0","_col1","_col2"]
+                      Group By Operator [GBY_158] (rows=1 width=128)
+                        Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                      <-Reducer 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                        PARTITION_ONLY_SHUFFLE [RS_157]
+                          Group By Operator [GBY_156] (rows=1 width=128)
+                            Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","count(_col2)","count(_col0)"]
+                            Group By Operator [GBY_155] (rows=7618989 width=226)
+                              Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                            <-Map 1 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_129]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_123] (rows=7618989 width=226)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                                  Select Operator [SEL_117] (rows=15237978 width=324)
+                                    Output:["ss_list_price"]
+                                    Filter Operator [FIL_111] (rows=15237978 width=324)
+                                      predicate:((ss_list_price BETWEEN 66 AND 76 or ss_coupon_amt BETWEEN 920 AND 1920 or ss_wholesale_cost BETWEEN 4 AND 24) and ss_quantity BETWEEN 11 AND 15)
+                                       Please refer to the previous TableScan [TS_0]
+                <-Reducer 6 [CUSTOM_SIMPLE_EDGE]
+                  PARTITION_ONLY_SHUFFLE [RS_51]
+                    Merge Join Operator [MERGEJOIN_104] (rows=1 width=512)
+                      Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                    <-Reducer 14 [CUSTOM_SIMPLE_EDGE] vectorized
+                      PARTITION_ONLY_SHUFFLE [RS_154]
+                        Select Operator [SEL_153] (rows=1 width=128)
+                          Output:["_col0","_col1","_col2"]
+                          Group By Operator [GBY_152] (rows=1 width=128)
+                            Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                          <-Reducer 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_151]
+                              Group By Operator [GBY_150] (rows=1 width=128)
+                                Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","count(_col2)","count(_col0)"]
+                                Group By Operator [GBY_149] (rows=7618989 width=226)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_128]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_122] (rows=7618989 width=226)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                                      Select Operator [SEL_116] (rows=15237978 width=324)
+                                        Output:["ss_list_price"]
+                                        Filter Operator [FIL_110] (rows=15237978 width=324)
+                                          predicate:((ss_list_price BETWEEN 142 AND 152 or ss_coupon_amt BETWEEN 3054 AND 4054 or ss_wholesale_cost BETWEEN 80 AND 100) and ss_quantity BETWEEN 16 AND 20)
+                                           Please refer to the previous TableScan [TS_0]
+                    <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                      PARTITION_ONLY_SHUFFLE [RS_48]
+                        Merge Join Operator [MERGEJOIN_103] (rows=1 width=384)
+                          Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                        <-Reducer 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                          PARTITION_ONLY_SHUFFLE [RS_148]
+                            Select Operator [SEL_147] (rows=1 width=128)
+                              Output:["_col0","_col1","_col2"]
+                              Group By Operator [GBY_146] (rows=1 width=128)
+                                Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                              <-Reducer 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                PARTITION_ONLY_SHUFFLE [RS_145]
+                                  Group By Operator [GBY_144] (rows=1 width=128)
+                                    Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","count(_col2)","count(_col0)"]
+                                    Group By Operator [GBY_143] (rows=7618989 width=226)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_127]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_121] (rows=7618989 width=226)
+                                          Output:["_col0","_col1","_col2"],aggregations:["sum(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                                          Select Operator [SEL_115] (rows=15237978 width=324)
+                                            Output:["ss_list_price"]
+                                            Filter Operator [FIL_109] (rows=15237978 width=324)
+                                              predicate:((ss_list_price BETWEEN 135 AND 145 or ss_coupon_amt BETWEEN 14180 AND 15180 or ss_wholesale_cost BETWEEN 38 AND 58) and ss_quantity BETWEEN 21 AND 25)
+                                               Please refer to the previous TableScan [TS_0]
+                        <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                          PARTITION_ONLY_SHUFFLE [RS_45]
+                            Merge Join Operator [MERGEJOIN_102] (rows=1 width=256)
+                              Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                            <-Reducer 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_142]
+                                Select Operator [SEL_141] (rows=1 width=128)
+                                  Output:["_col0","_col1","_col2"]
+                                  Group By Operator [GBY_140] (rows=1 width=128)
+                                    Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                                  <-Reducer 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_139]
+                                      Group By Operator [GBY_138] (rows=1 width=128)
+                                        Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","count(_col2)","count(_col0)"]
+                                        Group By Operator [GBY_137] (rows=7618989 width=226)
+                                          Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_126]
+                                            PartitionCols:_col0
+                                            Group By Operator [GBY_120] (rows=7618989 width=226)
+                                              Output:["_col0","_col1","_col2"],aggregations:["sum(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                                              Select Operator [SEL_114] (rows=15237978 width=324)
+                                                Output:["ss_list_price"]
+                                                Filter Operator [FIL_108] (rows=15237978 width=324)
+                                                  predicate:((ss_list_price BETWEEN 28 AND 38 or ss_coupon_amt BETWEEN 2513 AND 3513 or ss_wholesale_cost BETWEEN 42 AND 62) and ss_quantity BETWEEN 26 AND 30)
+                                                   Please refer to the previous TableScan [TS_0]
+                            <-Reducer 3 [CUSTOM_SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_136]
+                                Select Operator [SEL_135] (rows=1 width=128)
+                                  Output:["_col0","_col1","_col2"]
+                                  Group By Operator [GBY_134] (rows=1 width=128)
+                                    Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","count(VALUE._col2)"]
+                                  <-Reducer 2 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_133]
+                                      Group By Operator [GBY_132] (rows=1 width=128)
+                                        Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","count(_col2)","count(_col0)"]
+                                        Group By Operator [GBY_131] (rows=7618989 width=226)
+                                          Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_125]
+                                            PartitionCols:_col0
+                                            Group By Operator [GBY_119] (rows=7618989 width=226)
+                                              Output:["_col0","_col1","_col2"],aggregations:["sum(ss_list_price)","count(ss_list_price)"],keys:ss_list_price
+                                              Select Operator [SEL_113] (rows=15237978 width=324)
+                                                Output:["ss_list_price"]
+                                                Filter Operator [FIL_107] (rows=15237978 width=324)
+                                                  predicate:((ss_list_price BETWEEN 11 AND 21 or ss_coupon_amt BETWEEN 460 AND 1460 or ss_wholesale_cost BETWEEN 14 AND 34) and ss_quantity BETWEEN 0 AND 5)
+                                                   Please refer to the previous TableScan [TS_0]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query29.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query29.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query29.q.out
new file mode 100644
index 0000000..715f1ce
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query29.q.out
@@ -0,0 +1,328 @@
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 9 (BROADCAST_EDGE)
+Map 10 <- Reducer 16 (BROADCAST_EDGE), Reducer 18 (BROADCAST_EDGE), Reducer 19 (BROADCAST_EDGE), Reducer 20 (BROADCAST_EDGE), Reducer 6 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (SIMPLE_EDGE), Map 15 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE), Reducer 17 (SIMPLE_EDGE)
+Reducer 13 <- Map 22 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Map 23 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+Reducer 16 <- Map 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 15 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 14 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_250]
+        Limit [LIM_249] (rows=100 width=496)
+          Number of rows:100
+          Select Operator [SEL_248] (rows=21091879 width=496)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_247]
+              Group By Operator [GBY_246] (rows=21091879 width=496)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_47]
+                  PartitionCols:_col0, _col1, _col2, _col3
+                  Group By Operator [GBY_46] (rows=21091879 width=496)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col13)","sum(_col19)","sum(_col3)"],keys:_col6, _col7, _col22, _col23
+                    Top N Key Operator [TNK_91] (rows=4156223234 width=483)
+                      keys:_col6, _col7, _col22, _col23,sort order:++++,top n:100
+                      Merge Join Operator [MERGEJOIN_203] (rows=4156223234 width=483)
+                        Conds:RS_42._col2, _col1=RS_43._col11, _col12(Inner),Output:["_col3","_col6","_col7","_col13","_col19","_col22","_col23"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        PARTITION_ONLY_SHUFFLE [RS_42]
+                          PartitionCols:_col2, _col1
+                          Merge Join Operator [MERGEJOIN_197] (rows=7638375 width=10)
+                            Conds:RS_214._col0=RS_206._col0(Inner),Output:["_col1","_col2","_col3"]
+                          <-Map 8 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_206]
+                              PartitionCols:_col0
+                              Select Operator [SEL_205] (rows=1957 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_204] (rows=1957 width=8)
+                                  predicate:(d_year) IN (1999, 2000, 2001)
+                                  TableScan [TS_3] (rows=73049 width=8)
+                                    default@date_dim,d3,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_214]
+                              PartitionCols:_col0
+                              Select Operator [SEL_213] (rows=285117831 width=15)
+                                Output:["_col0","_col1","_col2","_col3"]
+                                Filter Operator [FIL_212] (rows=285117831 width=15)
+                                  predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_40_d3_d_date_sk_min) AND DynamicValue(RS_40_d3_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_40_d3_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                  TableScan [TS_0] (rows=287989836 width=15)
+                                    default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_quantity"]
+                                  <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_211]
+                                      Group By Operator [GBY_210] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_209]
+                                          Group By Operator [GBY_208] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_207] (rows=1957 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_205]
+                      <-Reducer 14 [SIMPLE_EDGE]
+                        SHUFFLE [RS_43]
+                          PartitionCols:_col11, _col12
+                          Select Operator [SEL_38] (rows=21091879 width=484)
+                            Output:["_col1","_col2","_col8","_col11","_col12","_col14","_col17","_col18"]
+                            Merge Join Operator [MERGEJOIN_202] (rows=21091879 width=484)
+                              Conds:RS_35._col3=RS_245._col0(Inner),Output:["_col5","_col8","_col9","_col11","_col14","_col15","_col17","_col18"]
+                            <-Map 23 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_245]
+                                PartitionCols:_col0
+                                Select Operator [SEL_244] (rows=1704 width=192)
+                                  Output:["_col0","_col1","_col2"]
+                                  TableScan [TS_24] (rows=1704 width=192)
+                                    default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id","s_store_name"]
+                            <-Reducer 13 [SIMPLE_EDGE]
+                              SHUFFLE [RS_35]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_201] (rows=21091879 width=298)
+                                  Conds:RS_32._col1=RS_243._col0(Inner),Output:["_col3","_col5","_col8","_col9","_col11","_col14","_col15"]
+                                <-Map 22 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_243]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_242] (rows=462000 width=288)
+                                      Output:["_col0","_col1","_col2"]
+                                      TableScan [TS_22] (rows=462000 width=288)
+                                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_item_desc"]
+                                <-Reducer 12 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_32]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_200] (rows=21091879 width=18)
+                                      Conds:RS_29._col1, _col2, _col4=RS_30._col1, _col2, _col3(Inner),Output:["_col1","_col3","_col5","_col8","_col9","_col11"]
+                                    <-Reducer 17 [SIMPLE_EDGE]
+                                      PARTITION_ONLY_SHUFFLE [RS_30]
+                                        PartitionCols:_col1, _col2, _col3
+                                        Merge Join Operator [MERGEJOIN_199] (rows=5384572 width=13)
+                                          Conds:RS_228._col0=RS_221._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                        <-Map 15 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_221]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_218] (rows=201 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_216] (rows=201 width=12)
+                                                predicate:((d_year = 1999) and d_moy BETWEEN 4 AND 7)
+                                                TableScan [TS_9] (rows=73049 width=12)
+                                                  default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                        <-Map 21 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_228]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_227] (rows=53632139 width=19)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                              Filter Operator [FIL_226] (rows=53632139 width=19)
+                                                predicate:(sr_customer_sk is not null and sr_returned_date_sk is not null)
+                                                TableScan [TS_12] (rows=57591150 width=19)
+                                                  default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number","sr_return_quantity"]
+                                    <-Reducer 11 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_29]
+                                        PartitionCols:_col1, _col2, _col4
+                                        Merge Join Operator [MERGEJOIN_198] (rows=13737330 width=8)
+                                          Conds:RS_241._col0=RS_219._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                        <-Map 15 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_219]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_217] (rows=50 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_215] (rows=50 width=12)
+                                                predicate:((d_moy = 4) and (d_year = 1999))
+                                                 Please refer to the previous TableScan [TS_9]
+                                        <-Map 10 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_241]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_240] (rows=501694138 width=23)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_239] (rows=501694138 width=23)
+                                                predicate:((ss_customer_sk BETWEEN DynamicValue(RS_30_store_returns_sr_customer_sk_min) AND DynamicValue(RS_30_store_returns_sr_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_30_store_returns_sr_customer_sk_bloom_filter))) and (ss_customer_sk BETWEEN DynamicValue(RS_42_catalog_sales_cs_bill_customer_sk_min) AND DynamicValue(RS_42_catalog_sales_cs_bill_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_42_catalog_sales_cs_bill_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_30_store_returns_sr_item_sk_min) AND DynamicValue(RS_30_store_returns_sr_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_30_store_returns_sr_item_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_42_catalog_sales_cs_item_sk_min) AND DynamicValue(RS_42_catalog_sales_cs_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_42_catalog_sales_cs_item_sk_bloom_filter))) and (ss_sold_da
 te_sk BETWEEN DynamicValue(RS_27_d1_d_date_sk_min) AND DynamicValue(RS_27_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_27_d1_d_date_sk_bloom_filter))) and (ss_ticket_number BETWEEN DynamicValue(RS_30_store_returns_sr_ticket_number_min) AND DynamicValue(RS_30_store_returns_sr_ticket_number_max) and in_bloom_filter(ss_ticket_number, DynamicValue(RS_30_store_returns_sr_ticket_number_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_6] (rows=575995635 width=23)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_quantity"]
+                                                <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_225]
+                                                    Group By Operator [GBY_224] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_223]
+                                                        Group By Operator [GBY_222] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_220] (rows=50 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_217]
+                                                <-Reducer 18 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_230]
+                                                    Group By Operator [GBY_229] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 17 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_119]
+                                                        Group By Operator [GBY_118] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_117] (rows=5384572 width=8)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_199]
+                                                <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_232]
+                                                    Group By Operator [GBY_231] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 17 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_124]
+                                                        Group By Operator [GBY_123] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_122] (rows=5384572 width=5)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_199]
+                                                <-Reducer 20 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_234]
+                                                    Group By Operator [GBY_233] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=3507020)"]
+                                                    <-Reducer 17 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_129]
+                                                        Group By Operator [GBY_128] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=3507020)"]
+                                                          Select Operator [SEL_127] (rows=5384572 width=8)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_199]
+                                                <-Reducer 6 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_236]
+                                                    Group By Operator [GBY_235] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_144]
+                                                        Group By Operator [GBY_143] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_142] (rows=7638375 width=8)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_197]
+                                                <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_238]
+                                                    Group By Operator [GBY_237] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_149]
+                                                        Group By Operator [GBY_148] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_147] (rows=7638375 width=6)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_197]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query3.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query3.q.out
new file mode 100644
index 0000000..0cca24c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query3.q.out
@@ -0,0 +1,135 @@
+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
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 7 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_77]
+        Limit [LIM_76] (rows=100 width=220)
+          Number of rows:100
+          Select Operator [SEL_75] (rows=274400 width=220)
+            Output:["_col0","_col1","_col2","_col3"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_74]
+              Group By Operator [GBY_73] (rows=274400 width=220)
+                Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_17]
+                  PartitionCols:_col0, _col1, _col2
+                  Group By Operator [GBY_16] (rows=274400 width=220)
+                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)"],keys:_col7, _col4, _col5
+                    Merge Join Operator [MERGEJOIN_53] (rows=589741 width=108)
+                      Conds:RS_12._col0=RS_64._col0(Inner),Output:["_col2","_col4","_col5","_col7"]
+                    <-Map 8 [SIMPLE_EDGE] vectorized
+                      PARTITION_ONLY_SHUFFLE [RS_64]
+                        PartitionCols:_col0
+                        Select Operator [SEL_63] (rows=5619 width=8)
+                          Output:["_col0","_col1"]
+                          Filter Operator [FIL_62] (rows=5619 width=12)
+                            predicate:(d_moy = 12)
+                            TableScan [TS_6] (rows=73049 width=12)
+                              default@date_dim,dt,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                    <-Reducer 2 [SIMPLE_EDGE]
+                      SHUFFLE [RS_12]
+                        PartitionCols:_col0
+                        Merge Join Operator [MERGEJOIN_52] (rows=7666836 width=104)
+                          Conds:RS_72._col1=RS_56._col0(Inner),Output:["_col0","_col2","_col4","_col5"]
+                        <-Map 6 [SIMPLE_EDGE] vectorized
+                          PARTITION_ONLY_SHUFFLE [RS_56]
+                            PartitionCols:_col0
+                            Select Operator [SEL_55] (rows=669 width=107)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_54] (rows=669 width=111)
+                                predicate:(i_manufact_id = 436)
+                                TableScan [TS_3] (rows=462000 width=111)
+                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand_id","i_brand","i_manufact_id"]
+                        <-Map 1 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_72]
+                            PartitionCols:_col1
+                            Select Operator [SEL_71] (rows=550076554 width=114)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_70] (rows=550076554 width=114)
+                                predicate:((ss_item_sk BETWEEN DynamicValue(RS_10_item_i_item_sk_min) AND DynamicValue(RS_10_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_10_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_13_dt_d_date_sk_min) AND DynamicValue(RS_13_dt_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_13_dt_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                TableScan [TS_0] (rows=575995635 width=114)
+                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
+                                <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                  BROADCAST [RS_61]
+                                    Group By Operator [GBY_60] (rows=1 width=12)
+                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                    <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_59]
+                                        Group By Operator [GBY_58] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                          Select Operator [SEL_57] (rows=669 width=4)
+                                            Output:["_col0"]
+                                             Please refer to the previous Select Operator [SEL_55]
+                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                  BROADCAST [RS_69]
+                                    Group By Operator [GBY_68] (rows=1 width=12)
+                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_67]
+                                        Group By Operator [GBY_66] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                          Select Operator [SEL_65] (rows=5619 width=4)
+                                            Output:["_col0"]
+                                             Please refer to the previous Select Operator [SEL_63]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query30.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query30.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query30.q.out
new file mode 100644
index 0000000..7924edd
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query30.q.out
@@ -0,0 +1,221 @@
+PREHOOK: query: explain
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
+Reducer 13 <- Map 11 (SIMPLE_EDGE), Map 14 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 5 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 6 <- Map 5 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 10 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Map 5 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 4 vectorized
+      File Output Operator [FS_210]
+        Limit [LIM_209] (rows=100 width=942)
+          Number of rows:100
+          Select Operator [SEL_208] (rows=691171 width=942)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+          <-Reducer 3 [SIMPLE_EDGE]
+            SHUFFLE [RS_63]
+              Select Operator [SEL_62] (rows=691171 width=942)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                Merge Join Operator [MERGEJOIN_177] (rows=691171 width=942)
+                  Conds:RS_59._col0=RS_60._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col17"]
+                <-Reducer 2 [SIMPLE_EDGE]
+                  SHUFFLE [RS_59]
+                    PartitionCols:_col0
+                    Merge Join Operator [MERGEJOIN_171] (rows=1568628 width=834)
+                      Conds:RS_180._col2=RS_187._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                    <-Map 5 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_187]
+                        PartitionCols:_col0
+                        Select Operator [SEL_184] (rows=784314 width=4)
+                          Output:["_col0"]
+                          Filter Operator [FIL_181] (rows=784314 width=90)
+                            predicate:(ca_state = 'IL')
+                            TableScan [TS_3] (rows=40000000 width=90)
+                              default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
+                    <-Map 1 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_180]
+                        PartitionCols:_col2
+                        Select Operator [SEL_179] (rows=80000000 width=849)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                          Filter Operator [FIL_178] (rows=80000000 width=849)
+                            predicate:c_current_addr_sk is not null
+                            TableScan [TS_0] (rows=80000000 width=849)
+                              default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_customer_id","c_current_addr_sk","c_salutation","c_first_name","c_last_name","c_preferred_cust_flag","c_birth_day","c_birth_month","c_birth_year","c_birth_country","c_login","c_email_address","c_last_review_date"]
+                <-Reducer 8 [SIMPLE_EDGE]
+                  SHUFFLE [RS_60]
+                    PartitionCols:_col0
+                    Select Operator [SEL_55] (rows=704993 width=227)
+                      Output:["_col0","_col2"]
+                      Filter Operator [FIL_54] (rows=704993 width=227)
+                        predicate:(_col2 > _col3)
+                        Merge Join Operator [MERGEJOIN_176] (rows=2114980 width=227)
+                          Conds:RS_202._col1=RS_207._col1(Inner),Output:["_col0","_col2","_col3"]
+                        <-Reducer 10 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_207]
+                            PartitionCols:_col1
+                            Select Operator [SEL_206] (rows=6 width=198)
+                              Output:["_col0","_col1"]
+                              Group By Operator [GBY_205] (rows=6 width=206)
+                                Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","count(_col2)"],keys:_col0
+                                Select Operator [SEL_204] (rows=2537976 width=201)
+                                  Output:["_col0","_col2"]
+                                  Group By Operator [GBY_203] (rows=2537976 width=201)
+                                    Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                  <-Reducer 9 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_43]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_42] (rows=3923529 width=201)
+                                        Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col6, _col1
+                                        Merge Join Operator [MERGEJOIN_175] (rows=3923529 width=184)
+                                          Conds:RS_38._col2=RS_189._col0(Inner),Output:["_col1","_col3","_col6"]
+                                        <-Map 5 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_189]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_186] (rows=40000000 width=90)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_183] (rows=40000000 width=90)
+                                                predicate:ca_state is not null
+                                                 Please refer to the previous TableScan [TS_3]
+                                        <-Reducer 13 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_38]
+                                            PartitionCols:_col2
+                                            Merge Join Operator [MERGEJOIN_174] (rows=3923529 width=101)
+                                              Conds:RS_195._col0=RS_199._col0(Inner),Output:["_col1","_col2","_col3"]
+                                            <-Map 11 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_195]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_193] (rows=13130761 width=118)
+                                                  Output:["_col0","_col1","_col2","_col3"]
+                                                  Filter Operator [FIL_191] (rows=13130761 width=118)
+                                                    predicate:(wr_returned_date_sk is not null and wr_returning_addr_sk is not null)
+                                                    TableScan [TS_6] (rows=14398467 width=118)
+                                                      default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_returned_date_sk","wr_returning_customer_sk","wr_returning_addr_sk","wr_return_amt"]
+                                            <-Map 14 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_199]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_197] (rows=652 width=4)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_196] (rows=652 width=8)
+                                                    predicate:(d_year = 2002)
+                                                    TableScan [TS_9] (rows=73049 width=8)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                        <-Reducer 7 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_202]
+                            PartitionCols:_col1
+                            Select Operator [SEL_201] (rows=2114980 width=201)
+                              Output:["_col0","_col1","_col2"]
+                              Group By Operator [GBY_200] (rows=2114980 width=201)
+                                Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                              <-Reducer 6 [SIMPLE_EDGE]
+                                SHUFFLE [RS_23]
+                                  PartitionCols:_col0, _col1
+                                  Group By Operator [GBY_22] (rows=3746772 width=201)
+                                    Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col6, _col1
+                                    Merge Join Operator [MERGEJOIN_173] (rows=3746772 width=184)
+                                      Conds:RS_18._col2=RS_188._col0(Inner),Output:["_col1","_col3","_col6"]
+                                    <-Map 5 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_188]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_185] (rows=40000000 width=90)
+                                          Output:["_col0","_col1"]
+                                          Filter Operator [FIL_182] (rows=40000000 width=90)
+                                            predicate:ca_state is not null
+                                             Please refer to the previous TableScan [TS_3]
+                                    <-Reducer 12 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_18]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_172] (rows=3746772 width=101)
+                                          Conds:RS_194._col0=RS_198._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 11 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_194]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_192] (rows=12539215 width=118)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_190] (rows=12539215 width=118)
+                                                predicate:(wr_returned_date_sk is not null and wr_returning_addr_sk is not null and wr_returning_customer_sk is not null)
+                                                 Please refer to the previous TableScan [TS_6]
+                                        <-Map 14 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_198]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_197]
+


[12/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query61.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query61.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query61.q.out
new file mode 100644
index 0000000..d9543ad
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query61.q.out
@@ -0,0 +1,388 @@
+Warning: Shuffle Join MERGEJOIN[266][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 5' is a cross product
+PREHOOK: query: explain
+select  promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
+from
+  (select sum(ss_ext_sales_price) promotions
+   from  store_sales
+        ,store
+        ,promotion
+        ,date_dim
+        ,customer
+        ,customer_address 
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_promo_sk = p_promo_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk 
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) promotional_sales,
+  (select sum(ss_ext_sales_price) total
+   from  store_sales
+        ,store
+        ,date_dim
+        ,customer
+        ,customer_address
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) all_sales
+order by promotions, total
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
+from
+  (select sum(ss_ext_sales_price) promotions
+   from  store_sales
+        ,store
+        ,promotion
+        ,date_dim
+        ,customer
+        ,customer_address 
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_promo_sk = p_promo_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk 
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) promotional_sales,
+  (select sum(ss_ext_sales_price) total
+   from  store_sales
+        ,store
+        ,date_dim
+        ,customer
+        ,customer_address
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) all_sales
+order by promotions, total
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 12 <- Reducer 18 (BROADCAST_EDGE), Reducer 24 (BROADCAST_EDGE), Reducer 27 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Map 30 <- Reducer 10 (BROADCAST_EDGE), Reducer 22 (BROADCAST_EDGE), Reducer 25 (BROADCAST_EDGE), Reducer 28 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Map 12 (SIMPLE_EDGE), Map 17 (SIMPLE_EDGE)
+Reducer 14 <- Map 23 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+Reducer 15 <- Map 26 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Map 29 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 18 <- Map 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Map 17 (SIMPLE_EDGE), Map 30 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 11 (SIMPLE_EDGE)
+Reducer 20 <- Map 23 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
+Reducer 21 <- Map 26 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Map 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 24 <- Map 23 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Map 23 (CUSTOM_SIMPLE_EDGE)
+Reducer 27 <- Map 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 28 <- Map 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 16 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (CUSTOM_SIMPLE_EDGE), Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Reducer 2 (SIMPLE_EDGE), Reducer 21 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_336]
+        Limit [LIM_335] (rows=1 width=336)
+          Number of rows:100
+          Select Operator [SEL_334] (rows=1 width=336)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 5 [SIMPLE_EDGE]
+            SHUFFLE [RS_88]
+              Select Operator [SEL_87] (rows=1 width=336)
+                Output:["_col0","_col1","_col2"]
+                Merge Join Operator [MERGEJOIN_266] (rows=1 width=448)
+                  Conds:(Inner),Output:["_col0","_col1","_col2","_col3"]
+                <-Reducer 4 [CUSTOM_SIMPLE_EDGE] vectorized
+                  PARTITION_ONLY_SHUFFLE [RS_319]
+                    Select Operator [SEL_318] (rows=1 width=224)
+                      Output:["_col0","_col1"]
+                      Group By Operator [GBY_317] (rows=1 width=112)
+                        Output:["_col0"],aggregations:["sum(VALUE._col0)"]
+                      <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+                        PARTITION_ONLY_SHUFFLE [RS_42]
+                          Group By Operator [GBY_41] (rows=1 width=112)
+                            Output:["_col0"],aggregations:["sum(_col8)"]
+                            Merge Join Operator [MERGEJOIN_264] (rows=505397 width=0)
+                              Conds:RS_37._col0=RS_38._col2(Inner),Output:["_col8"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_37]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_255] (rows=16000001 width=4)
+                                  Conds:RS_269._col1=RS_272._col0(Inner),Output:["_col0"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_269]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_268] (rows=80000000 width=8)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_267] (rows=80000000 width=8)
+                                        predicate:c_current_addr_sk is not null
+                                        TableScan [TS_0] (rows=80000000 width=8)
+                                          default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk"]
+                                <-Map 11 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_272]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_271] (rows=8000000 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_270] (rows=8000000 width=112)
+                                        predicate:(ca_gmt_offset = -7)
+                                        TableScan [TS_3] (rows=40000000 width=112)
+                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_gmt_offset"]
+                            <-Reducer 16 [SIMPLE_EDGE]
+                              SHUFFLE [RS_38]
+                                PartitionCols:_col2
+                                Merge Join Operator [MERGEJOIN_259] (rows=2526982 width=0)
+                                  Conds:RS_30._col4=RS_316._col0(Inner),Output:["_col2","_col5"]
+                                <-Map 29 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_316]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_315] (rows=2300 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_314] (rows=2300 width=259)
+                                        predicate:((p_channel_dmail = 'Y') or (p_channel_email = 'Y') or (p_channel_tv = 'Y'))
+                                        TableScan [TS_18] (rows=2300 width=259)
+                                          default@promotion,promotion,Tbl:COMPLETE,Col:COMPLETE,Output:["p_promo_sk","p_channel_dmail","p_channel_email","p_channel_tv"]
+                                <-Reducer 15 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_30]
+                                    PartitionCols:_col4
+                                    Merge Join Operator [MERGEJOIN_258] (rows=2526982 width=0)
+                                      Conds:RS_27._col3=RS_299._col0(Inner),Output:["_col2","_col4","_col5"]
+                                    <-Map 26 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_299]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_298] (rows=341 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_297] (rows=341 width=115)
+                                            predicate:(s_gmt_offset = -7)
+                                            TableScan [TS_15] (rows=1704 width=115)
+                                              default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_gmt_offset"]
+                                    <-Reducer 14 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_27]
+                                        PartitionCols:_col3
+                                        Merge Join Operator [MERGEJOIN_257] (rows=12627499 width=0)
+                                          Conds:RS_24._col1=RS_287._col0(Inner),Output:["_col2","_col3","_col4","_col5"]
+                                        <-Map 23 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_287]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_286] (rows=46200 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_285] (rows=46200 width=94)
+                                                predicate:(i_category = 'Electronics')
+                                                TableScan [TS_12] (rows=462000 width=94)
+                                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_category"]
+                                        <-Reducer 13 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_24]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_256] (rows=13119234 width=4)
+                                              Conds:RS_313._col0=RS_275._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                            <-Map 17 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_275]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_274] (rows=50 width=4)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_273] (rows=50 width=12)
+                                                    predicate:((d_moy = 11) and (d_year = 1999))
+                                                    TableScan [TS_9] (rows=73049 width=12)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                            <-Map 12 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_313]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_312] (rows=479120970 width=126)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                                  Filter Operator [FIL_311] (rows=479120970 width=126)
+                                                    predicate:((ss_customer_sk BETWEEN DynamicValue(RS_37_customer_c_customer_sk_min) AND DynamicValue(RS_37_customer_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_37_customer_c_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_25_item_i_item_sk_min) AND DynamicValue(RS_25_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_25_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_22_date_dim_d_date_sk_min) AND DynamicValue(RS_22_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_22_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_28_store_s_store_sk_min) AND DynamicValue(RS_28_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_28_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_promo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                    TableScan [TS_6] (rows=575995635 width=126)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_store_sk","ss_promo_sk","ss_ext_sales_price"]
+                                                    <-Reducer 18 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_284]
+                                                        Group By Operator [GBY_283] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_281]
+                                                            Group By Operator [GBY_279] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_276] (rows=50 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_274]
+                                                    <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_296]
+                                                        Group By Operator [GBY_295] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 23 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_293]
+                                                            Group By Operator [GBY_291] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_288] (rows=46200 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_286]
+                                                    <-Reducer 27 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_308]
+                                                        Group By Operator [GBY_307] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 26 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_305]
+                                                            Group By Operator [GBY_303] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_300] (rows=341 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_298]
+                                                    <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_310]
+                                                        Group By Operator [GBY_309] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=14591048)"]
+                                                        <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                          SHUFFLE [RS_182]
+                                                            Group By Operator [GBY_181] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=14591048)"]
+                                                              Select Operator [SEL_180] (rows=16000001 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_255]
+                <-Reducer 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                  PARTITION_ONLY_SHUFFLE [RS_333]
+                    Select Operator [SEL_332] (rows=1 width=224)
+                      Output:["_col0","_col1"]
+                      Group By Operator [GBY_331] (rows=1 width=112)
+                        Output:["_col0"],aggregations:["sum(VALUE._col0)"]
+                      <-Reducer 8 [CUSTOM_SIMPLE_EDGE]
+                        PARTITION_ONLY_SHUFFLE [RS_81]
+                          Group By Operator [GBY_80] (rows=1 width=112)
+                            Output:["_col0"],aggregations:["sum(_col7)"]
+                            Merge Join Operator [MERGEJOIN_265] (rows=529208 width=0)
+                              Conds:RS_76._col0=RS_77._col2(Inner),Output:["_col7"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_76]
+                                PartitionCols:_col0
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_255]
+                            <-Reducer 21 [SIMPLE_EDGE]
+                              SHUFFLE [RS_77]
+                                PartitionCols:_col2
+                                Merge Join Operator [MERGEJOIN_263] (rows=2646038 width=0)
+                                  Conds:RS_69._col3=RS_301._col0(Inner),Output:["_col2","_col4"]
+                                <-Map 26 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_301]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Select Operator [SEL_298]
+                                <-Reducer 20 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_69]
+                                    PartitionCols:_col3
+                                    Merge Join Operator [MERGEJOIN_262] (rows=13222427 width=0)
+                                      Conds:RS_66._col1=RS_289._col0(Inner),Output:["_col2","_col3","_col4"]
+                                    <-Map 23 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_289]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_286]
+                                    <-Reducer 19 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_66]
+                                        PartitionCols:_col1
+                                        Merge Join Operator [MERGEJOIN_261] (rows=13737330 width=4)
+                                          Conds:RS_330._col0=RS_277._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                        <-Map 17 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_277]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_274]
+                                        <-Map 30 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_330]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_329] (rows=501694138 width=122)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                              Filter Operator [FIL_328] (rows=501694138 width=122)
+                                                predicate:((ss_customer_sk BETWEEN DynamicValue(RS_76_customer_c_customer_sk_min) AND DynamicValue(RS_76_customer_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_76_customer_c_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_67_item_i_item_sk_min) AND DynamicValue(RS_67_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_67_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_64_date_dim_d_date_sk_min) AND DynamicValue(RS_64_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_64_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_70_store_s_store_sk_min) AND DynamicValue(RS_70_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_70_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_51] (rows=575995635 width=122)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_store_sk","ss_ext_sales_price"]
+                                                <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_327]
+                                                    Group By Operator [GBY_326] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=14591048)"]
+                                                    <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_237]
+                                                        Group By Operator [GBY_236] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=14591048)"]
+                                                          Select Operator [SEL_235] (rows=16000001 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_255]
+                                                <-Reducer 22 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_321]
+                                                    Group By Operator [GBY_320] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_282]
+                                                        Group By Operator [GBY_280] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_278] (rows=50 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_274]
+                                                <-Reducer 25 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_323]
+                                                    Group By Operator [GBY_322] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 23 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_294]
+                                                        Group By Operator [GBY_292] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_290] (rows=46200 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_286]
+                                                <-Reducer 28 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_325]
+                                                    Group By Operator [GBY_324] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 26 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_306]
+                                                        Group By Operator [GBY_304] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_302] (rows=341 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_298]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query63.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query63.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query63.q.out
new file mode 100644
index 0000000..a1f8413
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query63.q.out
@@ -0,0 +1,163 @@
+PREHOOK: query: explain
+select  * 
+from (select i_manager_id
+             ,sum(ss_sales_price) sum_sales
+             ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
+      from item
+          ,store_sales
+          ,date_dim
+          ,store
+      where ss_item_sk = i_item_sk
+        and ss_sold_date_sk = d_date_sk
+        and ss_store_sk = s_store_sk
+        and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11)
+        and ((    i_category in ('Books','Children','Electronics')
+              and i_class in ('personal','portable','refernece','self-help')
+              and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		                  'exportiunivamalg #9','scholaramalgamalg #9'))
+           or(    i_category in ('Women','Music','Men')
+              and i_class in ('accessories','classical','fragrances','pants')
+              and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		                 'importoamalg #1')))
+group by i_manager_id, d_moy) tmp1
+where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+order by i_manager_id
+        ,avg_monthly_sales
+        ,sum_sales
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  * 
+from (select i_manager_id
+             ,sum(ss_sales_price) sum_sales
+             ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
+      from item
+          ,store_sales
+          ,date_dim
+          ,store
+      where ss_item_sk = i_item_sk
+        and ss_sold_date_sk = d_date_sk
+        and ss_store_sk = s_store_sk
+        and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11)
+        and ((    i_category in ('Books','Children','Electronics')
+              and i_class in ('personal','portable','refernece','self-help')
+              and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		                  'exportiunivamalg #9','scholaramalgamalg #9'))
+           or(    i_category in ('Women','Music','Men')
+              and i_class in ('accessories','classical','fragrances','pants')
+              and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		                 'importoamalg #1')))
+group by i_manager_id, d_moy) tmp1
+where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+order by i_manager_id
+        ,avg_monthly_sales
+        ,sum_sales
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 7 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_86]
+        Limit [LIM_85] (rows=71 width=228)
+          Number of rows:100
+          Select Operator [SEL_84] (rows=71 width=228)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 4 [SIMPLE_EDGE]
+            SHUFFLE [RS_27]
+              Select Operator [SEL_24] (rows=71 width=228)
+                Output:["_col0","_col1","_col2"]
+                Filter Operator [FIL_36] (rows=71 width=228)
+                  predicate:CASE WHEN ((avg_window_0 > 0)) THEN (((abs((_col2 - avg_window_0)) / avg_window_0) > 0.1)) ELSE (null) END
+                  Select Operator [SEL_23] (rows=143 width=116)
+                    Output:["avg_window_0","_col0","_col2"]
+                    PTF Operator [PTF_22] (rows=143 width=116)
+                      Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col0 ASC NULLS FIRST","partition by:":"_col0"}]
+                      Select Operator [SEL_19] (rows=143 width=116)
+                        Output:["_col0","_col2"]
+                        Group By Operator [GBY_18] (rows=143 width=120)
+                          Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                        <-Reducer 3 [SIMPLE_EDGE]
+                          SHUFFLE [RS_17]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_16] (rows=143 width=120)
+                              Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col4, _col6
+                              Merge Join Operator [MERGEJOIN_62] (rows=129200 width=8)
+                                Conds:RS_12._col0=RS_73._col0(Inner),Output:["_col2","_col4","_col6"]
+                              <-Map 8 [SIMPLE_EDGE] vectorized
+                                PARTITION_ONLY_SHUFFLE [RS_73]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_72] (rows=317 width=8)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_71] (rows=317 width=12)
+                                      predicate:(d_month_seq) IN (1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223)
+                                      TableScan [TS_6] (rows=73049 width=12)
+                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq","d_moy"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_12]
+                                  PartitionCols:_col0
+                                  Merge Join Operator [MERGEJOIN_61] (rows=744232 width=4)
+                                    Conds:RS_81._col1=RS_65._col0(Inner),Output:["_col0","_col2","_col4"]
+                                  <-Map 6 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_65]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_64] (rows=68 width=8)
+                                        Output:["_col0","_col1"]
+                                        Filter Operator [FIL_63] (rows=68 width=290)
+                                          predicate:((((i_category) IN ('Books', 'Children', 'Electronics') and (i_class) IN ('personal', 'portable', 'refernece', 'self-help') and (i_brand) IN ('scholaramalgamalg #14', 'scholaramalgamalg #7', 'exportiunivamalg #9', 'scholaramalgamalg #9')) or ((i_category) IN ('Women', 'Music', 'Men') and (i_class) IN ('accessories', 'classical', 'fragrances', 'pants') and (i_brand) IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1'))) and (i_brand) IN ('scholaramalgamalg #14', 'scholaramalgamalg #7', 'exportiunivamalg #9', 'scholaramalgamalg #9', 'amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1') and (i_category) IN ('Books', 'Children', 'Electronics', 'Women', 'Music', 'Men') and (i_class) IN ('personal', 'portable', 'refernece', 'self-help', 'accessories', 'classical', 'fragrances', 'pants'))
+                                          TableScan [TS_3] (rows=462000 width=289)
+                                            default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand","i_class","i_category","i_manager_id"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_81]
+                                      PartitionCols:_col1
+                                      Select Operator [SEL_80] (rows=525329897 width=114)
+                                        Output:["_col0","_col1","_col2"]
+                                        Filter Operator [FIL_79] (rows=525329897 width=118)
+                                          predicate:((ss_item_sk BETWEEN DynamicValue(RS_10_item_i_item_sk_min) AND DynamicValue(RS_10_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_10_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_13_date_dim_d_date_sk_min) AND DynamicValue(RS_13_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_13_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                          TableScan [TS_0] (rows=575995635 width=118)
+                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_sales_price"]
+                                          <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_70]
+                                              Group By Operator [GBY_69] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_68]
+                                                  Group By Operator [GBY_67] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_66] (rows=68 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_64]
+                                          <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_78]
+                                              Group By Operator [GBY_77] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_76]
+                                                  Group By Operator [GBY_75] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_74] (rows=317 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_72]
+


[70/75] [abbrv] hive git commit: HIVE-14516: OrcInputFormat.SplitGenerator.callInternal() can be optimized (Igor Kryvenko via Eugene Koifman)

Posted by se...@apache.org.
HIVE-14516: OrcInputFormat.SplitGenerator.callInternal() can be optimized (Igor Kryvenko via Eugene Koifman)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a26d9d16
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a26d9d16
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a26d9d16

Branch: refs/heads/master-tez092
Commit: a26d9d166064117152779267e78c6b7fdd2ba6ee
Parents: a99be34
Author: Igor Kryvenko <kr...@gmail.com>
Authored: Thu Oct 25 17:00:14 2018 -0700
Committer: Eugene Koifman <ek...@apache.org>
Committed: Thu Oct 25 17:00:14 2018 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java  | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/a26d9d16/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
index 25b2d48..720dbe5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
@@ -1551,9 +1551,7 @@ public class OrcInputFormat implements InputFormat<NullWritable, OrcStruct>,
       } else {
         populateAndCacheStripeDetails();
         boolean[] includeStripe = null;
-        // We can't eliminate stripes if there are deltas because the
-        // deltas may change the rows making them match the predicate. todo: See HIVE-14516.
-        if ((deltas == null || deltas.isEmpty()) && context.sarg != null) {
+        if (context.sarg != null) {
           String[] colNames =
               extractNeededColNames((readerTypes == null ? fileTypes : readerTypes),
                   context.conf, readerIncluded, isOriginal);
@@ -2212,7 +2210,7 @@ public class OrcInputFormat implements InputFormat<NullWritable, OrcStruct>,
                                        OrcFile.WriterVersion writerVersion,
                                        List<StripeStatistics> stripeStats,
       int stripeCount, Path filePath, final SchemaEvolution evolution) {
-    if (sarg == null || stripeStats == null || writerVersion == OrcFile.WriterVersion.ORIGINAL) {
+    if (stripeStats == null || writerVersion == OrcFile.WriterVersion.ORIGINAL) {
       return null; // only do split pruning if HIVE-8732 has been fixed in the writer
     }
     // eliminate stripes that doesn't satisfy the predicate condition


[53/75] [abbrv] hive git commit: HIVE-20679: DDL operations on hive might create large messages for DBNotification (Anishek Agarwal, reviewed by Sankar Hariappan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java
new file mode 100644
index 0000000..787b9b2
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java
@@ -0,0 +1,425 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.messaging;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
+import java.util.regex.PatternSyntaxException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.api.Catalog;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
+import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
+import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
+import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.api.TxnToWriteId;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.events.AcidWriteEvent;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAbortTxnMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAcidWriteMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAddForeignKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAddNotNullConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAddPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAddPrimaryKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAddUniqueConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAllocWriteIdMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAlterCatalogMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAlterDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAlterPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONAlterTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONCommitTxnMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONCreateCatalogMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONCreateDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONCreateFunctionMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONCreateTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONDropCatalogMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONDropConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONDropDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONDropFunctionMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONDropPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONDropTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONInsertMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONOpenTxnMessage;
+import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
+import org.apache.thrift.TBase;
+import org.apache.thrift.TDeserializer;
+import org.apache.thrift.TException;
+import org.apache.thrift.TSerializer;
+import org.apache.thrift.protocol.TJSONProtocol;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.filterMapkeys;
+
+public class MessageBuilder {
+  private static final Logger LOG = LoggerFactory.getLogger(MessageBuilder.class);
+
+  public static final String ADD_PARTITION_EVENT = "ADD_PARTITION";
+  public static final String ALTER_PARTITION_EVENT = "ALTER_PARTITION";
+  public static final String DROP_PARTITION_EVENT = "DROP_PARTITION";
+  public static final String CREATE_TABLE_EVENT = "CREATE_TABLE";
+  public static final String ALTER_TABLE_EVENT = "ALTER_TABLE";
+  public static final String DROP_TABLE_EVENT = "DROP_TABLE";
+  public static final String CREATE_DATABASE_EVENT = "CREATE_DATABASE";
+  public static final String ALTER_DATABASE_EVENT = "ALTER_DATABASE";
+  public static final String DROP_DATABASE_EVENT = "DROP_DATABASE";
+  public static final String INSERT_EVENT = "INSERT";
+  public static final String CREATE_FUNCTION_EVENT = "CREATE_FUNCTION";
+  public static final String DROP_FUNCTION_EVENT = "DROP_FUNCTION";
+  public static final String ADD_PRIMARYKEY_EVENT = "ADD_PRIMARYKEY";
+  public static final String ADD_FOREIGNKEY_EVENT = "ADD_FOREIGNKEY";
+  public static final String ADD_UNIQUECONSTRAINT_EVENT = "ADD_UNIQUECONSTRAINT";
+  public static final String ADD_NOTNULLCONSTRAINT_EVENT = "ADD_NOTNULLCONSTRAINT";
+  public static final String DROP_CONSTRAINT_EVENT = "DROP_CONSTRAINT";
+  public static final String CREATE_ISCHEMA_EVENT = "CREATE_ISCHEMA";
+  public static final String ALTER_ISCHEMA_EVENT = "ALTER_ISCHEMA";
+  public static final String DROP_ISCHEMA_EVENT = "DROP_ISCHEMA";
+  public static final String ADD_SCHEMA_VERSION_EVENT = "ADD_SCHEMA_VERSION";
+  public static final String ALTER_SCHEMA_VERSION_EVENT = "ALTER_SCHEMA_VERSION";
+  public static final String DROP_SCHEMA_VERSION_EVENT = "DROP_SCHEMA_VERSION";
+  public static final String CREATE_CATALOG_EVENT = "CREATE_CATALOG";
+  public static final String DROP_CATALOG_EVENT = "DROP_CATALOG";
+  public static final String OPEN_TXN_EVENT = "OPEN_TXN";
+  public static final String COMMIT_TXN_EVENT = "COMMIT_TXN";
+  public static final String ABORT_TXN_EVENT = "ABORT_TXN";
+  public static final String ALLOC_WRITE_ID_EVENT = "ALLOC_WRITE_ID_EVENT";
+  public static final String ALTER_CATALOG_EVENT = "ALTER_CATALOG";
+  public static final String ACID_WRITE_EVENT = "ACID_WRITE_EVENT";
+
+  protected static final Configuration conf = MetastoreConf.newMetastoreConf();
+
+  private static final String MS_SERVER_URL = MetastoreConf
+      .getVar(conf, MetastoreConf.ConfVars.THRIFT_URIS, "");
+  private static final String MS_SERVICE_PRINCIPAL =
+      MetastoreConf.getVar(conf, MetastoreConf.ConfVars.KERBEROS_PRINCIPAL, "");
+
+  private static volatile MessageBuilder instance;
+  private static final Object lock = new Object();
+
+  public static MessageBuilder getInstance() {
+    if (instance == null) {
+      synchronized (lock) {
+        if (instance == null) {
+          instance = new MessageBuilder();
+          instance.init();
+        }
+      }
+    }
+    return instance;
+  }
+
+  private static List<Predicate<String>> paramsFilter;
+
+  public void init() {
+    List<String> excludePatterns = Arrays.asList(MetastoreConf
+        .getTrimmedStringsVar(conf,
+            MetastoreConf.ConfVars.EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS));
+    try {
+      paramsFilter = MetaStoreUtils.compilePatternsToPredicates(excludePatterns);
+    } catch (PatternSyntaxException e) {
+      LOG.error("Regex pattern compilation failed. Verify that "
+          + "metastore.notification.parameters.exclude.patterns has valid patterns.");
+      throw new IllegalStateException("Regex pattern compilation failed. " + e.getMessage());
+    }
+  }
+
+  public CreateDatabaseMessage buildCreateDatabaseMessage(Database db) {
+    return new JSONCreateDatabaseMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, db, now());
+  }
+
+  public AlterDatabaseMessage buildAlterDatabaseMessage(Database beforeDb, Database afterDb) {
+    return new JSONAlterDatabaseMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
+        beforeDb, afterDb, now());
+  }
+
+  public DropDatabaseMessage buildDropDatabaseMessage(Database db) {
+    return new JSONDropDatabaseMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, db.getName(), now());
+  }
+
+  public CreateTableMessage buildCreateTableMessage(Table table, Iterator<String> fileIter) {
+    return new JSONCreateTableMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table, fileIter, now());
+  }
+
+  public AlterTableMessage buildAlterTableMessage(Table before, Table after, boolean isTruncateOp,
+      Long writeId) {
+    return new JSONAlterTableMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, before, after,
+        isTruncateOp, writeId, now());
+  }
+
+  public DropTableMessage buildDropTableMessage(Table table) {
+    return new JSONDropTableMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table, now());
+  }
+
+  public AddPartitionMessage buildAddPartitionMessage(Table table,
+      Iterator<Partition> partitionsIterator, Iterator<PartitionFiles> partitionFileIter) {
+    return new JSONAddPartitionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table,
+        partitionsIterator, partitionFileIter, now());
+  }
+
+  public AlterPartitionMessage buildAlterPartitionMessage(Table table, Partition before,
+      Partition after, boolean isTruncateOp, Long writeId) {
+    return new JSONAlterPartitionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
+        table, before, after, isTruncateOp, writeId, now());
+  }
+
+  public DropPartitionMessage buildDropPartitionMessage(Table table,
+      Iterator<Partition> partitionsIterator) {
+    return new JSONDropPartitionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table,
+        getPartitionKeyValues(table, partitionsIterator), now());
+  }
+
+  public CreateFunctionMessage buildCreateFunctionMessage(Function fn) {
+    return new JSONCreateFunctionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fn, now());
+  }
+
+  public DropFunctionMessage buildDropFunctionMessage(Function fn) {
+    return new JSONDropFunctionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fn, now());
+  }
+
+  public InsertMessage buildInsertMessage(Table tableObj, Partition partObj,
+      boolean replace, Iterator<String> fileIter) {
+    return new JSONInsertMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
+        tableObj, partObj, replace, fileIter, now());
+  }
+
+  public AddPrimaryKeyMessage buildAddPrimaryKeyMessage(List<SQLPrimaryKey> pks) {
+    return new JSONAddPrimaryKeyMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, pks, now());
+  }
+
+  public AddForeignKeyMessage buildAddForeignKeyMessage(List<SQLForeignKey> fks) {
+    return new JSONAddForeignKeyMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fks, now());
+  }
+
+  public AddUniqueConstraintMessage buildAddUniqueConstraintMessage(List<SQLUniqueConstraint> uks) {
+    return new JSONAddUniqueConstraintMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, uks, now());
+  }
+
+  public AddNotNullConstraintMessage buildAddNotNullConstraintMessage(
+      List<SQLNotNullConstraint> nns) {
+    return new JSONAddNotNullConstraintMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, nns, now());
+  }
+
+  public DropConstraintMessage buildDropConstraintMessage(String dbName, String tableName,
+      String constraintName) {
+    return new JSONDropConstraintMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, dbName, tableName,
+        constraintName, now());
+  }
+
+  public CreateCatalogMessage buildCreateCatalogMessage(Catalog catalog) {
+    return new JSONCreateCatalogMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, catalog.getName(),
+        now());
+  }
+
+  public AlterCatalogMessage buildAlterCatalogMessage(Catalog beforeCat, Catalog afterCat) {
+    return new JSONAlterCatalogMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
+        beforeCat, afterCat, now());
+  }
+
+  public DropCatalogMessage buildDropCatalogMessage(Catalog catalog) {
+    return new JSONDropCatalogMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, catalog.getName(),
+        now());
+  }
+
+  public OpenTxnMessage buildOpenTxnMessage(Long fromTxnId, Long toTxnId) {
+    return new JSONOpenTxnMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fromTxnId, toTxnId, now());
+  }
+
+  public CommitTxnMessage buildCommitTxnMessage(Long txnId) {
+    return new JSONCommitTxnMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, txnId, now());
+  }
+
+  public AbortTxnMessage buildAbortTxnMessage(Long txnId) {
+    return new JSONAbortTxnMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, txnId, now());
+  }
+
+  public AllocWriteIdMessage buildAllocWriteIdMessage(List<TxnToWriteId> txnToWriteIdList,
+      String dbName, String tableName) {
+    return new JSONAllocWriteIdMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, txnToWriteIdList,
+        dbName, tableName, now());
+  }
+
+  public AcidWriteMessage buildAcidWriteMessage(AcidWriteEvent acidWriteEvent,
+      Iterator<String> files) {
+    return new JSONAcidWriteMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, now(), acidWriteEvent,
+        files);
+  }
+
+  private long now() {
+    return System.currentTimeMillis() / 1000;
+  }
+
+  public static String createPrimaryKeyObjJson(SQLPrimaryKey primaryKeyObj) throws TException {
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(primaryKeyObj, "UTF-8");
+  }
+
+  public static String createForeignKeyObjJson(SQLForeignKey foreignKeyObj) throws TException {
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(foreignKeyObj, "UTF-8");
+  }
+
+  public static String createUniqueConstraintObjJson(SQLUniqueConstraint uniqueConstraintObj)
+      throws TException {
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(uniqueConstraintObj, "UTF-8");
+  }
+
+  public static String createNotNullConstraintObjJson(SQLNotNullConstraint notNullConstaintObj)
+      throws TException {
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(notNullConstaintObj, "UTF-8");
+  }
+
+  public static String createDatabaseObjJson(Database dbObj) throws TException {
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(dbObj, "UTF-8");
+  }
+
+  public static String createCatalogObjJson(Catalog catObj) throws TException {
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(catObj, "UTF-8");
+  }
+
+  public static String createTableObjJson(Table tableObj) throws TException {
+    //Note: The parameters of the Table object will be removed in the filter if it matches
+    // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS
+    filterMapkeys(tableObj.getParameters(), paramsFilter);
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(tableObj, "UTF-8");
+  }
+
+  public static String createPartitionObjJson(Partition partitionObj) throws TException {
+    //Note: The parameters of the Partition object will be removed in the filter if it matches
+    // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS
+    filterMapkeys(partitionObj.getParameters(), paramsFilter);
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(partitionObj, "UTF-8");
+  }
+
+  public static String createFunctionObjJson(Function functionObj) throws TException {
+    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
+    return serializer.toString(functionObj, "UTF-8");
+  }
+
+  public static Table getTableObj(ObjectNode jsonTree) throws Exception {
+    TDeserializer deSerializer = new TDeserializer(new TJSONProtocol.Factory());
+    Table tableObj = new Table();
+    String tableJson = jsonTree.get("tableObjJson").asText();
+    deSerializer.deserialize(tableObj, tableJson, "UTF-8");
+    return tableObj;
+  }
+
+  /*
+   * TODO: Some thoughts here : We have a current todo to move some of these methods over to
+   * MessageFactory instead of being here, so we can override them, but before we move them over,
+   * we should keep the following in mind:
+   *
+   * a) We should return Iterables, not Lists. That makes sure that we can be memory-safe when
+   * implementing it rather than forcing ourselves down a path wherein returning List is part of
+   * our interface, and then people use .size() or somesuch which makes us need to materialize
+   * the entire list and not change. Also, returning Iterables allows us to do things like
+   * Iterables.transform for some of these.
+   * b) We should not have "magic" names like "tableObjJson", because that breaks expectation of a
+   * couple of things - firstly, that of serialization format, although that is fine for this
+   * JSONMessageEncoder, and secondly, that makes us just have a number of mappings, one for each
+   * obj type, and sometimes, as the case is with alter, have multiples. Also, any event-specific
+   * item belongs in that event message / event itself, as opposed to in the factory. It's okay to
+   * have utility accessor methods here that are used by each of the messages to provide accessors.
+   * I'm adding a couple of those here.
+   *
+   */
+
+  public static TBase getTObj(String tSerialized, Class<? extends TBase> objClass)
+      throws Exception {
+    TDeserializer thriftDeSerializer = new TDeserializer(new TJSONProtocol.Factory());
+    TBase obj = objClass.newInstance();
+    thriftDeSerializer.deserialize(obj, tSerialized, "UTF-8");
+    return obj;
+  }
+
+  public static Iterable<? extends TBase> getTObjs(
+      Iterable<String> objRefStrs, final Class<? extends TBase> objClass) throws Exception {
+
+    try {
+      return Iterables.transform(objRefStrs, new com.google.common.base.Function<String, TBase>() {
+
+        public TBase apply(@Nullable String objStr) {
+          try {
+            return getTObj(objStr, objClass);
+          } catch (Exception e) {
+            throw new RuntimeException(e);
+          }
+        }
+      });
+    } catch (RuntimeException re) {
+      // We have to add this bit of exception handling here, because Function.apply does not allow us to throw
+      // the actual exception that might be a checked exception, so we wind up needing to throw a RuntimeException
+      // with the previously thrown exception as its cause. However, since RuntimeException.getCause() returns
+      // a throwable instead of an Exception, we have to account for the possibility that the underlying code
+      // might have thrown a Throwable that we wrapped instead, in which case, continuing to throw the
+      // RuntimeException is the best thing we can do.
+      Throwable t = re.getCause();
+      if (t instanceof Exception) {
+        throw (Exception) t;
+      } else {
+        throw re;
+      }
+    }
+  }
+
+  // If we do not need this format of accessor using ObjectNode, this is a candidate for removal as well
+  public static Iterable<? extends TBase> getTObjs(
+      ObjectNode jsonTree, String objRefListName, final Class<? extends TBase> objClass)
+      throws Exception {
+    Iterable<JsonNode> jsonArrayIterator = jsonTree.get(objRefListName);
+    return getTObjs(Iterables.transform(jsonArrayIterator, JsonNode::asText), objClass);
+  }
+
+  public static Map<String, String> getPartitionKeyValues(Table table, Partition partition) {
+    Map<String, String> partitionKeys = new LinkedHashMap<>();
+    for (int i = 0; i < table.getPartitionKeysSize(); ++i) {
+      partitionKeys.put(table.getPartitionKeys().get(i).getName(),
+          partition.getValues().get(i));
+    }
+    return partitionKeys;
+  }
+
+  public static List<Map<String, String>> getPartitionKeyValues(final Table table,
+      Iterator<Partition> iterator) {
+    return Lists.newArrayList(Iterators
+        .transform(iterator, partition -> getPartitionKeyValues(table, partition)));
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageEncoder.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageEncoder.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageEncoder.java
new file mode 100644
index 0000000..832a80c
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageEncoder.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.messaging;
+
+public interface MessageEncoder {
+  MessageDeserializer getDeserializer();
+
+  MessageSerializer getSerializer();
+
+  String getMessageFormat();
+
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java
index 58c6891..16e74bb 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java
@@ -20,329 +20,86 @@
 package org.apache.hadoop.hive.metastore.messaging;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hive.metastore.api.Catalog;
-import org.apache.hadoop.hive.metastore.api.Database;
-import org.apache.hadoop.hive.metastore.api.Function;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
-import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
-import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
-import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.apache.hadoop.hive.metastore.api.TxnToWriteId;
 import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
-import org.apache.hadoop.hive.metastore.events.AcidWriteEvent;
-import org.apache.hadoop.hive.metastore.utils.JavaUtils;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
+import org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import java.util.Iterator;
-import java.util.List;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Abstract Factory for the construction of HCatalog message instances.
  */
 public abstract class MessageFactory {
+  private static final Logger LOG = LoggerFactory.getLogger(MessageFactory.class.getName());
 
-  // Common name constants for event messages
-  public static final String ADD_PARTITION_EVENT = "ADD_PARTITION";
-  public static final String ALTER_PARTITION_EVENT = "ALTER_PARTITION";
-  public static final String DROP_PARTITION_EVENT = "DROP_PARTITION";
-  public static final String CREATE_TABLE_EVENT = "CREATE_TABLE";
-  public static final String ALTER_TABLE_EVENT = "ALTER_TABLE";
-  public static final String DROP_TABLE_EVENT = "DROP_TABLE";
-  public static final String CREATE_DATABASE_EVENT = "CREATE_DATABASE";
-  public static final String ALTER_DATABASE_EVENT = "ALTER_DATABASE";
-  public static final String DROP_DATABASE_EVENT = "DROP_DATABASE";
-  public static final String INSERT_EVENT = "INSERT";
-  public static final String CREATE_FUNCTION_EVENT = "CREATE_FUNCTION";
-  public static final String DROP_FUNCTION_EVENT = "DROP_FUNCTION";
-  public static final String ADD_PRIMARYKEY_EVENT = "ADD_PRIMARYKEY";
-  public static final String ADD_FOREIGNKEY_EVENT = "ADD_FOREIGNKEY";
-  public static final String ADD_UNIQUECONSTRAINT_EVENT = "ADD_UNIQUECONSTRAINT";
-  public static final String ADD_NOTNULLCONSTRAINT_EVENT = "ADD_NOTNULLCONSTRAINT";
-  public static final String DROP_CONSTRAINT_EVENT = "DROP_CONSTRAINT";
-  public static final String CREATE_ISCHEMA_EVENT = "CREATE_ISCHEMA";
-  public static final String ALTER_ISCHEMA_EVENT = "ALTER_ISCHEMA";
-  public static final String DROP_ISCHEMA_EVENT = "DROP_ISCHEMA";
-  public static final String ADD_SCHEMA_VERSION_EVENT = "ADD_SCHEMA_VERSION";
-  public static final String ALTER_SCHEMA_VERSION_EVENT = "ALTER_SCHEMA_VERSION";
-  public static final String DROP_SCHEMA_VERSION_EVENT = "DROP_SCHEMA_VERSION";
-  public static final String CREATE_CATALOG_EVENT = "CREATE_CATALOG";
-  public static final String DROP_CATALOG_EVENT = "DROP_CATALOG";
-  public static final String OPEN_TXN_EVENT = "OPEN_TXN";
-  public static final String COMMIT_TXN_EVENT = "COMMIT_TXN";
-  public static final String ABORT_TXN_EVENT = "ABORT_TXN";
-  public static final String ALLOC_WRITE_ID_EVENT = "ALLOC_WRITE_ID_EVENT";
-  public static final String ALTER_CATALOG_EVENT = "ALTER_CATALOG";
-  public static final String ACID_WRITE_EVENT = "ACID_WRITE_EVENT";
+  protected static final Configuration conf = MetastoreConf.newMetastoreConf();
 
-  private static MessageFactory instance = null;
+  private static final Map<String, Method> registry = new HashMap<>();
 
-  protected static final Configuration conf = MetastoreConf.newMetastoreConf();
-  /*
-  // TODO MS-SPLIT I'm 99% certain we don't need this, as MetastoreConf.newMetastoreConf already
-  adds this resource.
-  static {
-    conf.addResource("hive-site.xml");
+  public static void register(String messageFormat, Class clazz) {
+    Method method = requiredMethod(clazz);
+    registry.put(messageFormat, method);
   }
-  */
-
-  protected static final String MS_SERVER_URL = MetastoreConf.getVar(conf, ConfVars.THRIFT_URIS, "");
-  protected static final String MS_SERVICE_PRINCIPAL =
-      MetastoreConf.getVar(conf, ConfVars.KERBEROS_PRINCIPAL, "");
 
+  static {
+    register(GzipJSONMessageEncoder.FORMAT, GzipJSONMessageEncoder.class);
+    register(JSONMessageEncoder.FORMAT, JSONMessageEncoder.class);
+  }
 
-  /**
-   * Getter for MessageFactory instance.
-   */
-  public static MessageFactory getInstance() {
-    if (instance == null) {
-      instance = getInstance(MetastoreConf.getVar(conf, ConfVars.EVENT_MESSAGE_FACTORY));
+  private static Method requiredMethod(Class clazz) {
+    if (MessageEncoder.class.isAssignableFrom(clazz)) {
+      try {
+        Method methodInstance = clazz.getMethod("getInstance");
+        if (MessageEncoder.class.isAssignableFrom(methodInstance.getReturnType())) {
+          int modifiers = methodInstance.getModifiers();
+          if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
+            return methodInstance;
+          }
+          throw new NoSuchMethodException(
+              "modifier for getInstance() method is not 'public static' in " + clazz
+                  .getCanonicalName());
+        }
+        throw new NoSuchMethodException(
+            "return type is not assignable to " + MessageEncoder.class.getCanonicalName());
+      } catch (NoSuchMethodException e) {
+        String message = clazz.getCanonicalName()
+            + " does not implement the required 'public static MessageEncoder getInstance()' method ";
+        LOG.error(message, e);
+        throw new IllegalArgumentException(message, e);
+      }
     }
-    return instance;
+    String message = clazz.getCanonicalName() + " is not assignable to " + MessageEncoder.class
+        .getCanonicalName();
+    LOG.error(message);
+    throw new IllegalArgumentException(message);
   }
 
-  private static MessageFactory getInstance(String className) {
-    try {
-      MessageFactory factory = JavaUtils.newInstance(JavaUtils.getClass(className, MessageFactory.class));
-      factory.init();
-      return factory;
-    } catch (MetaException e) {
-      throw new IllegalStateException("Could not construct MessageFactory implementation: ", e);
+  public static MessageEncoder getInstance(String messageFormat)
+      throws InvocationTargetException, IllegalAccessException {
+    Method methodInstance = registry.get(messageFormat);
+    if (methodInstance == null) {
+      LOG.error("received incorrect MessageFormat " + messageFormat);
+      throw new RuntimeException("messageFormat: " + messageFormat + " is not supported ");
     }
+    return (MessageEncoder) methodInstance.invoke(null);
   }
 
-  /**
-   * Getter for MessageDeserializer, corresponding to the specified format and version.
-   * @param format Serialization format for notifications.
-   * @param version Version of serialization format (currently ignored.)
-   * @return MessageDeserializer.
-   */
-  public static MessageDeserializer getDeserializer(String format,
-                            String version) {
-    return getInstance(MetastoreConf.getVar(conf, ConfVars.EVENT_MESSAGE_FACTORY)).getDeserializer();
-    // Note : The reason this method exists outside the no-arg getDeserializer method is in
-    // case there is a user-implemented MessageFactory that's used, and some the messages
-    // are in an older format and the rest in another. Then, what MessageFactory is default
-    // is irrelevant, we should always use the one that was used to create it to deserialize.
-    //
-    // There exist only 2 implementations of this - json and jms
-    //
-    // Additional note : rather than as a config parameter, does it make sense to have
-    // this use jdbc-like semantics that each MessageFactory made available register
-    // itself for discoverability? Might be worth pursuing.
+  public static MessageEncoder getDefaultInstance(Configuration conf) {
+    String clazz =
+        MetastoreConf.get(conf, MetastoreConf.ConfVars.EVENT_MESSAGE_FACTORY.getVarname());
+    try {
+      Class<?> clazzObject = MessageFactory.class.getClassLoader().loadClass(clazz);
+      return (MessageEncoder) requiredMethod(clazzObject).invoke(null);
+    } catch (Exception e) {
+      String message = "could not load the configured class " + clazz;
+      LOG.error(message, e);
+      throw new IllegalStateException(message, e);
+    }
   }
-
-  public void init() throws MetaException {}
-
-  public abstract MessageDeserializer getDeserializer();
-
-  /**
-   * Getter for message-format.
-   */
-  public abstract String getMessageFormat();
-
-  /**
-   * Factory method for CreateDatabaseMessage.
-   * @param db The Database being added.
-   * @return CreateDatabaseMessage instance.
-   */
-  public abstract CreateDatabaseMessage buildCreateDatabaseMessage(Database db);
-
-  /**
-   * Factory method for AlterDatabaseMessage.
-   * @param beforeDb The Database before alter.
-   * @param afterDb The Database after alter.
-   * @return AlterDatabaseMessage instance.
-   */
-  public abstract AlterDatabaseMessage buildAlterDatabaseMessage(Database beforeDb, Database afterDb);
-
-  /**
-   * Factory method for DropDatabaseMessage.
-   * @param db The Database being dropped.
-   * @return DropDatabaseMessage instance.
-   */
-  public abstract DropDatabaseMessage buildDropDatabaseMessage(Database db);
-
-  /**
-   * Factory method for CreateTableMessage.
-   * @param table The Table being created.
-   * @param files Iterator of files
-   * @return CreateTableMessage instance.
-   */
-  public abstract CreateTableMessage buildCreateTableMessage(Table table, Iterator<String> files);
-
-  /**
-   * Factory method for AlterTableMessage.  Unlike most of these calls, this one can return null,
-   * which means no message should be sent.  This is because there are many flavors of alter
-   * table (add column, add partition, etc.).  Some are covered elsewhere (like add partition)
-   * and some are not yet supported.
-   * @param before The table before the alter
-   * @param after The table after the alter
-   * @param isTruncateOp Flag to denote truncate table
-   * @param writeId writeId under which alter is done (for ACID tables)
-   * @return
-   */
-  public abstract AlterTableMessage buildAlterTableMessage(Table before, Table after, boolean isTruncateOp,
-                                                           Long writeId);
-
-  /**
-   * Factory method for DropTableMessage.
-   * @param table The Table being dropped.
-   * @return DropTableMessage instance.
-   */
-  public abstract DropTableMessage buildDropTableMessage(Table table);
-
-    /**
-     * Factory method for AddPartitionMessage.
-     * @param table The Table to which the partitions are added.
-     * @param partitions The iterator to set of Partitions being added.
-     * @param partitionFiles The iterator of partition files
-     * @return AddPartitionMessage instance.
-     */
-  public abstract AddPartitionMessage buildAddPartitionMessage(Table table, Iterator<Partition> partitions,
-      Iterator<PartitionFiles> partitionFiles);
-
-  /**
-   * Factory method for building AlterPartitionMessage
-   * @param table The table in which the partition is being altered
-   * @param before The partition before it was altered
-   * @param after The partition after it was altered
-   * @param isTruncateOp Flag to denote truncate partition
-   * @param writeId writeId under which alter is done (for ACID tables)
-   * @return a new AlterPartitionMessage
-   */
-  public abstract AlterPartitionMessage buildAlterPartitionMessage(Table table, Partition before,
-                                                                   Partition after, boolean isTruncateOp,
-                                                                   Long writeId);
-
-  /**
-   * Factory method for DropPartitionMessage.
-   * @param table The Table from which the partition is dropped.
-   * @param partitions The set of partitions being dropped.
-   * @return DropPartitionMessage instance.
-   */
-  public abstract DropPartitionMessage buildDropPartitionMessage(Table table, Iterator<Partition> partitions);
-
-  /**
-   * Factory method for CreateFunctionMessage.
-   * @param fn The Function being added.
-   * @return CreateFunctionMessage instance.
-   */
-  public abstract CreateFunctionMessage buildCreateFunctionMessage(Function fn);
-
-  /**
-   * Factory method for DropFunctionMessage.
-   * @param fn The Function being dropped.
-   * @return DropFunctionMessage instance.
-   */
-  public abstract DropFunctionMessage buildDropFunctionMessage(Function fn);
-
-  /**
-   * Factory method for building insert message
-   *
-   * @param tableObj Table object where the insert occurred in
-   * @param ptnObj Partition object where the insert occurred in, may be null if
-   *          the insert was done into a non-partitioned table
-   * @param replace Flag to represent if INSERT OVERWRITE or INSERT INTO
-   * @param files Iterator of file created
-   * @return instance of InsertMessage
-   */
-  public abstract InsertMessage buildInsertMessage(Table tableObj, Partition ptnObj,
-                                                   boolean replace, Iterator<String> files);
-
-  /**
-   * Factory method for building open txn message using start and end transaction range
-   *
-   * @param fromTxnId start transaction id (inclusive)
-   * @param toTxnId end transaction id (inclusive)
-   * @return instance of OpenTxnMessage
-   */
-  public abstract OpenTxnMessage buildOpenTxnMessage(Long fromTxnId, Long toTxnId);
-
-  /**
-   * Factory method for building commit txn message
-   *
-   * @param txnId Id of the transaction to be committed
-   * @return instance of CommitTxnMessage
-   */
-  public abstract CommitTxnMessage buildCommitTxnMessage(Long txnId);
-
-  /**
-   * Factory method for building abort txn message
-   *
-   * @param txnId Id of the transaction to be aborted
-   * @return instance of AbortTxnMessage
-   */
-  public abstract AbortTxnMessage buildAbortTxnMessage(Long txnId);
-
-  /**
-   * Factory method for building alloc write id message
-   *
-   * @param txnToWriteIdList List of Txn Ids and write id map
-   * @param dbName db for which write ids to be allocated
-   * @param tableName table for which write ids to be allocated
-   * @return instance of AllocWriteIdMessage
-   */
-  public abstract AllocWriteIdMessage buildAllocWriteIdMessage(List<TxnToWriteId> txnToWriteIdList, String dbName,
-                                                               String tableName);
-
-  /***
-   * Factory method for building add primary key message
-   *
-   * @param pks list of primary keys
-   * @return instance of AddPrimaryKeyMessage
-   */
-  public abstract AddPrimaryKeyMessage buildAddPrimaryKeyMessage(List<SQLPrimaryKey> pks);
-
-  /***
-   * Factory method for building add foreign key message
-   *
-   * @param fks list of foreign keys
-   * @return instance of AddForeignKeyMessage
-   */
-  public abstract AddForeignKeyMessage buildAddForeignKeyMessage(List<SQLForeignKey> fks);
-
-  /***
-   * Factory method for building add unique constraint message
-   *
-   * @param uks list of unique constraints
-   * @return instance of SQLUniqueConstraint
-   */
-  public abstract AddUniqueConstraintMessage buildAddUniqueConstraintMessage(List<SQLUniqueConstraint> uks);
-
-  /***
-   * Factory method for building add not null constraint message
-   *
-   * @param nns list of not null constraints
-   * @return instance of SQLNotNullConstraint
-   */
-  public abstract AddNotNullConstraintMessage buildAddNotNullConstraintMessage(List<SQLNotNullConstraint> nns);
-
-  /***
-   * Factory method for building drop constraint message
-   * @param dbName
-   * @param tableName
-   * @param constraintName
-   * @return
-   */
-  public abstract DropConstraintMessage buildDropConstraintMessage(String dbName, String tableName,
-      String constraintName);
-
-  public abstract CreateCatalogMessage buildCreateCatalogMessage(Catalog catalog);
-
-  public abstract DropCatalogMessage buildDropCatalogMessage(Catalog catalog);
-
-  public abstract AlterCatalogMessage buildAlterCatalogMessage(Catalog oldCat, Catalog newCat);
-
-  /**
-   * Factory method for building acid write message
-   *
-   *
-   * @param acidWriteEvent information related to the acid write operation
-   * @param files files added by this write operation
-   * @return instance of AcidWriteMessage
-   */
-  public abstract AcidWriteMessage buildAcidWriteMessage(AcidWriteEvent acidWriteEvent, Iterator<String> files);
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageSerializer.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageSerializer.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageSerializer.java
new file mode 100644
index 0000000..b249d76
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageSerializer.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.messaging;
+
+public interface MessageSerializer {
+  default String serialize(EventMessage message) {
+    return message.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java
index fdb6942..712c12c 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/event/filters/DatabaseAndTableFilter.java
@@ -18,7 +18,7 @@
 package org.apache.hadoop.hive.metastore.messaging.event.filters;
 
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 
 import java.util.regex.Pattern;
 
@@ -41,9 +41,9 @@ public class DatabaseAndTableFilter extends BasicFilter {
   }
 
   private boolean isTxnRelatedEvent(final NotificationEvent event) {
-    return ((event.getEventType().equals(MessageFactory.OPEN_TXN_EVENT)) ||
-            (event.getEventType().equals(MessageFactory.COMMIT_TXN_EVENT)) ||
-            (event.getEventType().equals(MessageFactory.ABORT_TXN_EVENT)));
+    return ((event.getEventType().equals(MessageBuilder.OPEN_TXN_EVENT)) ||
+            (event.getEventType().equals(MessageBuilder.COMMIT_TXN_EVENT)) ||
+            (event.getEventType().equals(MessageBuilder.ABORT_TXN_EVENT)));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java
index cc528ee..a5d8f78 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAcidWriteMessage.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.events.AcidWriteEvent;
 import org.apache.hadoop.hive.metastore.messaging.AcidWriteMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 import java.util.Iterator;
 import java.util.List;
@@ -60,9 +61,9 @@ public class JSONAcidWriteMessage extends AcidWriteMessage {
     this.writeId = acidWriteEvent.getWriteId();
     this.partition = acidWriteEvent.getPartition();
     try {
-      this.tableObjJson = JSONMessageFactory.createTableObjJson(acidWriteEvent.getTableObj());
+      this.tableObjJson = MessageBuilder.createTableObjJson(acidWriteEvent.getTableObj());
       if (acidWriteEvent.getPartitionObj() != null) {
-        this.partitionObjJson = JSONMessageFactory.createPartitionObjJson(acidWriteEvent.getPartitionObj());
+        this.partitionObjJson = MessageBuilder.createPartitionObjJson(acidWriteEvent.getPartitionObj());
       } else {
         this.partitionObjJson = null;
       }
@@ -119,13 +120,13 @@ public class JSONAcidWriteMessage extends AcidWriteMessage {
 
   @Override
   public Table getTableObj() throws Exception {
-    return (tableObjJson == null) ? null : (Table) JSONMessageFactory.getTObj(tableObjJson, Table.class);
+    return (tableObjJson == null) ? null : (Table) MessageBuilder.getTObj(tableObjJson, Table.class);
   }
 
   @Override
   public Partition getPartitionObj() throws Exception {
     return ((partitionObjJson == null) ? null :
-            (Partition) JSONMessageFactory.getTObj(partitionObjJson, Partition.class));
+            (Partition) MessageBuilder.getTObj(partitionObjJson, Partition.class));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java
index d4a0bc2..c3d6fb6 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddForeignKeyMessage.java
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
 import org.apache.hadoop.hive.metastore.messaging.AddForeignKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -55,7 +56,7 @@ public class JSONAddForeignKeyMessage extends AddForeignKeyMessage {
     this.foreignKeyListJson = new ArrayList<>();
     try {
       for (SQLForeignKey pk : fks) {
-        foreignKeyListJson.add(JSONMessageFactory.createForeignKeyObjJson(pk));
+        foreignKeyListJson.add(MessageBuilder.createForeignKeyObjJson(pk));
       }
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
@@ -86,7 +87,7 @@ public class JSONAddForeignKeyMessage extends AddForeignKeyMessage {
   public List<SQLForeignKey> getForeignKeys() throws Exception {
     List<SQLForeignKey> fks = new ArrayList<>();
     for (String pkJson : foreignKeyListJson) {
-      fks.add((SQLForeignKey)JSONMessageFactory.getTObj(pkJson, SQLForeignKey.class));
+      fks.add((SQLForeignKey) MessageBuilder.getTObj(pkJson, SQLForeignKey.class));
     }
     return fks;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java
index 1c3e8a8..f9f351f 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddNotNullConstraintMessage.java
@@ -22,6 +22,7 @@ import java.util.List;
 
 import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
 import org.apache.hadoop.hive.metastore.messaging.AddNotNullConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -50,7 +51,7 @@ public class JSONAddNotNullConstraintMessage extends AddNotNullConstraintMessage
     this.notNullConstraintListJson = new ArrayList<>();
     try {
       for (SQLNotNullConstraint nn : nns) {
-        notNullConstraintListJson.add(JSONMessageFactory.createNotNullConstraintObjJson(nn));
+        notNullConstraintListJson.add(MessageBuilder.createNotNullConstraintObjJson(nn));
       }
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
@@ -81,7 +82,7 @@ public class JSONAddNotNullConstraintMessage extends AddNotNullConstraintMessage
   public List<SQLNotNullConstraint> getNotNullConstraints() throws Exception {
     List<SQLNotNullConstraint> nns = new ArrayList<>();
     for (String nnJson : notNullConstraintListJson) {
-      nns.add((SQLNotNullConstraint)JSONMessageFactory.getTObj(nnJson, SQLNotNullConstraint.class));
+      nns.add((SQLNotNullConstraint) MessageBuilder.getTObj(nnJson, SQLNotNullConstraint.class));
     }
     return nns;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java
index bb2093b..6494cb8 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java
@@ -29,6 +29,7 @@ import javax.annotation.Nullable;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.messaging.AddPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hadoop.hive.metastore.messaging.PartitionFiles;
 import org.apache.thrift.TException;
 
@@ -79,11 +80,11 @@ public class JSONAddPartitionMessage extends AddPartitionMessage {
     partitionListJson = new ArrayList<>();
     Partition partitionObj;
     try {
-      this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
+      this.tableObjJson = MessageBuilder.createTableObjJson(tableObj);
       while (partitionsIterator.hasNext()) {
         partitionObj = partitionsIterator.next();
-        partitions.add(JSONMessageFactory.getPartitionKeyValues(tableObj, partitionObj));
-        partitionListJson.add(JSONMessageFactory.createPartitionObjJson(partitionObj));
+        partitions.add(MessageBuilder.getPartitionKeyValues(tableObj, partitionObj));
+        partitionListJson.add(MessageBuilder.createPartitionObjJson(partitionObj));
       }
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
@@ -124,7 +125,7 @@ public class JSONAddPartitionMessage extends AddPartitionMessage {
 
   @Override
   public Table getTableObj() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjJson,Table.class);
   }
 
   @Override
@@ -141,7 +142,7 @@ public class JSONAddPartitionMessage extends AddPartitionMessage {
   public Iterable<Partition> getPartitionObjs() throws Exception {
     // glorified cast from Iterable<TBase> to Iterable<Partition>
     return Iterables.transform(
-        JSONMessageFactory.getTObjs(partitionListJson,Partition.class),
+        MessageBuilder.getTObjs(partitionListJson,Partition.class),
         new Function<Object, Partition>() {
       @Nullable
       @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java
index 3a18be8..606a051 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPrimaryKeyMessage.java
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
 import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -55,7 +56,7 @@ public class JSONAddPrimaryKeyMessage extends AddPrimaryKeyMessage {
     this.primaryKeyListJson = new ArrayList<>();
     try {
       for (SQLPrimaryKey pk : pks) {
-        primaryKeyListJson.add(JSONMessageFactory.createPrimaryKeyObjJson(pk));
+        primaryKeyListJson.add(MessageBuilder.createPrimaryKeyObjJson(pk));
       }
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
@@ -86,7 +87,7 @@ public class JSONAddPrimaryKeyMessage extends AddPrimaryKeyMessage {
   public List<SQLPrimaryKey> getPrimaryKeys() throws Exception {
     List<SQLPrimaryKey> pks = new ArrayList<>();
     for (String pkJson : primaryKeyListJson) {
-      pks.add((SQLPrimaryKey)JSONMessageFactory.getTObj(pkJson, SQLPrimaryKey.class));
+      pks.add((SQLPrimaryKey) MessageBuilder.getTObj(pkJson, SQLPrimaryKey.class));
     }
     return pks;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java
index 3c4d5e0..ebdcd94 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddUniqueConstraintMessage.java
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
 import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -52,7 +53,7 @@ public class JSONAddUniqueConstraintMessage extends AddUniqueConstraintMessage {
     this.uniqueConstraintListJson = new ArrayList<>();
     try {
       for (SQLUniqueConstraint uk : uks) {
-        uniqueConstraintListJson.add(JSONMessageFactory.createUniqueConstraintObjJson(uk));
+        uniqueConstraintListJson.add(MessageBuilder.createUniqueConstraintObjJson(uk));
       }
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
@@ -83,7 +84,7 @@ public class JSONAddUniqueConstraintMessage extends AddUniqueConstraintMessage {
   public List<SQLUniqueConstraint> getUniqueConstraints() throws Exception {
     List<SQLUniqueConstraint> uks = new ArrayList<>();
     for (String pkJson : uniqueConstraintListJson) {
-      uks.add((SQLUniqueConstraint)JSONMessageFactory.getTObj(pkJson, SQLUniqueConstraint.class));
+      uks.add((SQLUniqueConstraint) MessageBuilder.getTObj(pkJson, SQLUniqueConstraint.class));
     }
     return uks;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java
index 779c0b0..7b7c12e 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterCatalogMessage.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.metastore.messaging.json;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import org.apache.hadoop.hive.metastore.api.Catalog;
 import org.apache.hadoop.hive.metastore.messaging.AlterCatalogMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 public class JSONAlterCatalogMessage extends AlterCatalogMessage {
@@ -41,8 +42,8 @@ public class JSONAlterCatalogMessage extends AlterCatalogMessage {
     this.servicePrincipal = servicePrincipal;
     this.timestamp = timestamp;
     try {
-      this.catObjBeforeJson = JSONMessageFactory.createCatalogObjJson(catObjBefore);
-      this.catObjAfterJson = JSONMessageFactory.createCatalogObjJson(catObjAfter);
+      this.catObjBeforeJson = MessageBuilder.createCatalogObjJson(catObjBefore);
+      this.catObjAfterJson = MessageBuilder.createCatalogObjJson(catObjAfter);
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
     }
@@ -71,12 +72,12 @@ public class JSONAlterCatalogMessage extends AlterCatalogMessage {
 
   @Override
   public Catalog getCatObjBefore() throws Exception {
-    return (Catalog) JSONMessageFactory.getTObj(catObjBeforeJson, Catalog.class);
+    return (Catalog) MessageBuilder.getTObj(catObjBeforeJson, Catalog.class);
   }
 
   @Override
   public Catalog getCatObjAfter() throws Exception {
-    return (Catalog) JSONMessageFactory.getTObj(catObjAfterJson, Catalog.class);
+    return (Catalog) MessageBuilder.getTObj(catObjAfterJson, Catalog.class);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java
index 7b316d5..5f9dae4 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterDatabaseMessage.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.metastore.messaging.json;
 
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -48,8 +49,8 @@ public class JSONAlterDatabaseMessage extends AlterDatabaseMessage {
     this.db = dbObjBefore.getName();
     this.timestamp = timestamp;
     try {
-      this.dbObjBeforeJson = JSONMessageFactory.createDatabaseObjJson(dbObjBefore);
-      this.dbObjAfterJson = JSONMessageFactory.createDatabaseObjJson(dbObjAfter);
+      this.dbObjBeforeJson = MessageBuilder.createDatabaseObjJson(dbObjBefore);
+      this.dbObjAfterJson = MessageBuilder.createDatabaseObjJson(dbObjAfter);
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
     }
@@ -78,12 +79,12 @@ public class JSONAlterDatabaseMessage extends AlterDatabaseMessage {
 
   @Override
   public Database getDbObjBefore() throws Exception {
-    return (Database) JSONMessageFactory.getTObj(dbObjBeforeJson, Database.class);
+    return (Database) MessageBuilder.getTObj(dbObjBeforeJson, Database.class);
   }
 
   @Override
   public Database getDbObjAfter() throws Exception {
-    return (Database) JSONMessageFactory.getTObj(dbObjAfterJson, Database.class);
+    return (Database) MessageBuilder.getTObj(dbObjAfterJson, Database.class);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java
index 9b85f4c..a38c1aa 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -62,12 +63,12 @@ public class JSONAlterPartitionMessage extends AlterPartitionMessage {
     this.tableType = tableObj.getTableType();
     this.isTruncateOp = Boolean.toString(isTruncateOp);
     this.timestamp = timestamp;
-    this.keyValues = JSONMessageFactory.getPartitionKeyValues(tableObj, partitionObjBefore);
+    this.keyValues = MessageBuilder.getPartitionKeyValues(tableObj, partitionObjBefore);
     this.writeId = writeId;
     try {
-      this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
-      this.partitionObjBeforeJson = JSONMessageFactory.createPartitionObjJson(partitionObjBefore);
-      this.partitionObjAfterJson = JSONMessageFactory.createPartitionObjJson(partitionObjAfter);
+      this.tableObjJson = MessageBuilder.createTableObjJson(tableObj);
+      this.partitionObjBeforeJson = MessageBuilder.createPartitionObjJson(partitionObjBefore);
+      this.partitionObjAfterJson = MessageBuilder.createPartitionObjJson(partitionObjAfter);
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
     }
@@ -118,17 +119,17 @@ public class JSONAlterPartitionMessage extends AlterPartitionMessage {
 
   @Override
   public Table getTableObj() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjJson,Table.class);
   }
 
   @Override
   public Partition getPtnObjBefore() throws Exception {
-    return (Partition) JSONMessageFactory.getTObj(partitionObjBeforeJson, Partition.class);
+    return (Partition) MessageBuilder.getTObj(partitionObjBeforeJson, Partition.class);
   }
 
   @Override
   public Partition getPtnObjAfter() throws Exception {
-    return (Partition) JSONMessageFactory.getTObj(partitionObjAfterJson, Partition.class);
+    return (Partition) MessageBuilder.getTObj(partitionObjAfterJson, Partition.class);
   }
 
   public String getTableObjJson() {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java
index eddff98..d6ec826 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.metastore.messaging.json;
 
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.messaging.AlterTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -55,8 +56,8 @@ public class JSONAlterTableMessage extends AlterTableMessage {
     this.timestamp = timestamp;
     this.writeId = writeId;
     try {
-      this.tableObjBeforeJson = JSONMessageFactory.createTableObjJson(tableObjBefore);
-      this.tableObjAfterJson = JSONMessageFactory.createTableObjJson(tableObjAfter);
+      this.tableObjBeforeJson = MessageBuilder.createTableObjJson(tableObjBefore);
+      this.tableObjAfterJson = MessageBuilder.createTableObjJson(tableObjAfter);
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
     }
@@ -102,12 +103,12 @@ public class JSONAlterTableMessage extends AlterTableMessage {
 
   @Override
   public Table getTableObjBefore() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjBeforeJson,Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjBeforeJson,Table.class);
   }
 
   @Override
   public Table getTableObjAfter() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjAfterJson,Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjAfterJson,Table.class);
   }
 
   public String getTableObjBeforeJson() {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java
index 2c4940b..482fc8e 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCommitTxnMessage.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.metastore.api.WriteEventInfo;
 import org.apache.hadoop.hive.metastore.messaging.CommitTxnMessage;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 
 import java.util.List;
 
@@ -118,13 +119,13 @@ public class JSONCommitTxnMessage extends CommitTxnMessage {
 
   @Override
   public Table getTableObj(int idx) throws Exception {
-    return tableObjs == null ? null :  (Table) JSONMessageFactory.getTObj(tableObjs.get(idx), Table.class);
+    return tableObjs == null ? null :  (Table) MessageBuilder.getTObj(tableObjs.get(idx), Table.class);
   }
 
   @Override
   public Partition getPartitionObj(int idx) throws Exception {
     return (partitionObjs == null ? null : (partitionObjs.get(idx) == null ? null :
-            (Partition)JSONMessageFactory.getTObj(partitionObjs.get(idx), Partition.class)));
+            (Partition) MessageBuilder.getTObj(partitionObjs.get(idx), Partition.class)));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateDatabaseMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateDatabaseMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateDatabaseMessage.java
index 761ff99..1f5c9e8 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateDatabaseMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateDatabaseMessage.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.metastore.messaging.json;
 
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.messaging.CreateDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -48,7 +49,7 @@ public class JSONCreateDatabaseMessage extends CreateDatabaseMessage {
     this.db = db.getName();
     this.timestamp = timestamp;
     try {
-      this.dbJson = JSONMessageFactory.createDatabaseObjJson(db);
+      this.dbJson = MessageBuilder.createDatabaseObjJson(db);
     } catch (TException ex) {
       throw new IllegalArgumentException("Could not serialize Function object", ex);
     }
@@ -57,7 +58,7 @@ public class JSONCreateDatabaseMessage extends CreateDatabaseMessage {
 
   @Override
   public Database getDatabaseObject() throws Exception {
-    return (Database) JSONMessageFactory.getTObj(dbJson, Database.class);
+    return (Database) MessageBuilder.getTObj(dbJson, Database.class);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateFunctionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateFunctionMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateFunctionMessage.java
index f7287df..bb50052 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateFunctionMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateFunctionMessage.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.metastore.messaging.json;
 
 import org.apache.hadoop.hive.metastore.api.Function;
 import org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -47,7 +48,7 @@ public class JSONCreateFunctionMessage extends CreateFunctionMessage {
     this.db = fn.getDbName();
     this.timestamp = timestamp;
     try {
-      this.functionObjJson = JSONMessageFactory.createFunctionObjJson(fn);
+      this.functionObjJson = MessageBuilder.createFunctionObjJson(fn);
     } catch (TException ex) {
       throw new IllegalArgumentException("Could not serialize Function object", ex);
     }
@@ -72,7 +73,7 @@ public class JSONCreateFunctionMessage extends CreateFunctionMessage {
 
   @Override
   public Function getFunctionObj() throws Exception {
-    return (Function) JSONMessageFactory.getTObj(functionObjJson,Function.class);
+    return (Function) MessageBuilder.getTObj(functionObjJson,Function.class);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java
index b80003b..145ee4b 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.messaging.CreateTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.thrift.TException;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -68,7 +69,7 @@ public class JSONCreateTableMessage extends CreateTableMessage {
     this(server, servicePrincipal, tableObj.getDbName(), tableObj.getTableName(),
         tableObj.getTableType(), timestamp);
     try {
-      this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
+      this.tableObjJson = MessageBuilder.createTableObjJson(tableObj);
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
     }
@@ -111,7 +112,7 @@ public class JSONCreateTableMessage extends CreateTableMessage {
 
   @Override
   public Table getTableObj() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjJson,Table.class);
   }
 
   public String getTableObjJson() {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java
index 957d595..23e5496 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hadoop.hive.metastore.messaging.DropPartitionMessage;
 import org.apache.thrift.TException;
 
@@ -70,7 +71,7 @@ public class JSONDropPartitionMessage extends DropPartitionMessage {
     this(server, servicePrincipal, tableObj.getDbName(), tableObj.getTableName(),
         tableObj.getTableType(), partitionKeyValues, timestamp);
     try {
-      this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
+      this.tableObjJson = MessageBuilder.createTableObjJson(tableObj);
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
     }
@@ -117,7 +118,7 @@ public class JSONDropPartitionMessage extends DropPartitionMessage {
 
   @Override
   public Table getTableObj() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjJson, Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjJson, Table.class);
   }
 
   public String getTableObjJson() {

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java
index 88374ec..1ef2ad0 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java
@@ -20,6 +20,7 @@
 package org.apache.hadoop.hive.metastore.messaging.json;
 
 import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hadoop.hive.metastore.messaging.DropTableMessage;
 import org.apache.thrift.TException;
 
@@ -63,7 +64,7 @@ public class JSONDropTableMessage extends DropTableMessage {
     this(server, servicePrincipal, tableObj.getDbName(), tableObj.getTableName(),
         tableObj.getTableType(), timestamp);
     try {
-      this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
+      this.tableObjJson = MessageBuilder.createTableObjJson(tableObj);
     } catch (TException e) {
       throw new IllegalArgumentException("Could not serialize: ", e);
     }
@@ -86,7 +87,7 @@ public class JSONDropTableMessage extends DropTableMessage {
 
   @Override
   public Table getTableObj() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjJson,Table.class);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java
index 2318a67..40d480b 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hadoop.hive.metastore.messaging.InsertMessage;
 import org.apache.thrift.TException;
 
@@ -67,9 +68,9 @@ public class JSONInsertMessage extends InsertMessage {
     this.tableType = tableObj.getTableType();
 
     try {
-      this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj);
+      this.tableObjJson = MessageBuilder.createTableObjJson(tableObj);
       if (null != ptnObj) {
-        this.ptnObjJson = JSONMessageFactory.createPartitionObjJson(ptnObj);
+        this.ptnObjJson = MessageBuilder.createPartitionObjJson(ptnObj);
       } else {
         this.ptnObjJson = null;
       }
@@ -128,12 +129,12 @@ public class JSONInsertMessage extends InsertMessage {
 
   @Override
   public Table getTableObj() throws Exception {
-    return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class);
+    return (Table) MessageBuilder.getTObj(tableObjJson,Table.class);
   }
 
   @Override
   public Partition getPtnObj() throws Exception {
-    return ((null == ptnObjJson) ? null : (Partition) JSONMessageFactory.getTObj(ptnObjJson, Partition.class));
+    return ((null == ptnObjJson) ? null : (Partition) MessageBuilder.getTObj(ptnObjJson, Partition.class));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageEncoder.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageEncoder.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageEncoder.java
new file mode 100644
index 0000000..08c53e4
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageEncoder.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.messaging.json;
+
+import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
+import org.apache.hadoop.hive.metastore.messaging.MessageEncoder;
+import org.apache.hadoop.hive.metastore.messaging.MessageSerializer;
+import org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder;
+
+/**
+ * The JSON implementation of the MessageFactory. Constructs JSON implementations of each
+ * message-type.
+ */
+public class JSONMessageEncoder implements MessageEncoder {
+  public static final String FORMAT = "json-0.2";
+
+  private static MessageDeserializer deserializer = new JSONMessageDeserializer();
+  private static MessageSerializer serializer = new MessageSerializer() {
+  };
+
+  private static volatile MessageEncoder instance;
+
+  public static MessageEncoder getInstance() {
+    if (instance == null) {
+      synchronized (GzipJSONMessageEncoder.class) {
+        if (instance == null) {
+          instance = new JSONMessageEncoder();
+        }
+      }
+    }
+    return instance;
+  }
+
+  @Override
+  public MessageDeserializer getDeserializer() {
+    return deserializer;
+  }
+
+  @Override
+  public MessageSerializer getSerializer() {
+    return serializer;
+  }
+
+  /**
+   * This is a format that's shipped, for any changes make sure that backward compatibiltiy
+   * with existing messages in this format are taken care of.
+   *
+   */
+  @Override
+  public String getMessageFormat() {
+    return FORMAT;
+  }
+}


[18/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query39.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query39.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query39.q.out
new file mode 100644
index 0000000..812928b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query39.q.out
@@ -0,0 +1,236 @@
+PREHOOK: query: explain
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 3 <- Map 11 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (ONE_TO_ONE_EDGE), Reducer 9 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 8 <- Map 11 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_166]
+        Select Operator [SEL_165] (rows=859 width=56)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+        <-Reducer 5 [SIMPLE_EDGE]
+          SHUFFLE [RS_44]
+            Select Operator [SEL_43] (rows=859 width=48)
+              Output:["_col0","_col1","_col2","_col3","_col6","_col7"]
+              Merge Join Operator [MERGEJOIN_144] (rows=859 width=40)
+                Conds:RS_160._col0, _col1=RS_164._col0, _col1(Inner),Output:["_col0","_col1","_col2","_col3","_col6","_col7"]
+              <-Reducer 4 [ONE_TO_ONE_EDGE] vectorized
+                FORWARD [RS_160]
+                  PartitionCols:_col0, _col1
+                  Select Operator [SEL_159] (rows=859 width=24)
+                    Output:["_col0","_col1","_col2","_col3"]
+                    Filter Operator [FIL_158] (rows=859 width=40)
+                      predicate:CASE WHEN (((UDFToDouble(_col2) / _col3) = 0)) THEN (false) ELSE (((power(((_col4 - ((_col5 * _col5) / _col3)) / CASE WHEN ((_col3 = 1L)) THEN (null) ELSE ((_col3 - 1)) END), 0.5) / (UDFToDouble(_col2) / _col3)) > 1.0D)) END
+                      Group By Operator [GBY_157] (rows=1719 width=40)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0, KEY._col1
+                      <-Reducer 3 [SIMPLE_EDGE]
+                        SHUFFLE [RS_16]
+                          PartitionCols:_col0, _col1
+                          Group By Operator [GBY_15] (rows=1719 width=40)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col3)","count(_col3)","sum(_col5)","sum(_col4)"],keys:_col1, _col2
+                            Select Operator [SEL_13] (rows=1032514 width=8)
+                              Output:["_col1","_col2","_col3","_col4","_col5"]
+                              Merge Join Operator [MERGEJOIN_141] (rows=1032514 width=8)
+                                Conds:RS_10._col1=RS_155._col0(Inner),Output:["_col2","_col3","_col5"]
+                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_155]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_154] (rows=27 width=4)
+                                    Output:["_col0"]
+                                    TableScan [TS_5] (rows=27 width=4)
+                                      default@warehouse,warehouse,Tbl:COMPLETE,Col:COMPLETE,Output:["w_warehouse_sk"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_10]
+                                  PartitionCols:_col1
+                                  Merge Join Operator [MERGEJOIN_140] (rows=1032514 width=8)
+                                    Conds:RS_146._col0=RS_152._col0(Inner),Output:["_col1","_col2","_col3"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_146]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_145] (rows=37584000 width=15)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        TableScan [TS_0] (rows=37584000 width=15)
+                                          default@inventory,inventory,Tbl:COMPLETE,Col:COMPLETE,Output:["inv_date_sk","inv_item_sk","inv_warehouse_sk","inv_quantity_on_hand"]
+                                  <-Map 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_152]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_150] (rows=50 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_148] (rows=50 width=12)
+                                          predicate:((d_moy = 5) and (d_year = 1999))
+                                          TableScan [TS_2] (rows=73049 width=12)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+              <-Reducer 9 [ONE_TO_ONE_EDGE] vectorized
+                FORWARD [RS_164]
+                  PartitionCols:_col0, _col1
+                  Select Operator [SEL_163] (rows=859 width=24)
+                    Output:["_col0","_col1","_col2","_col3"]
+                    Filter Operator [FIL_162] (rows=859 width=40)
+                      predicate:CASE WHEN (((UDFToDouble(_col2) / _col3) = 0)) THEN (false) ELSE (((power(((_col4 - ((_col5 * _col5) / _col3)) / CASE WHEN ((_col3 = 1L)) THEN (null) ELSE ((_col3 - 1)) END), 0.5) / (UDFToDouble(_col2) / _col3)) > 1.0D)) END
+                      Group By Operator [GBY_161] (rows=1719 width=40)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0, KEY._col1
+                      <-Reducer 8 [SIMPLE_EDGE]
+                        SHUFFLE [RS_36]
+                          PartitionCols:_col0, _col1
+                          Group By Operator [GBY_35] (rows=1719 width=40)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col3)","count(_col3)","sum(_col5)","sum(_col4)"],keys:_col1, _col2
+                            Select Operator [SEL_33] (rows=1032514 width=8)
+                              Output:["_col1","_col2","_col3","_col4","_col5"]
+                              Merge Join Operator [MERGEJOIN_143] (rows=1032514 width=8)
+                                Conds:RS_30._col1=RS_156._col0(Inner),Output:["_col2","_col3","_col5"]
+                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_156]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select Operator [SEL_154]
+                              <-Reducer 7 [SIMPLE_EDGE]
+                                SHUFFLE [RS_30]
+                                  PartitionCols:_col1
+                                  Merge Join Operator [MERGEJOIN_142] (rows=1032514 width=8)
+                                    Conds:RS_147._col0=RS_153._col0(Inner),Output:["_col1","_col2","_col3"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_147]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select Operator [SEL_145]
+                                  <-Map 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_153]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_151] (rows=50 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_149] (rows=50 width=12)
+                                          predicate:((d_moy = 4) and (d_year = 1999))
+                                           Please refer to the previous TableScan [TS_2]
+
+PREHOOK: query: with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query4.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query4.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query4.q.out
new file mode 100644
index 0000000..7291c14
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query4.q.out
@@ -0,0 +1,623 @@
+PREHOOK: query: explain
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
+       ,'c' sale_type
+ from customer
+     ,catalog_sales
+     ,date_dim
+ where c_customer_sk = cs_bill_customer_sk
+   and cs_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.customer_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_c_firstyear
+     ,year_total t_c_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_c_secyear.customer_id
+   and t_s_firstyear.customer_id = t_c_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_secyear.customer_id
+   and t_s_firstyear.sale_type = 's'
+   and t_c_firstyear.sale_type = 'c'
+   and t_w_firstyear.sale_type = 'w'
+   and t_s_secyear.sale_type = 's'
+   and t_c_secyear.sale_type = 'c'
+   and t_w_secyear.sale_type = 'w'
+   and t_s_firstyear.dyear =  2001
+   and t_s_secyear.dyear = 2001+1
+   and t_c_firstyear.dyear =  2001
+   and t_c_secyear.dyear =  2001+1
+   and t_w_firstyear.dyear = 2001
+   and t_w_secyear.dyear = 2001+1
+   and t_s_firstyear.year_total > 0
+   and t_c_firstyear.year_total > 0
+   and t_w_firstyear.year_total > 0
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+ order by t_s_secyear.customer_preferred_cust_flag
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
+       ,'c' sale_type
+ from customer
+     ,catalog_sales
+     ,date_dim
+ where c_customer_sk = cs_bill_customer_sk
+   and cs_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.customer_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_c_firstyear
+     ,year_total t_c_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_c_secyear.customer_id
+   and t_s_firstyear.customer_id = t_c_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_secyear.customer_id
+   and t_s_firstyear.sale_type = 's'
+   and t_c_firstyear.sale_type = 'c'
+   and t_w_firstyear.sale_type = 'w'
+   and t_s_secyear.sale_type = 's'
+   and t_c_secyear.sale_type = 'c'
+   and t_w_secyear.sale_type = 'w'
+   and t_s_firstyear.dyear =  2001
+   and t_s_secyear.dyear = 2001+1
+   and t_c_firstyear.dyear =  2001
+   and t_c_secyear.dyear =  2001+1
+   and t_w_firstyear.dyear = 2001
+   and t_w_secyear.dyear = 2001+1
+   and t_s_firstyear.year_total > 0
+   and t_c_firstyear.year_total > 0
+   and t_w_firstyear.year_total > 0
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+ order by t_s_secyear.customer_preferred_cust_flag
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 34 (BROADCAST_EDGE)
+Map 11 <- Reducer 35 (BROADCAST_EDGE)
+Map 15 <- Reducer 36 (BROADCAST_EDGE)
+Map 19 <- Reducer 37 (BROADCAST_EDGE)
+Map 23 <- Reducer 33 (BROADCAST_EDGE)
+Map 27 <- Reducer 32 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (SIMPLE_EDGE), Map 31 (SIMPLE_EDGE)
+Reducer 13 <- Map 38 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE), Map 31 (SIMPLE_EDGE)
+Reducer 17 <- Map 38 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 31 (SIMPLE_EDGE)
+Reducer 20 <- Map 19 (SIMPLE_EDGE), Map 31 (SIMPLE_EDGE)
+Reducer 21 <- Map 38 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Reducer 21 (SIMPLE_EDGE)
+Reducer 24 <- Map 23 (SIMPLE_EDGE), Map 31 (SIMPLE_EDGE)
+Reducer 25 <- Map 38 (SIMPLE_EDGE), Reducer 24 (SIMPLE_EDGE)
+Reducer 26 <- Reducer 25 (SIMPLE_EDGE)
+Reducer 28 <- Map 27 (SIMPLE_EDGE), Map 31 (SIMPLE_EDGE)
+Reducer 29 <- Map 38 (SIMPLE_EDGE), Reducer 28 (SIMPLE_EDGE)
+Reducer 3 <- Map 38 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Reducer 29 (SIMPLE_EDGE)
+Reducer 32 <- Map 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 33 <- Map 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 34 <- Map 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 35 <- Map 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 36 <- Map 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 37 <- Map 31 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 14 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 18 (SIMPLE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 22 (SIMPLE_EDGE), Reducer 6 (ONE_TO_ONE_EDGE)
+Reducer 8 <- Reducer 26 (SIMPLE_EDGE), Reducer 7 (ONE_TO_ONE_EDGE)
+Reducer 9 <- Reducer 30 (SIMPLE_EDGE), Reducer 8 (ONE_TO_ONE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 10 vectorized
+      File Output Operator [FS_550]
+        Limit [LIM_549] (rows=100 width=85)
+          Number of rows:100
+          Select Operator [SEL_548] (rows=7323197 width=85)
+            Output:["_col0"]
+          <-Reducer 9 [SIMPLE_EDGE]
+            SHUFFLE [RS_135]
+              Select Operator [SEL_134] (rows=7323197 width=85)
+                Output:["_col0"]
+                Filter Operator [FIL_133] (rows=7323197 width=541)
+                  predicate:CASE WHEN (_col4) THEN (CASE WHEN (_col10) THEN (((_col12 / _col9) > (_col15 / _col3))) ELSE ((null > (_col15 / _col3))) END) ELSE (CASE WHEN (_col10) THEN (((_col12 / _col9) > null)) ELSE (null) END) END
+                  Merge Join Operator [MERGEJOIN_466] (rows=14646395 width=541)
+                    Conds:RS_130._col2=RS_547._col0(Inner),Output:["_col3","_col4","_col9","_col10","_col12","_col14","_col15"]
+                  <-Reducer 30 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_547]
+                      PartitionCols:_col0
+                      Select Operator [SEL_546] (rows=80000000 width=297)
+                        Output:["_col0","_col1","_col2"]
+                        Group By Operator [GBY_545] (rows=80000000 width=764)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                        <-Reducer 29 [SIMPLE_EDGE]
+                          SHUFFLE [RS_114]
+                            PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                            Group By Operator [GBY_113] (rows=80000000 width=764)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                              Merge Join Operator [MERGEJOIN_461] (rows=187573258 width=764)
+                                Conds:RS_109._col1=RS_503._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                              <-Map 38 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_503]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_502] (rows=80000000 width=656)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                    TableScan [TS_104] (rows=80000000 width=656)
+                                      default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_customer_id","c_first_name","c_last_name","c_preferred_cust_flag","c_birth_country","c_login","c_email_address"]
+                              <-Reducer 28 [SIMPLE_EDGE]
+                                SHUFFLE [RS_109]
+                                  PartitionCols:_col1
+                                  Merge Join Operator [MERGEJOIN_460] (rows=187573258 width=115)
+                                    Conds:RS_106._col0=RS_475._col0(Inner),Output:["_col1","_col2"]
+                                  <-Map 31 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_475]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_471] (rows=652 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_467] (rows=652 width=8)
+                                          predicate:(d_year = 2002)
+                                          TableScan [TS_101] (rows=73049 width=8)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                  <-Map 27 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_106]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_100] (rows=525327388 width=119)
+                                        Output:["_col0","_col1","_col2"]
+                                        Filter Operator [FIL_244] (rows=525327388 width=435)
+                                          predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_107_date_dim_d_date_sk_min) AND DynamicValue(RS_107_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_107_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                          TableScan [TS_98] (rows=575995635 width=435)
+                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_ext_discount_amt","ss_ext_sales_price","ss_ext_wholesale_cost","ss_ext_list_price"]
+                                          <-Reducer 32 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_543]
+                                              Group By Operator [GBY_542] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 31 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_493]
+                                                  Group By Operator [GBY_487] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_476] (rows=652 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_471]
+                  <-Reducer 8 [ONE_TO_ONE_EDGE]
+                    FORWARD [RS_130]
+                      PartitionCols:_col2
+                      Filter Operator [FIL_129] (rows=12248093 width=672)
+                        predicate:CASE WHEN (_col7) THEN (CASE WHEN (_col10) THEN (((_col12 / _col9) > (_col1 / _col6))) ELSE ((null > (_col1 / _col6))) END) ELSE (CASE WHEN (_col10) THEN (((_col12 / _col9) > null)) ELSE (null) END) END
+                        Merge Join Operator [MERGEJOIN_465] (rows=24496186 width=672)
+                          Conds:RS_126._col2=RS_541._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col6","_col7","_col9","_col10","_col12"]
+                        <-Reducer 26 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_541]
+                            PartitionCols:_col0
+                            Select Operator [SEL_540] (rows=80000000 width=212)
+                              Output:["_col0","_col1"]
+                              Group By Operator [GBY_539] (rows=80000000 width=764)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                              <-Reducer 25 [SIMPLE_EDGE]
+                                SHUFFLE [RS_95]
+                                  PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                  Group By Operator [GBY_94] (rows=80000000 width=764)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                    Merge Join Operator [MERGEJOIN_459] (rows=101084444 width=764)
+                                      Conds:RS_90._col1=RS_504._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                    <-Map 38 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_504]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_502]
+                                    <-Reducer 24 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_90]
+                                        PartitionCols:_col1
+                                        Merge Join Operator [MERGEJOIN_458] (rows=101084444 width=115)
+                                          Conds:RS_87._col0=RS_477._col0(Inner),Output:["_col1","_col2"]
+                                        <-Map 31 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_477]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_471]
+                                        <-Map 23 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_87]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_81] (rows=285117831 width=119)
+                                              Output:["_col0","_col1","_col2"]
+                                              Filter Operator [FIL_241] (rows=285117831 width=453)
+                                                predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_88_date_dim_d_date_sk_min) AND DynamicValue(RS_88_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_88_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                                TableScan [TS_79] (rows=287989836 width=453)
+                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_ext_discount_amt","cs_ext_sales_price","cs_ext_wholesale_cost","cs_ext_list_price"]
+                                                <-Reducer 33 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_537]
+                                                    Group By Operator [GBY_536] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 31 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_494]
+                                                        Group By Operator [GBY_488] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_478] (rows=652 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_471]
+                        <-Reducer 7 [ONE_TO_ONE_EDGE]
+                          FORWARD [RS_126]
+                            PartitionCols:_col2
+                            Merge Join Operator [MERGEJOIN_464] (rows=20485011 width=560)
+                              Conds:RS_123._col2=RS_535._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col6","_col7","_col9","_col10"]
+                            <-Reducer 22 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_535]
+                                PartitionCols:_col0
+                                Select Operator [SEL_534] (rows=26666666 width=216)
+                                  Output:["_col0","_col1","_col2"]
+                                  Filter Operator [FIL_533] (rows=26666666 width=212)
+                                    predicate:(_col7 > 0)
+                                    Select Operator [SEL_532] (rows=80000000 width=212)
+                                      Output:["_col0","_col7"]
+                                      Group By Operator [GBY_531] (rows=80000000 width=764)
+                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                                      <-Reducer 21 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_75]
+                                          PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                          Group By Operator [GBY_74] (rows=80000000 width=764)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                            Merge Join Operator [MERGEJOIN_457] (rows=101084444 width=764)
+                                              Conds:RS_70._col1=RS_508._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                            <-Map 38 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_508]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_502]
+                                            <-Reducer 20 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_70]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_456] (rows=101084444 width=115)
+                                                  Conds:RS_67._col0=RS_485._col0(Inner),Output:["_col1","_col2"]
+                                                <-Map 31 [SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_485]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_474] (rows=652 width=4)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_470] (rows=652 width=8)
+                                                        predicate:(d_year = 2001)
+                                                         Please refer to the previous TableScan [TS_101]
+                                                <-Map 19 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_67]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_61] (rows=285117831 width=119)
+                                                      Output:["_col0","_col1","_col2"]
+                                                      Filter Operator [FIL_238] (rows=285117831 width=453)
+                                                        predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_68_date_dim_d_date_sk_min) AND DynamicValue(RS_68_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_68_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                                        TableScan [TS_59] (rows=287989836 width=453)
+                                                          default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_ext_discount_amt","cs_ext_sales_price","cs_ext_wholesale_cost","cs_ext_list_price"]
+                                                        <-Reducer 37 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_529]
+                                                            Group By Operator [GBY_528] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 31 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              PARTITION_ONLY_SHUFFLE [RS_498]
+                                                                Group By Operator [GBY_492] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_486] (rows=652 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_474]
+                            <-Reducer 6 [ONE_TO_ONE_EDGE]
+                              FORWARD [RS_123]
+                                PartitionCols:_col2
+                                Merge Join Operator [MERGEJOIN_463] (rows=20485011 width=444)
+                                  Conds:RS_120._col2=RS_527._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col6","_col7"]
+                                <-Reducer 18 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_527]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_526] (rows=17130654 width=216)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_525] (rows=17130654 width=212)
+                                        predicate:(_col7 > 0)
+                                        Select Operator [SEL_524] (rows=51391963 width=212)
+                                          Output:["_col0","_col7"]
+                                          Group By Operator [GBY_523] (rows=51391963 width=764)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                                          <-Reducer 17 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_55]
+                                              PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                              Group By Operator [GBY_54] (rows=51391963 width=764)
+                                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                                Merge Join Operator [MERGEJOIN_455] (rows=51391963 width=764)
+                                                  Conds:RS_50._col1=RS_507._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                                <-Map 38 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_507]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_502]
+                                                <-Reducer 16 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_50]
+                                                    PartitionCols:_col1
+                                                    Merge Join Operator [MERGEJOIN_454] (rows=51391963 width=115)
+                                                      Conds:RS_47._col0=RS_483._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 31 [SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_483]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_473] (rows=652 width=4)
+                                                          Output:["_col0"]
+                                                          Filter Operator [FIL_469] (rows=652 width=8)
+                                                            predicate:(d_year = 2001)
+                                                             Please refer to the previous TableScan [TS_101]
+                                                    <-Map 15 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_47]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_41] (rows=143930993 width=119)
+                                                          Output:["_col0","_col1","_col2"]
+                                                          Filter Operator [FIL_235] (rows=143930993 width=455)
+                                                            predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_48_date_dim_d_date_sk_min) AND DynamicValue(RS_48_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_48_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                            TableScan [TS_39] (rows=144002668 width=455)
+                                                              default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk","ws_ext_discount_amt","ws_ext_sales_price","ws_ext_wholesale_cost","ws_ext_list_price"]
+                                                            <-Reducer 36 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_521]
+                                                                Group By Operator [GBY_520] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 31 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_497]
+                                                                    Group By Operator [GBY_491] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_484] (rows=652 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_473]
+                                <-Reducer 5 [ONE_TO_ONE_EDGE]
+                                  FORWARD [RS_120]
+                                    PartitionCols:_col2
+                                    Merge Join Operator [MERGEJOIN_462] (rows=31888273 width=328)
+                                      Conds:RS_511._col0=RS_519._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                    <-Reducer 14 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_519]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_518] (rows=26666666 width=216)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_517] (rows=26666666 width=212)
+                                            predicate:(_col7 > 0)
+                                            Select Operator [SEL_516] (rows=80000000 width=212)
+                                              Output:["_col0","_col7"]
+                                              Group By Operator [GBY_515] (rows=80000000 width=764)
+                                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                                              <-Reducer 13 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_35]
+                                                  PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                                  Group By Operator [GBY_34] (rows=80000000 width=764)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                                    Merge Join Operator [MERGEJOIN_453] (rows=187573258 width=764)
+                                                      Conds:RS_30._col1=RS_506._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                                    <-Map 38 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_506]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_502]
+                                                    <-Reducer 12 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_30]
+                                                        PartitionCols:_col1
+                                                        Merge Join Operator [MERGEJOIN_452] (rows=187573258 width=115)
+                                                          Conds:RS_27._col0=RS_481._col0(Inner),Output:["_col1","_col2"]
+                                                        <-Map 31 [SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_481]
+                                                            PartitionCols:_col0
+                                                            Select Operator [SEL_472] (rows=652 width=4)
+                                                              Output:["_col0"]
+                                                              Filter Operator [FIL_468] (rows=652 width=8)
+                                                                predicate:(d_year = 2001)
+                                                                 Please refer to the previous TableScan [TS_101]
+                                                        <-Map 11 [SIMPLE_EDGE]
+                                                          SHUFFLE [RS_27]
+                                                            PartitionCols:_col0
+                                                            Select Operator [SEL_21] (rows=525327388 width=119)
+                                                              Output:["_col0","_col1","_col2"]
+                                                              Filter Operator [FIL_232] (rows=525327388 width=435)
+                                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_28_date_dim_d_date_sk_min) AND DynamicValue(RS_28_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_28_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                                TableScan [TS_19] (rows=575995635 width=435)
+                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_ext_discount_amt","ss_ext_sales_price","ss_ext_wholesale_cost","ss_ext_list_price"]
+                                                                <-Reducer 35 [BROADCAST_EDGE] vectorized
+                                                                  BROADCAST [RS_513]
+                                                                    Group By Operator [GBY_512] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                    <-Map 31 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                      PARTITION_ONLY_SHUFFLE [RS_496]
+                                                                        Group By Operator [GBY_490] (rows=1 width=12)
+                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                          Select Operator [SEL_482] (rows=652 width=4)
+                                                                            Output:["_col0"]
+                                                                             Please refer to the previous Select Operator [SEL_472]
+                                    <-Reducer 4 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_511]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_510] (rows=51391963 width=212)
+                                          Output:["_col0","_col1"]
+                                          Group By Operator [GBY_509] (rows=51391963 width=764)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                                          <-Reducer 3 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_16]
+                                              PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                              Group By Operator [GBY_15] (rows=51391963 width=764)
+                                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                                Merge Join Operator [MERGEJOIN_451] (rows=51391963 width=764)
+                                                  Conds:RS_11._col1=RS_505._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                                <-Map 38 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_505]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_502]
+                                                <-Reducer 2 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_11]
+                                                    PartitionCols:_col1
+                                                    Merge Join Operator [MERGEJOIN_450] (rows=51391963 width=115)
+                                                      Conds:RS_8._col0=RS_479._col0(Inner),Output:["_col1","_col2"]
+                                                    <-Map 31 [SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_479]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_471]
+                                                    <-Map 1 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_8]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_2] (rows=143930993 width=119)
+                                                          Output:["_col0","_col1","_col2"]
+                                                          Filter Operator [FIL_229] (rows=143930993 width=455)
+                                                            predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_9_date_dim_d_date_sk_min) AND DynamicValue(RS_9_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_9_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                            TableScan [TS_0] (rows=144002668 width=455)
+                                                              default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk","ws_ext_discount_amt","ws_ext_sales_price","ws_ext_wholesale_cost","ws_ext_list_price"]
+                                                            <-Reducer 34 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_500]
+                                                                Group By Operator [GBY_499] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 31 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_495]
+                                                                    Group By Operator [GBY_489] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_480] (rows=652 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_471]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query40.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query40.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query40.q.out
new file mode 100644
index 0000000..c05256f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query40.q.out
@@ -0,0 +1,183 @@
+PREHOOK: query: explain
+select  
+   w_state
+  ,i_item_id
+  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
+  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
+ from
+   catalog_sales left outer join catalog_returns on
+       (cs_order_number = cr_order_number 
+        and cs_item_sk = cr_item_sk)
+  ,warehouse 
+  ,item
+  ,date_dim
+ where
+     i_current_price between 0.99 and 1.49
+ and i_item_sk          = cs_item_sk
+ and cs_warehouse_sk    = w_warehouse_sk 
+ and cs_sold_date_sk    = d_date_sk
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
+ group by
+    w_state,i_item_id
+ order by w_state,i_item_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+   w_state
+  ,i_item_id
+  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
+  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
+ from
+   catalog_sales left outer join catalog_returns on
+       (cs_order_number = cr_order_number 
+        and cs_item_sk = cr_item_sk)
+  ,warehouse 
+  ,item
+  ,date_dim
+ where
+     i_current_price between 0.99 and 1.49
+ and i_item_sk          = cs_item_sk
+ and cs_warehouse_sk    = w_warehouse_sk 
+ and cs_sold_date_sk    = d_date_sk
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
+ group by
+    w_state,i_item_id
+ order by w_state,i_item_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 12 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 9 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 11 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 13 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_127]
+        Limit [LIM_126] (rows=100 width=410)
+          Number of rows:100
+          Select Operator [SEL_125] (rows=769995 width=410)
+            Output:["_col0","_col1","_col2","_col3"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_124]
+              Group By Operator [GBY_123] (rows=769995 width=410)
+                Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1
+              <-Reducer 5 [SIMPLE_EDGE]
+                SHUFFLE [RS_28]
+                  PartitionCols:_col0, _col1
+                  Group By Operator [GBY_27] (rows=5757278 width=410)
+                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)","sum(_col3)"],keys:_col0, _col1
+                    Top N Key Operator [TNK_53] (rows=5757278 width=278)
+                      keys:_col0, _col1,sort order:++,top n:100
+                      Select Operator [SEL_25] (rows=5757278 width=278)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Merge Join Operator [MERGEJOIN_99] (rows=5757278 width=278)
+                          Conds:RS_22._col1=RS_122._col0(Inner),Output:["_col4","_col7","_col9","_col10","_col12","_col14"]
+                        <-Map 13 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_122]
+                            PartitionCols:_col0
+                            Select Operator [SEL_121] (rows=27 width=90)
+                              Output:["_col0","_col1"]
+                              TableScan [TS_11] (rows=27 width=90)
+                                default@warehouse,warehouse,Tbl:COMPLETE,Col:COMPLETE,Output:["w_warehouse_sk","w_state"]
+                        <-Reducer 4 [SIMPLE_EDGE]
+                          SHUFFLE [RS_22]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_98] (rows=5757278 width=195)
+                              Conds:RS_19._col2=RS_110._col0(Inner),Output:["_col1","_col4","_col7","_col9","_col10","_col12"]
+                            <-Map 11 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_110]
+                                PartitionCols:_col0
+                                Select Operator [SEL_109] (rows=51333 width=104)
+                                  Output:["_col0","_col1"]
+                                  Filter Operator [FIL_108] (rows=51333 width=215)
+                                    predicate:i_current_price BETWEEN 0.99 AND 1.49
+                                    TableScan [TS_8] (rows=462000 width=215)
+                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_current_price"]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_19]
+                                PartitionCols:_col2
+                                Merge Join Operator [MERGEJOIN_97] (rows=51815831 width=124)
+                                  Conds:RS_16._col0=RS_102._col0(Inner),Output:["_col1","_col2","_col4","_col7","_col9","_col10"]
+                                <-Map 9 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_102]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_101] (rows=8116 width=12)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_100] (rows=8116 width=98)
+                                        predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-03-09 00:00:00' AND TIMESTAMP'1998-05-08 00:00:00'
+                                        TableScan [TS_5] (rows=73049 width=98)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_16]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_96] (rows=466374405 width=167)
+                                      Conds:RS_118._col2, _col3=RS_120._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col4","_col7"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_118]
+                                        PartitionCols:_col2, _col3
+                                        Select Operator [SEL_117] (rows=285115816 width=127)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                          Filter Operator [FIL_116] (rows=285115816 width=127)
+                                            predicate:((cs_item_sk BETWEEN DynamicValue(RS_20_item_i_item_sk_min) AND DynamicValue(RS_20_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_20_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_17_date_dim_d_date_sk_min) AND DynamicValue(RS_17_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_17_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null and cs_warehouse_sk is not null)
+                                            TableScan [TS_0] (rows=287989836 width=127)
+                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_warehouse_sk","cs_item_sk","cs_order_number","cs_sales_price"]
+                                            <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_107]
+                                                Group By Operator [GBY_106] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_105]
+                                                    Group By Operator [GBY_104] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_103] (rows=8116 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_101]
+                                            <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_115]
+                                                Group By Operator [GBY_114] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_113]
+                                                    Group By Operator [GBY_112] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_111] (rows=51333 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_109]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_120]
+                                        PartitionCols:_col0, _col1
+                                        Select Operator [SEL_119] (rows=28798881 width=117)
+                                          Output:["_col0","_col1","_col2"]
+                                          TableScan [TS_3] (rows=28798881 width=117)
+                                            default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_item_sk","cr_order_number","cr_refunded_cash"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query42.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query42.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query42.q.out
new file mode 100644
index 0000000..02b9f7c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query42.q.out
@@ -0,0 +1,139 @@
+PREHOOK: query: explain
+select  dt.d_year
+ 	,item.i_category_id
+ 	,item.i_category
+ 	,sum(ss_ext_sales_price)
+ 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_manager_id = 1  	
+ 	and dt.d_moy=12
+ 	and dt.d_year=1998
+ group by 	dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  dt.d_year
+ 	,item.i_category_id
+ 	,item.i_category
+ 	,sum(ss_ext_sales_price)
+ 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_manager_id = 1  	
+ 	and dt.d_moy=12
+ 	and dt.d_year=1998
+ group by 	dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 7 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Map 8 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_79]
+        Limit [LIM_78] (rows=100 width=210)
+          Number of rows:100
+          Select Operator [SEL_77] (rows=110 width=210)
+            Output:["_col0","_col1","_col2","_col3"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_76]
+              Select Operator [SEL_75] (rows=110 width=318)
+                Output:["_col0","_col1","_col3"]
+                Group By Operator [GBY_74] (rows=110 width=206)
+                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                <-Reducer 3 [SIMPLE_EDGE]
+                  SHUFFLE [RS_17]
+                    PartitionCols:_col0, _col1
+                    Group By Operator [GBY_16] (rows=120 width=206)
+                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)"],keys:_col5, _col6
+                      Merge Join Operator [MERGEJOIN_54] (rows=2301098 width=94)
+                        Conds:RS_12._col1=RS_65._col0(Inner),Output:["_col2","_col5","_col6"]
+                      <-Map 8 [SIMPLE_EDGE] vectorized
+                        PARTITION_ONLY_SHUFFLE [RS_65]
+                          PartitionCols:_col0
+                          Select Operator [SEL_64] (rows=7333 width=97)
+                            Output:["_col0","_col1","_col2"]
+                            Filter Operator [FIL_63] (rows=7333 width=101)
+                              predicate:(i_manager_id = 1)
+                              TableScan [TS_6] (rows=462000 width=101)
+                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_category_id","i_category","i_manager_id"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_12]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_53] (rows=15062131 width=4)
+                            Conds:RS_73._col0=RS_57._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_57]
+                              PartitionCols:_col0
+                              Select Operator [SEL_56] (rows=50 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_55] (rows=50 width=12)
+                                  predicate:((d_moy = 12) and (d_year = 1998))
+                                  TableScan [TS_3] (rows=73049 width=12)
+                                    default@date_dim,dt,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_73]
+                              PartitionCols:_col0
+                              Select Operator [SEL_72] (rows=550076554 width=114)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_71] (rows=550076554 width=114)
+                                  predicate:((ss_item_sk BETWEEN DynamicValue(RS_13_item_i_item_sk_min) AND DynamicValue(RS_13_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_13_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_10_dt_d_date_sk_min) AND DynamicValue(RS_10_dt_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_10_dt_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                  TableScan [TS_0] (rows=575995635 width=114)
+                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
+                                  <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_62]
+                                      Group By Operator [GBY_61] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_60]
+                                          Group By Operator [GBY_59] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_58] (rows=50 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_56]
+                                  <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_70]
+                                      Group By Operator [GBY_69] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_68]
+                                          Group By Operator [GBY_67] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_66] (rows=7333 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_64]
+


[27/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query90.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query90.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query90.q.out
new file mode 100644
index 0000000..ff28da1
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query90.q.out
@@ -0,0 +1,92 @@
+Warning: Shuffle Join MERGEJOIN[152][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
+PREHOOK: query: explain cbo
+select  cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio
+ from ( select count(*) amc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 6 and 6+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) at,
+      ( select count(*) pmc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 14 and 14+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) pt
+ order by am_pm_ratio
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio
+ from ( select count(*) amc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 6 and 6+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) at,
+      ( select count(*) pmc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 14 and 14+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) pt
+ order by am_pm_ratio
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(am_pm_ratio=[/($0, $1)])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(CAST=[CAST($0):DECIMAL(15, 4)])
+        HiveAggregate(group=[{}], agg#0=[count()])
+          HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_time_sk=[$1], ws_ship_hdemo_sk=[$10], ws_web_page_sk=[$12])
+                  HiveFilter(condition=[AND(IS NOT NULL($10), IS NOT NULL($1), IS NOT NULL($12))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(wp_web_page_sk=[$0])
+                  HiveFilter(condition=[BETWEEN(false, $10, 5000, 5200)])
+                    HiveTableScan(table=[[default, web_page]], table:alias=[web_page])
+              HiveProject(t_time_sk=[$0])
+                HiveFilter(condition=[BETWEEN(false, $3, 6, 7)])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(hd_demo_sk=[$0])
+              HiveFilter(condition=[=($3, 8)])
+                HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+      HiveProject(CAST=[CAST($0):DECIMAL(15, 4)])
+        HiveAggregate(group=[{}], agg#0=[count()])
+          HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_time_sk=[$1], ws_ship_hdemo_sk=[$10], ws_web_page_sk=[$12])
+                  HiveFilter(condition=[AND(IS NOT NULL($10), IS NOT NULL($1), IS NOT NULL($12))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(wp_web_page_sk=[$0])
+                  HiveFilter(condition=[BETWEEN(false, $10, 5000, 5200)])
+                    HiveTableScan(table=[[default, web_page]], table:alias=[web_page])
+              HiveProject(t_time_sk=[$0])
+                HiveFilter(condition=[BETWEEN(false, $3, 14, 15)])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(hd_demo_sk=[$0])
+              HiveFilter(condition=[=($3, 8)])
+                HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query91.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query91.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query91.q.out
new file mode 100644
index 0000000..046a374
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query91.q.out
@@ -0,0 +1,109 @@
+PREHOOK: query: explain cbo
+select  
+        cc_call_center_id Call_Center,
+        cc_name Call_Center_Name,
+        cc_manager Manager,
+        sum(cr_net_loss) Returns_Loss
+from
+        call_center,
+        catalog_returns,
+        date_dim,
+        customer,
+        customer_address,
+        customer_demographics,
+        household_demographics
+where
+        cr_call_center_sk       = cc_call_center_sk
+and     cr_returned_date_sk     = d_date_sk
+and     cr_returning_customer_sk= c_customer_sk
+and     cd_demo_sk              = c_current_cdemo_sk
+and     hd_demo_sk              = c_current_hdemo_sk
+and     ca_address_sk           = c_current_addr_sk
+and     d_year                  = 1999 
+and     d_moy                   = 11
+and     ( (cd_marital_status       = 'M' and cd_education_status     = 'Unknown')
+        or(cd_marital_status       = 'W' and cd_education_status     = 'Advanced Degree'))
+and     hd_buy_potential like '0-500%'
+and     ca_gmt_offset           = -7
+group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status
+order by sum(cr_net_loss) desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+        cc_call_center_id Call_Center,
+        cc_name Call_Center_Name,
+        cc_manager Manager,
+        sum(cr_net_loss) Returns_Loss
+from
+        call_center,
+        catalog_returns,
+        date_dim,
+        customer,
+        customer_address,
+        customer_demographics,
+        household_demographics
+where
+        cr_call_center_sk       = cc_call_center_sk
+and     cr_returned_date_sk     = d_date_sk
+and     cr_returning_customer_sk= c_customer_sk
+and     cd_demo_sk              = c_current_cdemo_sk
+and     hd_demo_sk              = c_current_hdemo_sk
+and     ca_address_sk           = c_current_addr_sk
+and     d_year                  = 1999 
+and     d_moy                   = 11
+and     ( (cd_marital_status       = 'M' and cd_education_status     = 'Unknown')
+        or(cd_marital_status       = 'W' and cd_education_status     = 'Advanced Degree'))
+and     hd_buy_potential like '0-500%'
+and     ca_gmt_offset           = -7
+group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status
+order by sum(cr_net_loss) desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(call_center=[$0], call_center_name=[$1], manager=[$2], returns_loss=[$3])
+  HiveSortLimit(sort0=[$4], dir0=[DESC-nulls-last])
+    HiveProject(call_center=[$2], call_center_name=[$3], manager=[$4], returns_loss=[$5], (tok_function sum (tok_table_or_col cr_net_loss))=[$5])
+      HiveAggregate(group=[{6, 7, 14, 15, 16}], agg#0=[sum($11)])
+        HiveJoin(condition=[=($17, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($9, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0])
+                HiveFilter(condition=[=($11, -7)])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($4, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4])
+                  HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2), IS NOT NULL($3))])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
+                  HiveFilter(condition=[AND(IN($3, _UTF-16LE'Unknown', _UTF-16LE'Advanced Degree'), IN($2, _UTF-16LE'M', _UTF-16LE'W'), IN(ROW($2, $3), ROW(_UTF-16LE'M', _UTF-16LE'Unknown'), ROW(_UTF-16LE'W', _UTF-16LE'Advanced Degree')))])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+            HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$1], cr_call_center_sk=[$2], cr_net_loss=[$3], d_date_sk=[$4], cc_call_center_sk=[$5], cc_call_center_id=[$6], cc_name=[$7], cc_manager=[$8])
+              HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$7], cr_call_center_sk=[$11], cr_net_loss=[$26])
+                    HiveFilter(condition=[AND(IS NOT NULL($11), IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($6, 1999), =($8, 11))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(cc_call_center_sk=[$0], cc_call_center_id=[$1], cc_name=[$6], cc_manager=[$11])
+                  HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+          HiveProject(hd_demo_sk=[$0])
+            HiveFilter(condition=[LIKE($2, _UTF-16LE'0-500%')])
+              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query92.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query92.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query92.q.out
new file mode 100644
index 0000000..16098d7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query92.q.out
@@ -0,0 +1,94 @@
+PREHOOK: query: explain cbo
+select  
+   sum(ws_ext_discount_amt)  as `Excess Discount Amount` 
+from 
+    web_sales 
+   ,item 
+   ,date_dim
+where
+i_manufact_id = 269
+and i_item_sk = ws_item_sk 
+and d_date between '1998-03-18' and 
+        (cast('1998-03-18' as date) + 90 days)
+and d_date_sk = ws_sold_date_sk 
+and ws_ext_discount_amt  
+     > ( 
+         SELECT 
+            1.3 * avg(ws_ext_discount_amt) 
+         FROM 
+            web_sales 
+           ,date_dim
+         WHERE 
+              ws_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 = ws_sold_date_sk 
+      ) 
+order by sum(ws_ext_discount_amt)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   sum(ws_ext_discount_amt)  as `Excess Discount Amount` 
+from 
+    web_sales 
+   ,item 
+   ,date_dim
+where
+i_manufact_id = 269
+and i_item_sk = ws_item_sk 
+and d_date between '1998-03-18' and 
+        (cast('1998-03-18' as date) + 90 days)
+and d_date_sk = ws_sold_date_sk 
+and ws_ext_discount_amt  
+     > ( 
+         SELECT 
+            1.3 * avg(ws_ext_discount_amt) 
+         FROM 
+            web_sales 
+           ,date_dim
+         WHERE 
+              ws_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 = ws_sold_date_sk 
+      ) 
+order by sum(ws_ext_discount_amt)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(excess discount amount=[$0])
+  HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+    HiveProject(excess discount amount=[$0], (tok_function sum (tok_table_or_col ws_ext_discount_amt))=[$0])
+      HiveAggregate(group=[{}], agg#0=[sum($2)])
+        HiveJoin(condition=[AND(>($2, $5), =($6, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_discount_amt=[$22])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(ws_item_sk=[$0], CAST3=[$1], i_item_sk=[$2])
+            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ws_item_sk=[$0], CAST3=[CAST(*(1.3, /($1, $2))):DECIMAL(14, 7)])
+                HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_discount_amt=[$22])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(i_item_sk=[$0])
+                HiveFilter(condition=[=($13, 269)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query93.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query93.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query93.q.out
new file mode 100644
index 0000000..4902320
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query93.q.out
@@ -0,0 +1,58 @@
+PREHOOK: query: explain cbo
+select  ss_customer_sk
+            ,sum(act_sales) sumsales
+      from (select ss_item_sk
+                  ,ss_ticket_number
+                  ,ss_customer_sk
+                  ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price
+                                                            else (ss_quantity*ss_sales_price) end act_sales
+            from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk
+                                                               and sr_ticket_number = ss_ticket_number)
+                ,reason
+            where sr_reason_sk = r_reason_sk
+              and r_reason_desc = 'Did not like the warranty') t
+      group by ss_customer_sk
+      order by sumsales, ss_customer_sk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@reason
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  ss_customer_sk
+            ,sum(act_sales) sumsales
+      from (select ss_item_sk
+                  ,ss_ticket_number
+                  ,ss_customer_sk
+                  ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price
+                                                            else (ss_quantity*ss_sales_price) end act_sales
+            from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk
+                                                               and sr_ticket_number = ss_ticket_number)
+                ,reason
+            where sr_reason_sk = r_reason_sk
+              and r_reason_desc = 'Did not like the warranty') t
+      group by ss_customer_sk
+      order by sumsales, ss_customer_sk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@reason
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], sort1=[$0], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(ss_customer_sk=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(ss_customer_sk=[$1], act_sales=[CASE(IS NOT NULL($8), *(CAST(-($3, $8)):DECIMAL(10, 0), $4), *(CAST($3):DECIMAL(10, 0), $4))])
+        HiveJoin(condition=[AND(=($5, $0), =($7, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_ticket_number=[$9], ss_quantity=[$10], ss_sales_price=[$13])
+            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(sr_item_sk=[$2], sr_reason_sk=[$8], sr_ticket_number=[$9], sr_return_quantity=[$10])
+              HiveFilter(condition=[IS NOT NULL($8)])
+                HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+            HiveProject(r_reason_sk=[$0])
+              HiveFilter(condition=[=($2, _UTF-16LE'Did not like the warranty')])
+                HiveTableScan(table=[[default, reason]], table:alias=[reason])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query94.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query94.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query94.q.out
new file mode 100644
index 0000000..198778f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query94.q.out
@@ -0,0 +1,98 @@
+PREHOOK: query: explain cbo
+select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and exists (select *
+            from web_sales ws2
+            where ws1.ws_order_number = ws2.ws_order_number
+              and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+and not exists(select *
+               from web_returns wr1
+               where ws1.ws_order_number = wr1.wr_order_number)
+order by count(distinct ws_order_number)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and exists (select *
+            from web_sales ws2
+            where ws1.ws_order_number = ws2.ws_order_number
+              and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+and not exists(select *
+               from web_returns wr1
+               where ws1.ws_order_number = wr1.wr_order_number)
+order by count(distinct ws_order_number)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2])
+  HiveSortLimit(sort0=[$3], dir0=[ASC], fetch=[100])
+    HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2], (tok_functiondi count (tok_table_or_col ws_order_number))=[$0])
+      HiveAggregate(group=[{}], agg#0=[count(DISTINCT $4)], agg#1=[sum($5)], agg#2=[sum($6)])
+        HiveFilter(condition=[IS NULL($14)])
+          HiveJoin(condition=[=($4, $13)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveSemiJoin(condition=[AND(<>($3, $13), =($4, $14))], joinType=[inner])
+              HiveProject(ws_ship_date_sk=[$2], ws_ship_addr_sk=[$3], ws_web_site_sk=[$4], ws_warehouse_sk=[$5], ws_order_number=[$6], ws_ext_ship_cost=[$7], ws_net_profit=[$8], d_date_sk=[$9], d_date=[$10], ca_address_sk=[$0], ca_state=[$1], web_site_sk=[$11], web_company_name=[$12])
+                HiveJoin(condition=[=($4, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_state=[CAST(_UTF-16LE'TX'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[=($8, _UTF-16LE'TX')])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_ship_date_sk=[$2], ws_ship_addr_sk=[$11], ws_web_site_sk=[$13], ws_warehouse_sk=[$15], ws_order_number=[$17], ws_ext_ship_cost=[$28], ws_net_profit=[$33])
+                        HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($11), IS NOT NULL($13))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1999-05-01 00:00:00, 1999-06-30 00:00:00)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(web_site_sk=[$0], web_company_name=[CAST(_UTF-16LE'pri'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                    HiveFilter(condition=[=($14, _UTF-16LE'pri')])
+                      HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+              HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                HiveFilter(condition=[IS NOT NULL($15)])
+                  HiveTableScan(table=[[default, web_sales]], table:alias=[ws2])
+            HiveProject(wr_order_number0=[$13], $f1=[true])
+              HiveTableScan(table=[[default, web_returns]], table:alias=[wr1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query95.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query95.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query95.q.out
new file mode 100644
index 0000000..0546f1c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query95.q.out
@@ -0,0 +1,112 @@
+PREHOOK: query: explain cbo
+with ws_wh as
+(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2
+ from web_sales ws1,web_sales ws2
+ where ws1.ws_order_number = ws2.ws_order_number
+   and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+ select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and ws1.ws_order_number in (select ws_order_number
+                            from ws_wh)
+and ws1.ws_order_number in (select wr_order_number
+                            from web_returns,ws_wh
+                            where wr_order_number = ws_wh.ws_order_number)
+order by count(distinct ws_order_number)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ws_wh as
+(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2
+ from web_sales ws1,web_sales ws2
+ where ws1.ws_order_number = ws2.ws_order_number
+   and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+ select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and ws1.ws_order_number in (select ws_order_number
+                            from ws_wh)
+and ws1.ws_order_number in (select wr_order_number
+                            from web_returns,ws_wh
+                            where wr_order_number = ws_wh.ws_order_number)
+order by count(distinct ws_order_number)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2])
+  HiveSortLimit(sort0=[$3], dir0=[ASC], fetch=[100])
+    HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2], (tok_functiondi count (tok_table_or_col ws_order_number))=[$0])
+      HiveAggregate(group=[{}], agg#0=[count(DISTINCT $6)], agg#1=[sum($7)], agg#2=[sum($8)])
+        HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(wr_order_number=[$14])
+            HiveJoin(condition=[=($14, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ws_order_number=[$1])
+                HiveJoin(condition=[AND(=($1, $3), <>($0, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                  HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[ws2])
+              HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ws_order_number=[$1])
+              HiveJoin(condition=[AND(=($1, $3), <>($0, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                  HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                HiveProject(ws_warehouse_sk=[$15], ws_order_number=[$17])
+                  HiveTableScan(table=[[default, web_sales]], table:alias=[ws2])
+            HiveJoin(condition=[=($3, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0])
+                  HiveFilter(condition=[=($8, _UTF-16LE'TX')])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_ship_date_sk=[$2], ws_ship_addr_sk=[$11], ws_web_site_sk=[$13], ws_order_number=[$17], ws_ext_ship_cost=[$28], ws_net_profit=[$33])
+                    HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($11), IS NOT NULL($13))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1999-05-01 00:00:00, 1999-06-30 00:00:00)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(web_site_sk=[$0])
+                HiveFilter(condition=[=($14, _UTF-16LE'pri')])
+                  HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query96.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query96.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query96.q.out
new file mode 100644
index 0000000..e32705a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query96.q.out
@@ -0,0 +1,61 @@
+PREHOOK: query: explain cbo
+select  count(*) 
+from store_sales
+    ,household_demographics 
+    ,time_dim, store
+where ss_sold_time_sk = time_dim.t_time_sk   
+    and ss_hdemo_sk = household_demographics.hd_demo_sk 
+    and ss_store_sk = s_store_sk
+    and time_dim.t_hour = 8
+    and time_dim.t_minute >= 30
+    and household_demographics.hd_dep_count = 5
+    and store.s_store_name = 'ese'
+order by count(*)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  count(*) 
+from store_sales
+    ,household_demographics 
+    ,time_dim, store
+where ss_sold_time_sk = time_dim.t_time_sk   
+    and ss_hdemo_sk = household_demographics.hd_demo_sk 
+    and ss_store_sk = s_store_sk
+    and time_dim.t_hour = 8
+    and time_dim.t_minute >= 30
+    and household_demographics.hd_dep_count = 5
+    and store.s_store_name = 'ese'
+order by count(*)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(_o__c0=[$0])
+  HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+    HiveProject(_o__c0=[$0], (tok_functionstar count)=[$0])
+      HiveAggregate(group=[{}], agg#0=[count()])
+        HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(t_time_sk=[$0])
+                HiveFilter(condition=[AND(=($3, 8), >=($4, 30))])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(hd_demo_sk=[$0])
+              HiveFilter(condition=[=($3, 5)])
+                HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+          HiveProject(s_store_sk=[$0])
+            HiveFilter(condition=[=($5, _UTF-16LE'ese')])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query97.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query97.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query97.q.out
new file mode 100644
index 0000000..6151627
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query97.q.out
@@ -0,0 +1,81 @@
+PREHOOK: query: explain cbo
+with ssci as (
+select ss_customer_sk customer_sk
+      ,ss_item_sk item_sk
+from store_sales,date_dim
+where ss_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by ss_customer_sk
+        ,ss_item_sk),
+csci as(
+ select cs_bill_customer_sk customer_sk
+      ,cs_item_sk item_sk
+from catalog_sales,date_dim
+where cs_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by cs_bill_customer_sk
+        ,cs_item_sk)
+ select  sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
+      ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
+      ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
+from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk
+                               and ssci.item_sk = csci.item_sk)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssci as (
+select ss_customer_sk customer_sk
+      ,ss_item_sk item_sk
+from store_sales,date_dim
+where ss_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by ss_customer_sk
+        ,ss_item_sk),
+csci as(
+ select cs_bill_customer_sk customer_sk
+      ,cs_item_sk item_sk
+from catalog_sales,date_dim
+where cs_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by cs_bill_customer_sk
+        ,cs_item_sk)
+ select  sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
+      ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
+      ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
+from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk
+                               and ssci.item_sk = csci.item_sk)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+    HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[sum($1)], agg#2=[sum($2)])
+      HiveProject($f0=[CASE(AND(IS NOT NULL($0), IS NULL($2)), 1, 0)], $f1=[CASE(AND(IS NULL($0), IS NOT NULL($2)), 1, 0)], $f2=[CASE(AND(IS NOT NULL($0), IS NOT NULL($2)), 1, 0)])
+        HiveJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[full], algorithm=[none], cost=[not available])
+          HiveProject(ss_customer_sk=[$1], ss_item_sk=[$0])
+            HiveAggregate(group=[{1, 2}])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(cs_bill_customer_sk=[$0], cs_item_sk=[$1])
+            HiveAggregate(group=[{1, 2}])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query98.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query98.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query98.q.out
new file mode 100644
index 0000000..2a6b66f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query98.q.out
@@ -0,0 +1,87 @@
+PREHOOK: query: explain cbo
+select i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ss_ext_sales_price) as itemrevenue 
+      ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	store_sales
+    	,item 
+    	,date_dim
+where 
+	ss_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ss_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ss_ext_sales_price) as itemrevenue 
+      ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	store_sales
+    	,item 
+    	,date_dim
+where 
+	ss_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ss_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3], itemrevenue=[$4], revenueratio=[$5])
+  HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$6], sort3=[$0], sort4=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC])
+    HiveProject(i_item_desc=[$1], i_category=[$4], i_class=[$3], i_current_price=[$2], itemrevenue=[$5], revenueratio=[/(*($5, CAST(100):DECIMAL(10, 0)), sum($5) OVER (PARTITION BY $3 ORDER BY $3 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING))], (tok_table_or_col i_item_id)=[$0])
+      HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
+            HiveFilter(condition=[IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books')])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-01-12 00:00:00, 2001-02-11 00:00:00)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query99.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query99.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query99.q.out
new file mode 100644
index 0000000..2dccdf2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query99.q.out
@@ -0,0 +1,102 @@
+PREHOOK: query: explain cbo
+select  
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and
+                 (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   catalog_sales
+  ,warehouse
+  ,ship_mode
+  ,call_center
+  ,date_dim
+where
+    d_month_seq between 1212 and 1212 + 11
+and cs_ship_date_sk   = d_date_sk
+and cs_warehouse_sk   = w_warehouse_sk
+and cs_ship_mode_sk   = sm_ship_mode_sk
+and cs_call_center_sk = cc_call_center_sk
+group by
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+order by substr(w_warehouse_name,1,20)
+        ,sm_type
+        ,cc_name
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@ship_mode
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and
+                 (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   catalog_sales
+  ,warehouse
+  ,ship_mode
+  ,call_center
+  ,date_dim
+where
+    d_month_seq between 1212 and 1212 + 11
+and cs_ship_date_sk   = d_date_sk
+and cs_warehouse_sk   = w_warehouse_sk
+and cs_ship_mode_sk   = sm_ship_mode_sk
+and cs_call_center_sk = cc_call_center_sk
+group by
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+order by substr(w_warehouse_name,1,20)
+        ,sm_type
+        ,cc_name
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@ship_mode
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(_o__c0=[$0], sm_type=[$1], cc_name=[$2], 30 days=[$3], 31-60 days=[$4], 61-90 days=[$5], 91-120 days=[$6], >120 days=[$7])
+  HiveSortLimit(sort0=[$8], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(_o__c0=[$2], sm_type=[$0], cc_name=[$1], 30 days=[$3], 31-60 days=[$4], 61-90 days=[$5], 91-120 days=[$6], >120 days=[$7], (tok_function substr (tok_table_or_col w_warehouse_name) 1 20)=[$2])
+      HiveAggregate(group=[{11, 13, 15}], agg#0=[sum($4)], agg#1=[sum($5)], agg#2=[sum($6)], agg#3=[sum($7)], agg#4=[sum($8)])
+        HiveJoin(condition=[=($3, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($1, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_ship_date_sk=[$2], cs_call_center_sk=[$11], cs_ship_mode_sk=[$13], cs_warehouse_sk=[$14], CASE=[CASE(<=(-($2, $0), 30), 1, 0)], CASE5=[CASE(AND(>(-($2, $0), 30), <=(-($2, $0), 60)), 1, 0)], CASE6=[CASE(AND(>(-($2, $0), 60), <=(-($2, $0), 90)), 1, 0)], CASE7=[CASE(AND(>(-($2, $0), 90), <=(-($2, $0), 120)), 1, 0)], CASE8=[CASE(>(-($2, $0), 120), 1, 0)])
+                  HiveFilter(condition=[AND(IS NOT NULL($14), IS NOT NULL($13), IS NOT NULL($11), IS NOT NULL($2))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(sm_ship_mode_sk=[$0], sm_type=[$2])
+                HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
+            HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+              HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+          HiveProject(w_warehouse_sk=[$0], substr=[substr($2, 1, 20)])
+            HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query1.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query1.q.out
new file mode 100644
index 0000000..69f9329
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query1.q.out
@@ -0,0 +1,177 @@
+PREHOOK: query: explain
+with customer_total_return as
+(select sr_customer_sk as ctr_customer_sk
+,sr_store_sk as ctr_store_sk
+,sum(SR_FEE) as ctr_total_return
+from store_returns
+,date_dim
+where sr_returned_date_sk = d_date_sk
+and d_year =2000
+group by sr_customer_sk
+,sr_store_sk)
+ select  c_customer_id
+from customer_total_return ctr1
+,store
+,customer
+where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+from customer_total_return ctr2
+where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
+and s_store_sk = ctr1.ctr_store_sk
+and s_state = 'NM'
+and ctr1.ctr_customer_sk = c_customer_sk
+order by c_customer_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with customer_total_return as
+(select sr_customer_sk as ctr_customer_sk
+,sr_store_sk as ctr_store_sk
+,sum(SR_FEE) as ctr_total_return
+from store_returns
+,date_dim
+where sr_returned_date_sk = d_date_sk
+and d_year =2000
+group by sr_customer_sk
+,sr_store_sk)
+ select  c_customer_id
+from customer_total_return ctr1
+,store
+,customer
+where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+from customer_total_return ctr2
+where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
+and s_store_sk = ctr1.ctr_store_sk
+and s_state = 'NM'
+and ctr1.ctr_customer_sk = c_customer_sk
+order by c_customer_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 11 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 12 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_159]
+        Limit [LIM_158] (rows=100 width=100)
+          Number of rows:100
+          Select Operator [SEL_157] (rows=816091 width=100)
+            Output:["_col0"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_49]
+              Select Operator [SEL_48] (rows=816091 width=100)
+                Output:["_col0"]
+                Filter Operator [FIL_47] (rows=816091 width=324)
+                  predicate:(_col2 > _col6)
+                  Merge Join Operator [MERGEJOIN_133] (rows=2448274 width=324)
+                    Conds:RS_44._col1=RS_156._col1(Inner),Output:["_col2","_col5","_col6"]
+                  <-Reducer 5 [SIMPLE_EDGE]
+                    SHUFFLE [RS_44]
+                      PartitionCols:_col1
+                      Merge Join Operator [MERGEJOIN_131] (rows=2369298 width=213)
+                        Conds:RS_41._col0=RS_151._col0(Inner),Output:["_col1","_col2","_col5"]
+                      <-Map 12 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_151]
+                          PartitionCols:_col0
+                          Select Operator [SEL_150] (rows=80000000 width=104)
+                            Output:["_col0","_col1"]
+                            TableScan [TS_17] (rows=80000000 width=104)
+                              default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_customer_id"]
+                      <-Reducer 4 [SIMPLE_EDGE]
+                        SHUFFLE [RS_41]
+                          PartitionCols:_col0
+                          Merge Join Operator [MERGEJOIN_130] (rows=2369298 width=114)
+                            Conds:RS_146._col1=RS_149._col0(Inner),Output:["_col0","_col1","_col2"]
+                          <-Map 11 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_149]
+                              PartitionCols:_col0
+                              Select Operator [SEL_148] (rows=35 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_147] (rows=35 width=90)
+                                  predicate:(s_state = 'NM')
+                                  TableScan [TS_14] (rows=1704 width=90)
+                                    default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
+                          <-Reducer 3 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_146]
+                              PartitionCols:_col1
+                              Select Operator [SEL_145] (rows=14291868 width=119)
+                                Output:["_col0","_col1","_col2"]
+                                Group By Operator [GBY_144] (rows=14291868 width=119)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_11]
+                                    PartitionCols:_col0, _col1
+                                    Group By Operator [GBY_10] (rows=16855704 width=119)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col2, _col1
+                                      Merge Join Operator [MERGEJOIN_129] (rows=16855704 width=107)
+                                        Conds:RS_138._col0=RS_142._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_138]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_136] (rows=51757026 width=119)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_134] (rows=51757026 width=119)
+                                              predicate:(sr_customer_sk is not null and sr_returned_date_sk is not null and sr_store_sk is not null)
+                                              TableScan [TS_0] (rows=57591150 width=119)
+                                                default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_returned_date_sk","sr_customer_sk","sr_store_sk","sr_fee"]
+                                      <-Map 10 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_142]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_141] (rows=652 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_140] (rows=652 width=8)
+                                              predicate:(d_year = 2000)
+                                              TableScan [TS_3] (rows=73049 width=8)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                  <-Reducer 9 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_156]
+                      PartitionCols:_col1
+                      Select Operator [SEL_155] (rows=31 width=115)
+                        Output:["_col0","_col1"]
+                        Group By Operator [GBY_154] (rows=31 width=123)
+                          Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","count(_col2)"],keys:_col1
+                          Select Operator [SEL_153] (rows=14291868 width=119)
+                            Output:["_col1","_col2"]
+                            Group By Operator [GBY_152] (rows=14291868 width=119)
+                              Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                            <-Reducer 8 [SIMPLE_EDGE]
+                              SHUFFLE [RS_30]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_29] (rows=17467258 width=119)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col2, _col1
+                                  Merge Join Operator [MERGEJOIN_132] (rows=17467258 width=107)
+                                    Conds:RS_139._col0=RS_143._col0(Inner),Output:["_col1","_col2","_col3"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_139]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_137] (rows=53634860 width=119)
+                                        Output:["_col0","_col1","_col2","_col3"]
+                                        Filter Operator [FIL_135] (rows=53634860 width=119)
+                                          predicate:(sr_returned_date_sk is not null and sr_store_sk is not null)
+                                           Please refer to the previous TableScan [TS_0]
+                                  <-Map 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_143]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select Operator [SEL_141]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query10.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query10.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query10.q.out
new file mode 100644
index 0000000..3fbd928
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query10.q.out
@@ -0,0 +1,379 @@
+PREHOOK: query: explain
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2002 and
+                d_moy between 4 and 4+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 ANd 4+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 and 4+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2002 and
+                d_moy between 4 and 4+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 ANd 4+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 and 4+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 14 <- Reducer 11 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Map 24 <- Reducer 10 (BROADCAST_EDGE), Reducer 20 (BROADCAST_EDGE)
+Map 25 <- Reducer 23 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Reducer 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Map 16 (SIMPLE_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 16 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 20 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 21 <- Map 16 (SIMPLE_EDGE), Map 25 (SIMPLE_EDGE)
+Reducer 22 <- Reducer 21 (SIMPLE_EDGE)
+Reducer 23 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 13 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 15 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 19 (ONE_TO_ONE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 22 (ONE_TO_ONE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 5 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_235]
+        Limit [LIM_234] (rows=1 width=419)
+          Number of rows:100
+          Select Operator [SEL_233] (rows=1 width=419)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+          <-Reducer 7 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_232]
+              Select Operator [SEL_231] (rows=1 width=419)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col6","_col8","_col10","_col12"]
+                Group By Operator [GBY_230] (rows=1 width=379)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7
+                <-Reducer 6 [SIMPLE_EDGE]
+                  SHUFFLE [RS_66]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7
+                    Group By Operator [GBY_65] (rows=1 width=379)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["count()"],keys:_col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13
+                      Top N Key Operator [TNK_102] (rows=58 width=379)
+                        keys:_col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13,sort order:++++++++,top n:100
+                        Select Operator [SEL_64] (rows=58 width=379)
+                          Output:["_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                          Filter Operator [FIL_63] (rows=58 width=379)
+                            predicate:(_col15 is not null or _col17 is not null)
+                            Merge Join Operator [MERGEJOIN_180] (rows=58 width=379)
+                              Conds:RS_60._col0=RS_229._col0(Left Outer),Output:["_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col15","_col17"]
+                            <-Reducer 5 [ONE_TO_ONE_EDGE]
+                              PARTITION_ONLY_SHUFFLE [RS_60]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_179] (rows=58 width=379)
+                                  Conds:RS_57._col0=RS_219._col0(Left Outer),Output:["_col0","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col15"]
+                                <-Reducer 4 [ONE_TO_ONE_EDGE]
+                                  FORWARD [RS_57]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_178] (rows=7792 width=375)
+                                      Conds:RS_54._col0=RS_55._col0(Left Semi),Output:["_col0","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                                    <-Reducer 3 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_54]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_174] (rows=3914656 width=375)
+                                          Conds:RS_49._col1=RS_188._col0(Inner),Output:["_col0","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                                        <-Map 13 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_188]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_187] (rows=1861800 width=375)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                              TableScan [TS_6] (rows=1861800 width=375)
+                                                default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status","cd_purchase_estimate","cd_credit_rating","cd_dep_count","cd_dep_employed_count","cd_dep_college_count"]
+                                        <-Reducer 2 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_49]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_173] (rows=3860070 width=5)
+                                              Conds:RS_183._col2=RS_186._col0(Inner),Output:["_col0","_col1"]
+                                            <-Map 1 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_183]
+                                                PartitionCols:_col2
+                                                Select Operator [SEL_182] (rows=77201384 width=11)
+                                                  Output:["_col0","_col1","_col2"]
+                                                  Filter Operator [FIL_181] (rows=77201384 width=11)
+                                                    predicate:(c_current_addr_sk is not null and c_current_cdemo_sk is not null)
+                                                    TableScan [TS_0] (rows=80000000 width=11)
+                                                      default@customer,c,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk"]
+                                            <-Map 12 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_186]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_185] (rows=2000000 width=102)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_184] (rows=2000000 width=102)
+                                                    predicate:(ca_county) IN ('Walker County', 'Richland County', 'Gaines County', 'Douglas County', 'Dona Ana County')
+                                                    TableScan [TS_3] (rows=40000000 width=102)
+                                                      default@customer_address,ca,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_county"]
+                                    <-Reducer 15 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_55]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_53] (rows=155827 width=2)
+                                          Output:["_col0"],keys:_col0
+                                          Select Operator [SEL_17] (rows=57825495 width=2)
+                                            Output:["_col0"]
+                                            Merge Join Operator [MERGEJOIN_175] (rows=57825495 width=2)
+                                              Conds:RS_209._col0=RS_191._col0(Inner),Output:["_col1"]
+                                            <-Map 16 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_191]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_190] (rows=201 width=4)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_189] (rows=201 width=12)
+                                                    predicate:((d_year = 2002) and d_moy BETWEEN 4 AND 7)
+                                                    TableScan [TS_11] (rows=73049 width=12)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                            <-Map 14 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_209]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_208] (rows=525327388 width=7)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_207] (rows=525327388 width=7)
+                                                    predicate:((ss_customer_sk BETWEEN DynamicValue(RS_54_c_c_customer_sk_min) AND DynamicValue(RS_54_c_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_54_c_c_customer_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                    TableScan [TS_8] (rows=575995635 width=7)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk"]
+                                                    <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_206]
+                                                        Group By Operator [GBY_205] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=3647763)"]
+                                                        <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+                                                          SHUFFLE [RS_135]
+                                                            Group By Operator [GBY_134] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=3647763)"]
+                                                              Select Operator [SEL_133] (rows=3914656 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_174]
+                                                    <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_204]
+                                                        Group By Operator [GBY_203] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_200]
+                                                            Group By Operator [GBY_197] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_192] (rows=201 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_190]
+                                <-Reducer 19 [ONE_TO_ONE_EDGE] vectorized
+                                  FORWARD [RS_219]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_218] (rows=155827 width=7)
+                                      Output:["_col0","_col1"]
+                                      Group By Operator [GBY_217] (rows=155827 width=3)
+                                        Output:["_col0"],keys:KEY._col0
+                                      <-Reducer 18 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_29]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_28] (rows=155827 width=3)
+                                            Output:["_col0"],keys:_col1
+                                            Merge Join Operator [MERGEJOIN_176] (rows=15843227 width=3)
+                                              Conds:RS_216._col0=RS_193._col0(Inner),Output:["_col1"]
+                                            <-Map 16 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_193]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_190]
+                                            <-Map 24 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_216]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_215] (rows=143930993 width=7)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_214] (rows=143930993 width=7)
+                                                    predicate:((ws_bill_customer_sk BETWEEN DynamicValue(RS_57_c_c_customer_sk_min) AND DynamicValue(RS_57_c_c_customer_sk_max) and in_bloom_filter(ws_bill_customer_sk, DynamicValue(RS_57_c_c_customer_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_25_date_dim_d_date_sk_min) AND DynamicValue(RS_25_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_25_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                    TableScan [TS_18] (rows=144002668 width=7)
+                                                      default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk"]
+                                                    <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_213]
+                                                        Group By Operator [GBY_212] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                                          FORWARD [RS_150]
+                                                            Group By Operator [GBY_149] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_148] (rows=7792 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_178]
+                                                    <-Reducer 20 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_211]
+                                                        Group By Operator [GBY_210] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_201]
+                                                            Group By Operator [GBY_198] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_194] (rows=201 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_190]
+                            <-Reducer 22 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_229]
+                                PartitionCols:_col0
+                                Select Operator [SEL_228] (rows=154725 width=7)
+                                  Output:["_col0","_col1"]
+                                  Group By Operator [GBY_227] (rows=154725 width=3)
+                                    Output:["_col0"],keys:KEY._col0
+                                  <-Reducer 21 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_43]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_42] (rows=154725 width=3)
+                                        Output:["_col0"],keys:_col1
+                                        Merge Join Operator [MERGEJOIN_177] (rows=31162251 width=3)
+                                          Conds:RS_226._col0=RS_195._col0(Inner),Output:["_col1"]
+                                        <-Map 16 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_195]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_190]
+                                        <-Map 25 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_226]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_225] (rows=285115246 width=7)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_224] (rows=285115246 width=7)
+                                                predicate:((cs_ship_customer_sk BETWEEN DynamicValue(RS_60_c_c_customer_sk_min) AND DynamicValue(RS_60_c_c_customer_sk_max) and in_bloom_filter(cs_ship_customer_sk, DynamicValue(RS_60_c_c_customer_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_39_date_dim_d_date_sk_min) AND DynamicValue(RS_39_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_39_date_dim_d_date_sk_bloom_filter))) and cs_ship_customer_sk is not null and cs_sold_date_sk is not null)
+                                                TableScan [TS_32] (rows=287989836 width=7)
+                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_ship_customer_sk"]
+                                                <-Reducer 23 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_221]
+                                                    Group By Operator [GBY_220] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_202]
+                                                        Group By Operator [GBY_199] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_196] (rows=201 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_190]
+                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_223]
+                                                    Group By Operator [GBY_222] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_165]
+                                                        Group By Operator [GBY_164] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_163] (rows=58 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_179]
+


[50/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/itests/src/test/resources/testconfiguration.properties
----------------------------------------------------------------------
diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties
index ff9f758..da2091a 100644
--- a/itests/src/test/resources/testconfiguration.properties
+++ b/itests/src/test/resources/testconfiguration.properties
@@ -1732,7 +1732,104 @@ spark.only.query.negative.files=spark_job_max_tasks.q,\
   spark_submit_negative_executor_memory.q
 
 spark.perf.disabled.query.files=query14.q,\
-  query64.q
+  query64.q,\
+  cbo_query1.q,\
+  cbo_query10.q,\
+  cbo_query11.q,\
+  cbo_query12.q,\
+  cbo_query13.q,\
+  cbo_query14.q,\
+  cbo_query15.q,\
+  cbo_query16.q,\
+  cbo_query17.q,\
+  cbo_query18.q,\
+  cbo_query19.q,\
+  cbo_query2.q,\
+  cbo_query20.q,\
+  cbo_query21.q,\
+  cbo_query22.q,\
+  cbo_query23.q,\
+  cbo_query24.q,\
+  cbo_query25.q,\
+  cbo_query26.q,\
+  cbo_query27.q,\
+  cbo_query28.q,\
+  cbo_query29.q,\
+  cbo_query3.q,\
+  cbo_query30.q,\
+  cbo_query31.q,\
+  cbo_query32.q,\
+  cbo_query33.q,\
+  cbo_query34.q,\
+  cbo_query35.q,\
+  cbo_query36.q,\
+  cbo_query37.q,\
+  cbo_query38.q,\
+  cbo_query39.q,\
+  cbo_query4.q,\
+  cbo_query40.q,\
+  cbo_query42.q,\
+  cbo_query43.q,\
+  cbo_query44.q,\
+  cbo_query45.q,\
+  cbo_query46.q,\
+  cbo_query47.q,\
+  cbo_query48.q,\
+  cbo_query49.q,\
+  cbo_query5.q,\
+  cbo_query50.q,\
+  cbo_query51.q,\
+  cbo_query52.q,\
+  cbo_query53.q,\
+  cbo_query54.q,\
+  cbo_query55.q,\
+  cbo_query56.q,\
+  cbo_query57.q,\
+  cbo_query58.q,\
+  cbo_query59.q,\
+  cbo_query6.q,\
+  cbo_query60.q,\
+  cbo_query61.q,\
+  cbo_query63.q,\
+  cbo_query64.q,\
+  cbo_query65.q,\
+  cbo_query66.q,\
+  cbo_query67.q,\
+  cbo_query68.q,\
+  cbo_query69.q,\
+  cbo_query7.q,\
+  cbo_query70.q,\
+  cbo_query71.q,\
+  cbo_query72.q,\
+  cbo_query73.q,\
+  cbo_query74.q,\
+  cbo_query75.q,\
+  cbo_query76.q,\
+  cbo_query77.q,\
+  cbo_query78.q,\
+  cbo_query79.q,\
+  cbo_query8.q,\
+  cbo_query80.q,\
+  cbo_query81.q,\
+  cbo_query82.q,\
+  cbo_query83.q,\
+  cbo_query84.q,\
+  cbo_query85.q,\
+  cbo_query86.q,\
+  cbo_query87.q,\
+  cbo_query88.q,\
+  cbo_query89.q,\
+  cbo_query9.q,\
+  cbo_query90.q,\
+  cbo_query91.q,\
+  cbo_query92.q,\
+  cbo_query93.q,\
+  cbo_query94.q,\
+  cbo_query95.q,\
+  cbo_query96.q,\
+  cbo_query97.q,\
+  cbo_query98.q,\
+  cbo_query99.q
 
 druid.query.files=druidmini_test1.q,\
   druidmini_test_ts.q,\

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java
----------------------------------------------------------------------
diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java
index 5e1e88e..afff0df 100644
--- a/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java
+++ b/itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CliConfigs.java
@@ -280,7 +280,7 @@ public class CliConfigs {
   }
 
   public static class TezPerfCliConfig extends AbstractCliConfig {
-    public TezPerfCliConfig() {
+    public TezPerfCliConfig(boolean useConstraints) {
       super(CorePerfCliDriver.class);
       try {
         setQueryDir("ql/src/test/queries/clientpositive/perf");
@@ -290,10 +290,21 @@ public class CliConfigs {
         excludesFrom(testConfigProps, "encrypted.query.files");
         excludesFrom(testConfigProps, "erasurecoding.only.query.files");
 
-        setResultsDir("ql/src/test/results/clientpositive/perf/tez");
+        excludeQuery("cbo_query44.q"); // TODO: Enable when we move to Calcite 1.18
+        excludeQuery("cbo_query45.q"); // TODO: Enable when we move to Calcite 1.18
+        excludeQuery("cbo_query67.q"); // TODO: Enable when we move to Calcite 1.18
+        excludeQuery("cbo_query70.q"); // TODO: Enable when we move to Calcite 1.18
+        excludeQuery("cbo_query86.q"); // TODO: Enable when we move to Calcite 1.18
+
         setLogDir("itests/qtest/target/qfile-results/clientpositive/tez");
 
-        setInitScript("q_perf_test_init.sql");
+        if (useConstraints) {
+          setInitScript("q_perf_test_init_constraints.sql");
+          setResultsDir("ql/src/test/results/clientpositive/perf/tez/constraints");
+        } else {
+          setInitScript("q_perf_test_init.sql");
+          setResultsDir("ql/src/test/results/clientpositive/perf/tez");
+        }
         setCleanupScript("q_perf_test_cleanup.sql");
 
         setHiveConfDir("data/conf/perf-reg/tez");

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/Context.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Context.java b/ql/src/java/org/apache/hadoop/hive/ql/Context.java
index b4d5806..aabc34d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Context.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Context.java
@@ -105,6 +105,7 @@ public class Context {
   protected String cboInfo;
   protected boolean cboSucceeded;
   protected String optimizedSql;
+  protected String calcitePlan;
   protected String cmd = "";
   private TokenRewriteStream tokenRewriteStream;
   // Holds the qualified name to tokenRewriteStream for the views
@@ -1021,6 +1022,14 @@ public class Context {
     this.cboSucceeded = cboSucceeded;
   }
 
+  public String getCalcitePlan() {
+    return this.calcitePlan;
+  }
+
+  public void setCalcitePlan(String calcitePlan) {
+    this.calcitePlan = calcitePlan;
+  }
+
   public Table getMaterializedTable(String cteName) {
     return cteTables.get(cteName);
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java
index 46bf088..4cc5fa8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java
@@ -140,6 +140,16 @@ public class ExplainTask extends Task<ExplainWork> implements Serializable {
     return outJSONObject;
   }
 
+  public String outputCboPlan(String cboPlan, PrintStream out, boolean jsonOutput)
+      throws JSONException {
+    if (out != null) {
+      out.println("CBO PLAN:");
+      out.println(cboPlan);
+    }
+
+    return jsonOutput ? cboPlan : null;
+  }
+
   public JSONObject getJSONLogicalPlan(PrintStream out, ExplainWork work) throws Exception {
     isLogical = true;
 
@@ -385,7 +395,11 @@ public class ExplainTask extends Task<ExplainWork> implements Serializable {
       OutputStream outS = resFile.getFileSystem(conf).create(resFile);
       out = new PrintStream(outS);
 
-      if (work.isLogical()) {
+      if (work.isCbo()) {
+        if (work.getCboPlan() != null) {
+          outputCboPlan(work.getCboPlan(), out, work.isFormatted());
+        }
+      } else if (work.isLogical()) {
         JSONObject jsonLogicalPlan = getJSONLogicalPlan(out, work);
         if (work.isFormatted()) {
           out.print(jsonLogicalPlan);

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java b/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java
index 92fcfec..8b10823 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java
@@ -268,7 +268,8 @@ public class ATSHook implements ExecuteWithHookContext {
                   null,// analyzer
                   config, //explainConfig
                   null, // cboInfo
-                  plan.getOptimizedQueryString() // optimizedSQL
+                  plan.getOptimizedQueryString(), // optimizedSQL
+                  null
               );
                 @SuppressWarnings("unchecked")
                 ExplainTask explain = (ExplainTask) TaskFactory.get(work);

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java b/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
index 0af30d4..5a613b8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
@@ -495,7 +495,8 @@ public class HiveProtoLoggingHook implements ExecuteWithHookContext {
           null, null, // analyzer
           config, // explainConfig
           plan.getCboInfo(), // cboInfo,
-          plan.getOptimizedQueryString()
+          plan.getOptimizedQueryString(),
+          null
       );
       ExplainTask explain = (ExplainTask) TaskFactory.get(work, conf);
       explain.initialize(hookContext.getQueryState(), plan, null, null);

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java
index dc0a84b..9aa3012 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java
@@ -18,20 +18,28 @@
 package org.apache.hadoop.hive.ql.optimizer.calcite;
 
 import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
 import java.util.AbstractList;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 
 import com.google.common.collect.ImmutableList;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptUtil;
 import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.RelReferentialConstraint;
 import org.apache.calcite.rel.core.Aggregate;
 import org.apache.calcite.rel.core.Aggregate.Group;
 import org.apache.calcite.rel.core.AggregateCall;
 import org.apache.calcite.rel.core.Filter;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.rel.core.Project;
 import org.apache.calcite.rel.core.RelFactories;
 import org.apache.calcite.rel.core.Sort;
@@ -45,12 +53,15 @@ import org.apache.calcite.rex.RexFieldAccess;
 import org.apache.calcite.rex.RexInputRef;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.rex.RexOver;
+import org.apache.calcite.rex.RexTableInputRef;
+import org.apache.calcite.rex.RexTableInputRef.RelTableRef;
 import org.apache.calcite.rex.RexUtil;
 import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.SqlOperator;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.tools.RelBuilder;
 import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
 import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
 import org.apache.hadoop.hive.ql.optimizer.calcite.translator.TypeConverter;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
@@ -524,4 +535,231 @@ public class HiveRelOptUtil extends RelOptUtil {
     // It passed all the tests
     return false;
   }
+
+  public static Pair<Boolean, List<RexNode>> isRewritablePKFKJoin(RelBuilder builder, Join join,
+        boolean leftInputPotentialFK, RelMetadataQuery mq) {
+    final JoinRelType joinType = join.getJoinType();
+    final RexNode cond = join.getCondition();
+    final RelNode fkInput = leftInputPotentialFK ? join.getLeft() : join.getRight();
+    final RelNode nonFkInput = leftInputPotentialFK ? join.getRight() : join.getLeft();
+    final Pair<Boolean, List<RexNode>> nonRewritable = Pair.of(false, null);
+
+    if (joinType != JoinRelType.INNER) {
+      // If it is not an inner, we transform it as the metadata
+      // providers for expressions do not pull information through
+      // outer join (as it would not be correct)
+      join = (Join) builder
+          .push(join.getLeft()).push(join.getRight())
+          .join(JoinRelType.INNER, cond)
+          .build();
+    }
+
+    // 1) Check whether there is any filtering condition on the
+    // non-FK side. Basically we check whether the operators
+    // below altered the PK cardinality in any way
+    if (HiveRelOptUtil.isRowFilteringPlan(mq, nonFkInput)) {
+      return nonRewritable;
+    }
+
+    // 2) Check whether there is an FK relationship
+    final Map<RexTableInputRef, RexNode> refToRex = new HashMap<>();
+    final EquivalenceClasses ec = new EquivalenceClasses();
+    for (RexNode conj : RelOptUtil.conjunctions(cond)) {
+      if (!conj.isA(SqlKind.EQUALS)) {
+        // Not an equality, we bail out
+        return nonRewritable;
+      }
+      RexCall equiCond = (RexCall) conj;
+      RexNode eqOp1 = equiCond.getOperands().get(0);
+      Set<RexNode> eqOp1ExprsLineage = mq.getExpressionLineage(join, eqOp1);
+      if (eqOp1ExprsLineage == null) {
+        // Cannot be mapped, bail out
+        return nonRewritable;
+      }
+      RexNode eqOp2 = equiCond.getOperands().get(1);
+      Set<RexNode> eqOp2ExprsLineage = mq.getExpressionLineage(join, eqOp2);
+      if (eqOp2ExprsLineage == null) {
+        // Cannot be mapped, bail out
+        return nonRewritable;
+      }
+      List<RexTableInputRef> eqOp2ExprsFiltered = null;
+      for (RexNode eqOpExprLineage1 : eqOp1ExprsLineage) {
+        RexTableInputRef inputRef1 = extractTableInputRef(eqOpExprLineage1);
+        if (inputRef1 == null) {
+          // Bail out as this condition could not be map into an input reference
+          return nonRewritable;
+        }
+        refToRex.put(inputRef1, eqOp1);
+        if (eqOp2ExprsFiltered == null) {
+          // First iteration
+          eqOp2ExprsFiltered = new ArrayList<>();
+          for (RexNode eqOpExprLineage2 : eqOp2ExprsLineage) {
+            RexTableInputRef inputRef2 = extractTableInputRef(eqOpExprLineage2);
+            if (inputRef2 == null) {
+              // Bail out as this condition could not be map into an input reference
+              return nonRewritable;
+            }
+            // Add to list of expressions for follow-up iterations
+            eqOp2ExprsFiltered.add(inputRef2);
+            // Add to equivalence classes and backwards mapping
+            ec.addEquivalenceClass(inputRef1, inputRef2);
+            refToRex.put(inputRef2, eqOp2);
+          }
+        } else {
+          // Rest of iterations, only adding, no checking
+          for (RexTableInputRef inputRef2 : eqOp2ExprsFiltered) {
+            ec.addEquivalenceClass(inputRef1, inputRef2);
+          }
+        }
+      }
+    }
+    if (ec.getEquivalenceClassesMap().isEmpty()) {
+      // This may be a cartesian product, we bail out
+      return nonRewritable;
+    }
+
+    // 3) Gather all tables from the FK side and the table from the
+    // non-FK side
+    final Set<RelTableRef> leftTables = mq.getTableReferences(join.getLeft());
+    final Set<RelTableRef> rightTables =
+        Sets.difference(mq.getTableReferences(join), mq.getTableReferences(join.getLeft()));
+    final Set<RelTableRef> fkTables = join.getLeft() == fkInput ? leftTables : rightTables;
+    final Set<RelTableRef> nonFkTables = join.getLeft() == fkInput ? rightTables : leftTables;
+    assert nonFkTables.size() == 1;
+    final RelTableRef nonFkTable = nonFkTables.iterator().next();
+    final List<String> nonFkTableQName = nonFkTable.getQualifiedName();
+
+    // 4) For each table, check whether there is a matching on the non-FK side.
+    // If there is and it is the only condition, we are ready to transform
+    boolean canBeRewritten = false;
+    List<RexNode> nullableNodes = null;
+    for (RelTableRef tRef : fkTables) {
+      List<RelReferentialConstraint> constraints = tRef.getTable().getReferentialConstraints();
+      for (RelReferentialConstraint constraint : constraints) {
+        if (constraint.getTargetQualifiedName().equals(nonFkTableQName)) {
+          nullableNodes = new ArrayList<>();
+          EquivalenceClasses ecT = EquivalenceClasses.copy(ec);
+          boolean allContained = true;
+          for (int pos = 0; pos < constraint.getNumColumns(); pos++) {
+            int foreignKeyPos = constraint.getColumnPairs().get(pos).source;
+            RelDataType foreignKeyColumnType =
+                tRef.getTable().getRowType().getFieldList().get(foreignKeyPos).getType();
+            RexTableInputRef foreignKeyColumnRef =
+                RexTableInputRef.of(tRef, foreignKeyPos, foreignKeyColumnType);
+            int uniqueKeyPos = constraint.getColumnPairs().get(pos).target;
+            RexTableInputRef uniqueKeyColumnRef = RexTableInputRef.of(nonFkTable, uniqueKeyPos,
+                nonFkTable.getTable().getRowType().getFieldList().get(uniqueKeyPos).getType());
+            if (ecT.getEquivalenceClassesMap().containsKey(uniqueKeyColumnRef) &&
+                ecT.getEquivalenceClassesMap().get(uniqueKeyColumnRef).contains(foreignKeyColumnRef)) {
+              if (foreignKeyColumnType.isNullable()) {
+                if (joinType == JoinRelType.INNER) {
+                  // If it is nullable and it is an INNER, we just need a IS NOT NULL filter
+                  RexNode originalCondOp = refToRex.get(foreignKeyColumnRef);
+                  assert originalCondOp != null;
+                  nullableNodes.add(originalCondOp);
+                } else {
+                  // If it is nullable and this is not an INNER, we cannot execute any transformation
+                  allContained = false;
+                  break;
+                }
+              }
+              // Remove this condition from eq classes as we have checked that it is present
+              // in the join condition
+              ecT.getEquivalenceClassesMap().get(uniqueKeyColumnRef).remove(foreignKeyColumnRef);
+              if (ecT.getEquivalenceClassesMap().get(uniqueKeyColumnRef).size() == 1) { // self
+                ecT.getEquivalenceClassesMap().remove(uniqueKeyColumnRef);
+              }
+              ecT.getEquivalenceClassesMap().get(foreignKeyColumnRef).remove(uniqueKeyColumnRef);
+              if (ecT.getEquivalenceClassesMap().get(foreignKeyColumnRef).size() == 1) { // self
+                ecT.getEquivalenceClassesMap().remove(foreignKeyColumnRef);
+              }
+            } else {
+              // No relationship, we cannot do anything
+              allContained = false;
+              break;
+            }
+          }
+          if (allContained && ecT.getEquivalenceClassesMap().isEmpty()) {
+            // We made it
+            canBeRewritten = true;
+            break;
+          }
+        }
+      }
+    }
+
+    return Pair.of(canBeRewritten, nullableNodes);
+  }
+
+  private static RexTableInputRef extractTableInputRef(RexNode node) {
+    RexTableInputRef ref = null;
+    if (node instanceof RexTableInputRef) {
+      ref = (RexTableInputRef) node;
+    } else if (RexUtil.isLosslessCast(node) &&
+        ((RexCall) node).getOperands().get(0) instanceof RexTableInputRef) {
+      ref = (RexTableInputRef) ((RexCall) node).getOperands().get(0);
+    }
+    return ref;
+  }
+
+  /**
+   * Class representing an equivalence class, i.e., a set of equivalent columns
+   *
+   * TODO: This is a subset of a private class in materialized view rewriting
+   * in Calcite. It should be moved to its own class in Calcite so it can be
+   * accessible here.
+   */
+  private static class EquivalenceClasses {
+
+    private final Map<RexTableInputRef, Set<RexTableInputRef>> nodeToEquivalenceClass;
+
+    protected EquivalenceClasses() {
+      nodeToEquivalenceClass = new HashMap<>();
+    }
+
+    protected void addEquivalenceClass(RexTableInputRef p1, RexTableInputRef p2) {
+      Set<RexTableInputRef> c1 = nodeToEquivalenceClass.get(p1);
+      Set<RexTableInputRef> c2 = nodeToEquivalenceClass.get(p2);
+      if (c1 != null && c2 != null) {
+        // Both present, we need to merge
+        if (c1.size() < c2.size()) {
+          // We swap them to merge
+          Set<RexTableInputRef> c2Temp = c2;
+          c2 = c1;
+          c1 = c2Temp;
+        }
+        for (RexTableInputRef newRef : c2) {
+          c1.add(newRef);
+          nodeToEquivalenceClass.put(newRef, c1);
+        }
+      } else if (c1 != null) {
+        // p1 present, we need to merge into it
+        c1.add(p2);
+        nodeToEquivalenceClass.put(p2, c1);
+      } else if (c2 != null) {
+        // p2 present, we need to merge into it
+        c2.add(p1);
+        nodeToEquivalenceClass.put(p1, c2);
+      } else {
+        // None are present, add to same equivalence class
+        Set<RexTableInputRef> equivalenceClass = new LinkedHashSet<>();
+        equivalenceClass.add(p1);
+        equivalenceClass.add(p2);
+        nodeToEquivalenceClass.put(p1, equivalenceClass);
+        nodeToEquivalenceClass.put(p2, equivalenceClass);
+      }
+    }
+
+    protected Map<RexTableInputRef, Set<RexTableInputRef>> getEquivalenceClassesMap() {
+      return nodeToEquivalenceClass;
+    }
+
+    protected static EquivalenceClasses copy(EquivalenceClasses ec) {
+      final EquivalenceClasses newEc = new EquivalenceClasses();
+      for (Entry<RexTableInputRef, Set<RexTableInputRef>> e : ec.nodeToEquivalenceClass.entrySet()) {
+        newEc.nodeToEquivalenceClass.put(e.getKey(), Sets.newLinkedHashSet(e.getValue()));
+      }
+      return newEc;
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java
index 0a307f2..534a5c9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveJoinConstraintsRule.java
@@ -53,6 +53,7 @@ import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.tools.RelBuilderFactory;
 import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.mapping.Mapping;
 import org.apache.calcite.util.mapping.MappingType;
 import org.apache.calcite.util.mapping.Mappings;
@@ -105,7 +106,6 @@ public class HiveJoinConstraintsRule extends RelOptRule {
     // If it is a left outer, left will be the FK side.
     // If it is a right outer, right will be the FK side.
     final RelNode fkInput;
-    final RelNode nonFkInput;
     final ImmutableBitSet topRefs =
         RelOptUtil.InputFinder.bits(topProjExprs, null);
     final ImmutableBitSet leftBits =
@@ -204,17 +204,14 @@ public class HiveJoinConstraintsRule extends RelOptRule {
         return;
       }
       fkInput = leftInputPotentialFK ? leftInput : rightInput;
-      nonFkInput = leftInputPotentialFK ? rightInput : leftInput;
       mode = Mode.REMOVE;
       break;
     case LEFT:
       fkInput = leftInput;
-      nonFkInput = rightInput;
       mode = leftInputPotentialFK && !rightInputPotentialFK ? Mode.REMOVE : Mode.TRANSFORM;
       break;
     case RIGHT:
       fkInput = rightInput;
-      nonFkInput = leftInput;
       mode = !leftInputPotentialFK && rightInputPotentialFK ? Mode.REMOVE : Mode.TRANSFORM;
       break;
     default:
@@ -222,151 +219,13 @@ public class HiveJoinConstraintsRule extends RelOptRule {
       return;
     }
 
-    // 2) Check whether there is any filtering condition on the
-    // non-FK side. Basically we check whether the operators
-    // below altered the PK cardinality in any way
-    final RelMetadataQuery mq = call.getMetadataQuery();
-    if (HiveRelOptUtil.isRowFilteringPlan(mq, nonFkInput)) {
-      return;
-    }
-
-    // 3) Check whether there is an FK relationship
-    if (join.getJoinType() != JoinRelType.INNER) {
-      // If it is not an inner, we transform it as the metadata
-      // providers for expressions do not pull information through
-      // outer join (as it would not be correct)
-      join = (Join) call.builder()
-          .push(leftInput).push(rightInput)
-          .join(JoinRelType.INNER, cond)
-          .build();
-    }
-    final Map<RexTableInputRef, RexNode> refToRex = new HashMap<>();
-    final EquivalenceClasses ec = new EquivalenceClasses();
-    for (RexNode conj : RelOptUtil.conjunctions(cond)) {
-      if (!conj.isA(SqlKind.EQUALS)) {
-        // Not an equality, we bail out
-        return;
-      }
-      RexCall equiCond = (RexCall) conj;
-      RexNode eqOp1 = equiCond.getOperands().get(0);
-      Set<RexNode> eqOp1ExprsLineage = mq.getExpressionLineage(join, eqOp1);
-      if (eqOp1ExprsLineage == null) {
-        // Cannot be mapped, bail out
-        return;
-      }
-      RexNode eqOp2 = equiCond.getOperands().get(1);
-      Set<RexNode> eqOp2ExprsLineage = mq.getExpressionLineage(join, eqOp2);
-      if (eqOp2ExprsLineage == null) {
-        // Cannot be mapped, bail out
-        return;
-      }
-      List<RexTableInputRef> eqOp2ExprsFiltered = null;
-      for (RexNode eqOpExprLineage1 : eqOp1ExprsLineage) {
-        RexTableInputRef inputRef1 = extractTableInputRef(eqOpExprLineage1);
-        if (inputRef1 == null) {
-          // Bail out as this condition could not be map into an input reference
-          return;
-        }
-        refToRex.put(inputRef1, eqOp1);
-        if (eqOp2ExprsFiltered == null) {
-          // First iteration
-          eqOp2ExprsFiltered = new ArrayList<>();
-          for (RexNode eqOpExprLineage2 : eqOp2ExprsLineage) {
-            RexTableInputRef inputRef2 = extractTableInputRef(eqOpExprLineage2);
-            if (inputRef2 == null) {
-              // Bail out as this condition could not be map into an input reference
-              return;
-            }
-            // Add to list of expressions for follow-up iterations
-            eqOp2ExprsFiltered.add(inputRef2);
-            // Add to equivalence classes and backwards mapping
-            ec.addEquivalenceClass(inputRef1, inputRef2);
-            refToRex.put(inputRef2, eqOp2);
-          }
-        } else {
-          // Rest of iterations, only adding, no checking
-          for (RexTableInputRef inputRef2 : eqOp2ExprsFiltered) {
-            ec.addEquivalenceClass(inputRef1, inputRef2);
-          }
-        }
-      }
-    }
-    if (ec.getEquivalenceClassesMap().isEmpty()) {
-      // This may be a cartesian product, we bail out
-      return;
-    }
-
-    // 4) Gather all tables from the FK side and the table from the
-    // non-FK side
-    final Set<RelTableRef> leftTables = mq.getTableReferences(leftInput);
-    final Set<RelTableRef> rightTables =
-        Sets.difference(mq.getTableReferences(join), mq.getTableReferences(leftInput));
-    final Set<RelTableRef> fkTables = leftInputPotentialFK ? leftTables : rightTables;
-    final Set<RelTableRef> nonFkTables = leftInputPotentialFK ? rightTables : leftTables;
-    assert nonFkTables.size() == 1;
-    final RelTableRef nonFkTable = nonFkTables.iterator().next();
-    final List<String> nonFkTableQName = nonFkTable.getQualifiedName();
+    // 2) Check whether this join can be rewritten or removed
+    Pair<Boolean, List<RexNode>> r = HiveRelOptUtil.isRewritablePKFKJoin(call.builder(),
+        join, leftInput == fkInput, call.getMetadataQuery());
 
-    // 5) For each table, check whether there is a matching on the non-FK side.
-    // If there is and it is the only condition, we are ready to transform
-    boolean canBeRewritten = false;
-    List<RexNode> nullableNodes = new ArrayList<>();
-    for (RelTableRef tRef : fkTables) {
-      List<RelReferentialConstraint> constraints = tRef.getTable().getReferentialConstraints();
-      for (RelReferentialConstraint constraint : constraints) {
-        if (constraint.getTargetQualifiedName().equals(nonFkTableQName)) {
-          EquivalenceClasses ecT = EquivalenceClasses.copy(ec);
-          boolean allContained = true;
-          for (int pos = 0; pos < constraint.getNumColumns(); pos++) {
-            int foreignKeyPos = constraint.getColumnPairs().get(pos).source;
-            RelDataType foreignKeyColumnType =
-                tRef.getTable().getRowType().getFieldList().get(foreignKeyPos).getType();
-            RexTableInputRef foreignKeyColumnRef =
-                RexTableInputRef.of(tRef, foreignKeyPos, foreignKeyColumnType);
-            if (foreignKeyColumnType.isNullable()) {
-              if (joinType == JoinRelType.INNER) {
-                // If it is nullable and it is an INNER, we just need a IS NOT NULL filter
-                RexNode originalCondOp = refToRex.get(foreignKeyColumnRef);
-                assert originalCondOp != null;
-                nullableNodes.add(originalCondOp);
-              } else {
-                // If it is nullable and this is not an INNER, we cannot execute any transformation
-                allContained = false;
-                break;
-              }
-            }
-            int uniqueKeyPos = constraint.getColumnPairs().get(pos).target;
-            RexTableInputRef uniqueKeyColumnRef = RexTableInputRef.of(nonFkTable, uniqueKeyPos,
-                nonFkTable.getTable().getRowType().getFieldList().get(uniqueKeyPos).getType());
-            if (ecT.getEquivalenceClassesMap().containsKey(uniqueKeyColumnRef) &&
-                ecT.getEquivalenceClassesMap().get(uniqueKeyColumnRef).contains(foreignKeyColumnRef)) {
-              // Remove this condition from eq classes as we have checked that it is present
-              // in the join condition
-              ecT.getEquivalenceClassesMap().get(uniqueKeyColumnRef).remove(foreignKeyColumnRef);
-              if (ecT.getEquivalenceClassesMap().get(uniqueKeyColumnRef).size() == 1) { // self
-                ecT.getEquivalenceClassesMap().remove(uniqueKeyColumnRef);
-              }
-              ecT.getEquivalenceClassesMap().get(foreignKeyColumnRef).remove(uniqueKeyColumnRef);
-              if (ecT.getEquivalenceClassesMap().get(foreignKeyColumnRef).size() == 1) { // self
-                ecT.getEquivalenceClassesMap().remove(foreignKeyColumnRef);
-              }
-            } else {
-              // No relationship, we cannot do anything
-              allContained = false;
-              break;
-            }
-          }
-          if (allContained && ecT.getEquivalenceClassesMap().isEmpty()) {
-            // We made it
-            canBeRewritten = true;
-            break;
-          }
-        }
-      }
-    }
-
-    // 6) If it is the only condition, we can trigger the rewriting
-    if (canBeRewritten) {
+    // 3) If it is the only condition, we can trigger the rewriting
+    if (r.left) {
+      List<RexNode> nullableNodes = r.right;
       // If we reach here, we trigger the transform
       if (mode == Mode.REMOVE) {
         if (rightInputPotentialFK) {
@@ -410,84 +269,13 @@ public class HiveJoinConstraintsRule extends RelOptRule {
         call.transformTo(call.builder()
             .push(leftInput).push(rightInput)
             .join(JoinRelType.INNER, join.getCondition())
+            .convert(call.rel(1).getRowType(), false) // Preserve nullability
             .project(project.getChildExps())
             .build());
       }
     }
   }
 
-  private static RexTableInputRef extractTableInputRef(RexNode node) {
-    RexTableInputRef ref = null;
-    if (node instanceof RexTableInputRef) {
-      ref = (RexTableInputRef) node;
-    } else if (RexUtil.isLosslessCast(node) &&
-        ((RexCall) node).getOperands().get(0) instanceof RexTableInputRef) {
-      ref = (RexTableInputRef) ((RexCall) node).getOperands().get(0);
-    }
-    return ref;
-  }
-
-  /**
-   * Class representing an equivalence class, i.e., a set of equivalent columns
-   *
-   * TODO: This is a subset of a private class in materialized view rewriting
-   * in Calcite. It should be moved to its own class in Calcite so it can be
-   * accessible here.
-   */
-  private static class EquivalenceClasses {
-
-    private final Map<RexTableInputRef, Set<RexTableInputRef>> nodeToEquivalenceClass;
-
-    protected EquivalenceClasses() {
-      nodeToEquivalenceClass = new HashMap<>();
-    }
-
-    protected void addEquivalenceClass(RexTableInputRef p1, RexTableInputRef p2) {
-      Set<RexTableInputRef> c1 = nodeToEquivalenceClass.get(p1);
-      Set<RexTableInputRef> c2 = nodeToEquivalenceClass.get(p2);
-      if (c1 != null && c2 != null) {
-        // Both present, we need to merge
-        if (c1.size() < c2.size()) {
-          // We swap them to merge
-          Set<RexTableInputRef> c2Temp = c2;
-          c2 = c1;
-          c1 = c2Temp;
-        }
-        for (RexTableInputRef newRef : c2) {
-          c1.add(newRef);
-          nodeToEquivalenceClass.put(newRef, c1);
-        }
-      } else if (c1 != null) {
-        // p1 present, we need to merge into it
-        c1.add(p2);
-        nodeToEquivalenceClass.put(p2, c1);
-      } else if (c2 != null) {
-        // p2 present, we need to merge into it
-        c2.add(p1);
-        nodeToEquivalenceClass.put(p1, c2);
-      } else {
-        // None are present, add to same equivalence class
-        Set<RexTableInputRef> equivalenceClass = new LinkedHashSet<>();
-        equivalenceClass.add(p1);
-        equivalenceClass.add(p2);
-        nodeToEquivalenceClass.put(p1, equivalenceClass);
-        nodeToEquivalenceClass.put(p2, equivalenceClass);
-      }
-    }
-
-    protected Map<RexTableInputRef, Set<RexTableInputRef>> getEquivalenceClassesMap() {
-      return nodeToEquivalenceClass;
-    }
-
-    protected static EquivalenceClasses copy(EquivalenceClasses ec) {
-      final EquivalenceClasses newEc = new EquivalenceClasses();
-      for (Entry<RexTableInputRef, Set<RexTableInputRef>> e : ec.nodeToEquivalenceClass.entrySet()) {
-        newEc.nodeToEquivalenceClass.put(e.getKey(), Sets.newLinkedHashSet(e.getValue()));
-      }
-      return newEc;
-    }
-  }
-
   private enum Mode {
     // Removes join operator from the plan
     REMOVE,

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
index 1085845..82e975a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
@@ -528,7 +528,15 @@ public class CalcitePlanner extends SemanticAnalyzer {
             this.ctx.setCboSucceeded(true);
             if (this.ctx.isExplainPlan()) {
               ExplainConfiguration explainConfig = this.ctx.getExplainConfig();
-              if (explainConfig.isExtended() || explainConfig.isFormatted()) {
+              if (explainConfig.isCbo()) {
+                if (explainConfig.isCboExtended()) {
+                  // Include join cost
+                  this.ctx.setCalcitePlan(RelOptUtil.toString(newPlan, SqlExplainLevel.ALL_ATTRIBUTES));
+                } else {
+                  // Do not include join cost
+                  this.ctx.setCalcitePlan(RelOptUtil.toString(newPlan));
+                }
+              } else if (explainConfig.isExtended() || explainConfig.isFormatted()) {
                 this.ctx.setOptimizedSql(getOptimizedSql(newPlan));
               }
             }

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainConfiguration.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainConfiguration.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainConfiguration.java
index a92502e..28a7b43 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainConfiguration.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainConfiguration.java
@@ -41,6 +41,8 @@ public class ExplainConfiguration {
   private boolean extended = false;
   private boolean formatted = false;
   private boolean dependency = false;
+  private boolean cbo = false;
+  private boolean cboExtended = false;
   private boolean logical = false;
   private boolean authorize = false;
   private boolean userLevelExplain = false;
@@ -84,6 +86,22 @@ public class ExplainConfiguration {
     this.dependency = dependency;
   }
 
+  public boolean isCbo() {
+    return cbo;
+  }
+
+  public void setCbo(boolean cbo) {
+    this.cbo = cbo;
+  }
+
+  public boolean isCboExtended() {
+    return cboExtended;
+  }
+
+  public void setCboExtended(boolean cboExtended) {
+    this.cboExtended = cboExtended;
+  }
+
   public boolean isLogical() {
     return logical;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
index 49b6146..6721a37 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
@@ -75,6 +75,14 @@ public class ExplainSemanticAnalyzer extends BaseSemanticAnalyzer {
         config.setExtended(true);
       } else if (explainOptions == HiveParser.KW_DEPENDENCY) {
         config.setDependency(true);
+      } else if (explainOptions == HiveParser.KW_CBO) {
+        config.setCbo(true);
+        if (i + 1 < childCount) {
+          if (ast.getChild(i + 1).getType() == HiveParser.KW_EXTENDED) {
+            config.setCboExtended(true);
+            i++;
+          }
+        }
       } else if (explainOptions == HiveParser.KW_LOGICAL) {
         config.setLogical(true);
       } else if (explainOptions == HiveParser.KW_AUTHORIZATION) {
@@ -191,6 +199,7 @@ public class ExplainSemanticAnalyzer extends BaseSemanticAnalyzer {
     config.setUserLevelExplain(!config.isExtended()
         && !config.isFormatted()
         && !config.isDependency()
+        && !config.isCbo()
         && !config.isLogical()
         && !config.isAuthorize()
         && (
@@ -216,7 +225,8 @@ public class ExplainSemanticAnalyzer extends BaseSemanticAnalyzer {
         sem,
         config,
         ctx.getCboInfo(),
-        ctx.getOptimizedSql());
+        ctx.getOptimizedSql(),
+        ctx.getCalcitePlan());
 
     work.setAppendTaskType(
         HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVEEXPLAINDEPENDENCYAPPENDTASKTYPES));

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
index 8bf9cc0..253633c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
@@ -193,6 +193,7 @@ KW_DEBUG: 'DEBUG';
 KW_FORMATTED: 'FORMATTED';
 KW_DEPENDENCY: 'DEPENDENCY';
 KW_LOGICAL: 'LOGICAL';
+KW_CBO: 'CBO';
 KW_SERDE: 'SERDE';
 KW_WITH: 'WITH';
 KW_DEFERRED: 'DEFERRED';

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
index bc95c46..7dda8b3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
@@ -805,6 +805,7 @@ explainOption
     : KW_EXTENDED
     | KW_FORMATTED
     | KW_DEPENDENCY
+    | KW_CBO KW_EXTENDED?
     | KW_LOGICAL
     | KW_AUTHORIZATION
     | KW_ANALYZE

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
index fa033d7..417955c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
@@ -794,7 +794,7 @@ principalIdentifier
 nonReserved
     :
     KW_ABORT | KW_ADD | KW_ADMIN | KW_AFTER | KW_ANALYZE | KW_ARCHIVE | KW_ASC | KW_BEFORE | KW_BUCKET | KW_BUCKETS
-    | KW_CASCADE | KW_CHANGE | KW_CHECK | KW_CLUSTER | KW_CLUSTERED | KW_CLUSTERSTATUS | KW_COLLECTION | KW_COLUMNS
+    | KW_CASCADE | KW_CBO | KW_CHANGE | KW_CHECK | KW_CLUSTER | KW_CLUSTERED | KW_CLUSTERSTATUS | KW_COLLECTION | KW_COLUMNS
     | KW_COMMENT | KW_COMPACT | KW_COMPACTIONS | KW_COMPUTE | KW_CONCATENATE | KW_CONTINUE | KW_DATA | KW_DAY
     | KW_DATABASES | KW_DATETIME | KW_DBPROPERTIES | KW_DEFERRED | KW_DEFINED | KW_DELIMITED | KW_DEPENDENCY 
     | KW_DESC | KW_DIRECTORIES | KW_DIRECTORY | KW_DISABLE | KW_DISTRIBUTE | KW_DOW | KW_ELEM_TYPE 

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/java/org/apache/hadoop/hive/ql/plan/ExplainWork.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExplainWork.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExplainWork.java
index 01da4d5..8a60d59 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExplainWork.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExplainWork.java
@@ -54,6 +54,7 @@ public class ExplainWork implements Serializable {
   boolean appendTaskType;
 
   String cboInfo;
+  String cboPlan;
 
   private String optimizedSQL;
 
@@ -70,7 +71,8 @@ public class ExplainWork implements Serializable {
       BaseSemanticAnalyzer analyzer,
       ExplainConfiguration config,
       String cboInfo,
-      String optimizedSQL) {
+      String optimizedSQL,
+      String cboPlan) {
     this.resFile = resFile;
     this.rootTasks = new ArrayList<Task<?>>(rootTasks);
     this.fetchTask = fetchTask;
@@ -87,6 +89,7 @@ public class ExplainWork implements Serializable {
     this.pCtx = pCtx;
     this.cboInfo = cboInfo;
     this.optimizedSQL = optimizedSQL;
+    this.cboPlan = cboPlan;
     this.config = config;
   }
 
@@ -177,6 +180,10 @@ public class ExplainWork implements Serializable {
     this.pCtx = pCtx;
   }
 
+  public boolean isCbo() {
+    return config.isCbo();
+  }
+
   public boolean isLogical() {
     return config.isLogical();
   }
@@ -217,6 +224,14 @@ public class ExplainWork implements Serializable {
     this.optimizedSQL = optimizedSQL;
   }
 
+  public String getCboPlan() {
+    return cboPlan;
+  }
+
+  public void setCboPlan(String cboPlan) {
+    this.cboPlan = cboPlan;
+  }
+
   public ExplainConfiguration getConfig() {
     return config;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java
index 932f4e8..f449c6b 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestUpdateDeleteSemanticAnalyzer.java
@@ -300,7 +300,7 @@ public class TestUpdateDeleteSemanticAnalyzer {
     ExplainConfiguration config = new ExplainConfiguration();
     config.setExtended(true);
     ExplainWork work = new ExplainWork(tmp, sem.getParseContext(), sem.getRootTasks(),
-        sem.getFetchTask(), null, sem, config, null, plan.getOptimizedQueryString());
+        sem.getFetchTask(), null, sem, config, null, plan.getOptimizedQueryString(), null);
     ExplainTask task = new ExplainTask();
     task.setWork(work);
     task.initialize(queryState, plan, null, null);

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query1.q b/ql/src/test/queries/clientpositive/perf/cbo_query1.q
new file mode 100644
index 0000000..7cb0cd2
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query1.q
@@ -0,0 +1,27 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query1.tpl and seed 2031708268
+explain cbo
+with customer_total_return as
+(select sr_customer_sk as ctr_customer_sk
+,sr_store_sk as ctr_store_sk
+,sum(SR_FEE) as ctr_total_return
+from store_returns
+,date_dim
+where sr_returned_date_sk = d_date_sk
+and d_year =2000
+group by sr_customer_sk
+,sr_store_sk)
+ select  c_customer_id
+from customer_total_return ctr1
+,store
+,customer
+where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+from customer_total_return ctr2
+where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
+and s_store_sk = ctr1.ctr_store_sk
+and s_state = 'NM'
+and ctr1.ctr_customer_sk = c_customer_sk
+order by c_customer_id
+limit 100;
+
+-- end query 1 in stream 0 using template query1.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query10.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query10.q b/ql/src/test/queries/clientpositive/perf/cbo_query10.q
new file mode 100644
index 0000000..fbdc9db
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query10.q
@@ -0,0 +1,61 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query10.tpl and seed 797269820
+explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2002 and
+                d_moy between 4 and 4+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 ANd 4+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 and 4+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100;
+
+-- end query 1 in stream 0 using template query10.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query11.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query11.q b/ql/src/test/queries/clientpositive/perf/cbo_query11.q
new file mode 100644
index 0000000..09d9529
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query11.q
@@ -0,0 +1,77 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query11.tpl and seed 1819994127
+explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year 
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.c_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.dyear = 2001
+         and t_s_secyear.dyear = 2001+1
+         and t_w_firstyear.dyear = 2001
+         and t_w_secyear.dyear = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+             > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by t_s_secyear.c_preferred_cust_flag
+limit 100;
+
+-- end query 1 in stream 0 using template query11.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query12.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query12.q b/ql/src/test/queries/clientpositive/perf/cbo_query12.q
new file mode 100644
index 0000000..41029cf
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query12.q
@@ -0,0 +1,35 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query12.tpl and seed 345591136
+explain cbo
+select  i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ws_ext_sales_price) as itemrevenue 
+      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	web_sales
+    	,item 
+    	,date_dim
+where 
+	ws_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ws_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+limit 100;
+
+-- end query 1 in stream 0 using template query12.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query13.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query13.q b/ql/src/test/queries/clientpositive/perf/cbo_query13.q
new file mode 100644
index 0000000..72eb08d
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query13.q
@@ -0,0 +1,54 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query13.tpl and seed 622697896
+explain cbo
+select avg(ss_quantity)
+       ,avg(ss_ext_sales_price)
+       ,avg(ss_ext_wholesale_cost)
+       ,sum(ss_ext_wholesale_cost)
+ from store_sales
+     ,store
+     ,customer_demographics
+     ,household_demographics
+     ,customer_address
+     ,date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 2001
+ and((ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'M'
+  and cd_education_status = '4 yr Degree'
+  and ss_sales_price between 100.00 and 150.00
+  and hd_dep_count = 3   
+     )or
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'D'
+  and cd_education_status = 'Primary'
+  and ss_sales_price between 50.00 and 100.00   
+  and hd_dep_count = 1
+     ) or 
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'U'
+  and cd_education_status = 'Advanced Degree'
+  and ss_sales_price between 150.00 and 200.00 
+  and hd_dep_count = 1  
+     ))
+ and((ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 100 and 200  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 300  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 250  
+     ))
+;
+
+-- end query 1 in stream 0 using template query13.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query14.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query14.q b/ql/src/test/queries/clientpositive/perf/cbo_query14.q
new file mode 100644
index 0000000..eaee914
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query14.q
@@ -0,0 +1,104 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query14.tpl and seed 1819994127
+explain cbo
+with  cross_items as
+ (select i_item_sk ss_item_sk
+ from item,
+ (select iss.i_brand_id brand_id
+     ,iss.i_class_id class_id
+     ,iss.i_category_id category_id
+ from store_sales
+     ,item iss
+     ,date_dim d1
+ where ss_item_sk = iss.i_item_sk
+   and ss_sold_date_sk = d1.d_date_sk
+   and d1.d_year between 1999 AND 1999 + 2
+ intersect 
+ select ics.i_brand_id
+     ,ics.i_class_id
+     ,ics.i_category_id
+ from catalog_sales
+     ,item ics
+     ,date_dim d2
+ where cs_item_sk = ics.i_item_sk
+   and cs_sold_date_sk = d2.d_date_sk
+   and d2.d_year between 1999 AND 1999 + 2
+ intersect
+ select iws.i_brand_id
+     ,iws.i_class_id
+     ,iws.i_category_id
+ from web_sales
+     ,item iws
+     ,date_dim d3
+ where ws_item_sk = iws.i_item_sk
+   and ws_sold_date_sk = d3.d_date_sk
+   and d3.d_year between 1999 AND 1999 + 2) x
+ where i_brand_id = brand_id
+      and i_class_id = class_id
+      and i_category_id = category_id
+),
+ avg_sales as
+ (select avg(quantity*list_price) average_sales
+  from (select ss_quantity quantity
+             ,ss_list_price list_price
+       from store_sales
+           ,date_dim
+       where ss_sold_date_sk = d_date_sk
+         and d_year between 1999 and 2001 
+       union all 
+       select cs_quantity quantity 
+             ,cs_list_price list_price
+       from catalog_sales
+           ,date_dim
+       where cs_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2 
+       union all
+       select ws_quantity quantity
+             ,ws_list_price list_price
+       from web_sales
+           ,date_dim
+       where ws_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2) x)
+  select  channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
+ from(
+       select 'store' channel, i_brand_id,i_class_id
+             ,i_category_id,sum(ss_quantity*ss_list_price) sales
+             , count(*) number_sales
+       from store_sales
+           ,item
+           ,date_dim
+       where ss_item_sk in (select ss_item_sk from cross_items)
+         and ss_item_sk = i_item_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
+       from catalog_sales
+           ,item
+           ,date_dim
+       where cs_item_sk in (select ss_item_sk from cross_items)
+         and cs_item_sk = i_item_sk
+         and cs_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
+       from web_sales
+           ,item
+           ,date_dim
+       where ws_item_sk in (select ss_item_sk from cross_items)
+         and ws_item_sk = i_item_sk
+         and ws_sold_date_sk = d_date_sk
+         and d_year = 1998+2
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
+ ) y
+ group by rollup (channel, i_brand_id,i_class_id,i_category_id)
+ order by channel,i_brand_id,i_class_id,i_category_id
+ limit 100;

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query15.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query15.q b/ql/src/test/queries/clientpositive/perf/cbo_query15.q
new file mode 100644
index 0000000..3beea4e
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query15.q
@@ -0,0 +1,22 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query15.tpl and seed 1819994127
+explain cbo
+select  ca_zip
+       ,sum(cs_sales_price)
+ from catalog_sales
+     ,customer
+     ,customer_address
+     ,date_dim
+ where cs_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
+                                   '85392', '85460', '80348', '81792')
+ 	      or ca_state in ('CA','WA','GA')
+ 	      or cs_sales_price > 500)
+ 	and cs_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip
+ order by ca_zip
+ limit 100;
+
+-- end query 1 in stream 0 using template query15.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query16.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query16.q b/ql/src/test/queries/clientpositive/perf/cbo_query16.q
new file mode 100644
index 0000000..74245aa
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query16.q
@@ -0,0 +1,33 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query16.tpl and seed 171719422
+explain cbo
+select  
+   count(distinct cs_order_number) as `order count`
+  ,sum(cs_ext_ship_cost) as `total shipping cost`
+  ,sum(cs_net_profit) as `total net profit`
+from
+   catalog_sales cs1
+  ,date_dim
+  ,customer_address
+  ,call_center
+where
+    d_date between '2001-4-01' and 
+           (cast('2001-4-01' as date) + 60 days)
+and cs1.cs_ship_date_sk = d_date_sk
+and cs1.cs_ship_addr_sk = ca_address_sk
+and ca_state = 'NY'
+and cs1.cs_call_center_sk = cc_call_center_sk
+and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish',
+                  'Daviess County'
+)
+and exists (select *
+            from catalog_sales cs2
+            where cs1.cs_order_number = cs2.cs_order_number
+              and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
+and not exists(select *
+               from catalog_returns cr1
+               where cs1.cs_order_number = cr1.cr_order_number)
+order by count(distinct cs_order_number)
+limit 100;
+
+-- end query 1 in stream 0 using template query16.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query17.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query17.q b/ql/src/test/queries/clientpositive/perf/cbo_query17.q
new file mode 100644
index 0000000..5bf9864
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query17.q
@@ -0,0 +1,47 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query17.tpl and seed 1819994127
+explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,s_state
+       ,count(ss_quantity) as store_sales_quantitycount
+       ,avg(ss_quantity) as store_sales_quantityave
+       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
+       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
+       ,count(sr_return_quantity) as_store_returns_quantitycount
+       ,avg(sr_return_quantity) as_store_returns_quantityave
+       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
+       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
+       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
+ from store_sales
+     ,store_returns
+     ,catalog_sales
+     ,date_dim d1
+     ,date_dim d2
+     ,date_dim d3
+     ,store
+     ,item
+ where d1.d_quarter_name = '2000Q1'
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+ group by i_item_id
+         ,i_item_desc
+         ,s_state
+ order by i_item_id
+         ,i_item_desc
+         ,s_state
+limit 100;
+
+-- end query 1 in stream 0 using template query17.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query18.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query18.q b/ql/src/test/queries/clientpositive/perf/cbo_query18.q
new file mode 100644
index 0000000..110bee5
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query18.q
@@ -0,0 +1,36 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query18.tpl and seed 1978355063
+explain cbo
+select  i_item_id,
+        ca_country,
+        ca_state, 
+        ca_county,
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
+ from catalog_sales, customer_demographics cd1, 
+      customer_demographics cd2, customer, customer_address, date_dim, item
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd1.cd_demo_sk and
+       cs_bill_customer_sk = c_customer_sk and
+       cd1.cd_gender = 'M' and 
+       cd1.cd_education_status = 'College' and
+       c_current_cdemo_sk = cd2.cd_demo_sk and
+       c_current_addr_sk = ca_address_sk and
+       c_birth_month in (9,5,12,4,1,10) and
+       d_year = 2001 and
+       ca_state in ('ND','WI','AL'
+                   ,'NC','OK','MS','TN')
+ group by rollup (i_item_id, ca_country, ca_state, ca_county)
+ order by ca_country,
+        ca_state, 
+        ca_county,
+	i_item_id
+ limit 100;
+
+-- end query 1 in stream 0 using template query18.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query19.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query19.q b/ql/src/test/queries/clientpositive/perf/cbo_query19.q
new file mode 100644
index 0000000..abcec36
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query19.q
@@ -0,0 +1,27 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query19.tpl and seed 1930872976
+explain cbo
+select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item,customer,customer_address,store
+ where d_date_sk = ss_sold_date_sk
+   and ss_item_sk = i_item_sk
+   and i_manager_id=7
+   and d_moy=11
+   and d_year=1999
+   and ss_customer_sk = c_customer_sk 
+   and c_current_addr_sk = ca_address_sk
+   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
+   and ss_store_sk = s_store_sk 
+ group by i_brand
+      ,i_brand_id
+      ,i_manufact_id
+      ,i_manufact
+ order by ext_price desc
+         ,i_brand
+         ,i_brand_id
+         ,i_manufact_id
+         ,i_manufact
+limit 100 ;
+
+-- end query 1 in stream 0 using template query19.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query2.q b/ql/src/test/queries/clientpositive/perf/cbo_query2.q
new file mode 100644
index 0000000..9fcccbf
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query2.q
@@ -0,0 +1,62 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query2.tpl and seed 1819994127
+explain cbo
+with wscs as
+ (select sold_date_sk
+        ,sales_price
+  from (select ws_sold_date_sk sold_date_sk
+              ,ws_ext_sales_price sales_price
+        from web_sales) x
+        union all
+       (select cs_sold_date_sk sold_date_sk
+              ,cs_ext_sales_price sales_price
+        from catalog_sales)),
+ wswscs as 
+ (select d_week_seq,
+        sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
+ from wscs
+     ,date_dim
+ where d_date_sk = sold_date_sk
+ group by d_week_seq)
+ select d_week_seq1
+       ,round(sun_sales1/sun_sales2,2)
+       ,round(mon_sales1/mon_sales2,2)
+       ,round(tue_sales1/tue_sales2,2)
+       ,round(wed_sales1/wed_sales2,2)
+       ,round(thu_sales1/thu_sales2,2)
+       ,round(fri_sales1/fri_sales2,2)
+       ,round(sat_sales1/sat_sales2,2)
+ from
+ (select wswscs.d_week_seq d_week_seq1
+        ,sun_sales sun_sales1
+        ,mon_sales mon_sales1
+        ,tue_sales tue_sales1
+        ,wed_sales wed_sales1
+        ,thu_sales thu_sales1
+        ,fri_sales fri_sales1
+        ,sat_sales sat_sales1
+  from wswscs,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001) y,
+ (select wswscs.d_week_seq d_week_seq2
+        ,sun_sales sun_sales2
+        ,mon_sales mon_sales2
+        ,tue_sales tue_sales2
+        ,wed_sales wed_sales2
+        ,thu_sales thu_sales2
+        ,fri_sales fri_sales2
+        ,sat_sales sat_sales2
+  from wswscs
+      ,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001+1) z
+ where d_week_seq1=d_week_seq2-53
+ order by d_week_seq1;
+
+-- end query 1 in stream 0 using template query2.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query20.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query20.q b/ql/src/test/queries/clientpositive/perf/cbo_query20.q
new file mode 100644
index 0000000..1d361b8
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query20.q
@@ -0,0 +1,31 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query20.tpl and seed 345591136
+explain cbo
+select  i_item_desc 
+       ,i_category 
+       ,i_class 
+       ,i_current_price
+       ,sum(cs_ext_sales_price) as itemrevenue 
+       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
+           (partition by i_class) as revenueratio
+ from	catalog_sales
+     ,item 
+     ,date_dim
+ where cs_item_sk = i_item_sk 
+   and i_category in ('Jewelry', 'Sports', 'Books')
+   and cs_sold_date_sk = d_date_sk
+ and d_date between cast('2001-01-12' as date) 
+ 				and (cast('2001-01-12' as date) + 30 days)
+ group by i_item_id
+         ,i_item_desc 
+         ,i_category
+         ,i_class
+         ,i_current_price
+ order by i_category
+         ,i_class
+         ,i_item_id
+         ,i_item_desc
+         ,revenueratio
+limit 100;
+
+-- end query 1 in stream 0 using template query20.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query21.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query21.q b/ql/src/test/queries/clientpositive/perf/cbo_query21.q
new file mode 100644
index 0000000..90daea0
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query21.q
@@ -0,0 +1,32 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query21.tpl and seed 1819994127
+explain cbo
+select  *
+ from(select w_warehouse_name
+            ,i_item_id
+            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
+	                then inv_quantity_on_hand 
+                      else 0 end) as inv_before
+            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
+                      then inv_quantity_on_hand 
+                      else 0 end) as inv_after
+   from inventory
+       ,warehouse
+       ,item
+       ,date_dim
+   where i_current_price between 0.99 and 1.49
+     and i_item_sk          = inv_item_sk
+     and inv_warehouse_sk   = w_warehouse_sk
+     and inv_date_sk    = d_date_sk
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
+   group by w_warehouse_name, i_item_id) x
+ where (case when inv_before > 0 
+             then inv_after / inv_before 
+             else null
+             end) between 2.0/3.0 and 3.0/2.0
+ order by w_warehouse_name
+         ,i_item_id
+ limit 100;
+
+-- end query 1 in stream 0 using template query21.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query22.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query22.q b/ql/src/test/queries/clientpositive/perf/cbo_query22.q
new file mode 100644
index 0000000..14ceec4
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query22.q
@@ -0,0 +1,24 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query22.tpl and seed 1819994127
+explain cbo
+select  i_product_name
+             ,i_brand
+             ,i_class
+             ,i_category
+             ,avg(inv_quantity_on_hand) qoh
+       from inventory
+           ,date_dim
+           ,item
+           ,warehouse
+       where inv_date_sk=d_date_sk
+              and inv_item_sk=i_item_sk
+              and inv_warehouse_sk = w_warehouse_sk
+              and d_month_seq between 1212 and 1212 + 11
+       group by rollup(i_product_name
+                       ,i_brand
+                       ,i_class
+                       ,i_category)
+order by qoh, i_product_name, i_brand, i_class, i_category
+limit 100;
+
+-- end query 1 in stream 0 using template query22.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query23.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query23.q b/ql/src/test/queries/clientpositive/perf/cbo_query23.q
new file mode 100644
index 0000000..a1c661b
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query23.q
@@ -0,0 +1,52 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query23.tpl and seed 2031708268
+explain cbo
+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
+  *
+from
+ max_store_sales))
+  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;

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query24.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query24.q b/ql/src/test/queries/clientpositive/perf/cbo_query24.q
new file mode 100644
index 0000000..02bcbaf
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query24.q
@@ -0,0 +1,51 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query24.tpl and seed 1220860970
+explain cbo
+with ssales as
+(select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,ca_state
+      ,s_state
+      ,i_color
+      ,i_current_price
+      ,i_manager_id
+      ,i_units
+      ,i_size
+      ,sum(ss_sales_price) netpaid
+from store_sales
+    ,store_returns
+    ,store
+    ,item
+    ,customer
+    ,customer_address
+where ss_ticket_number = sr_ticket_number
+  and ss_item_sk = sr_item_sk
+  and ss_customer_sk = c_customer_sk
+  and ss_item_sk = i_item_sk
+  and ss_store_sk = s_store_sk
+  and c_birth_country = upper(ca_country)
+  and s_zip = ca_zip
+and s_market_id=7
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+        ,ca_state
+        ,s_state
+        ,i_color
+        ,i_current_price
+        ,i_manager_id
+        ,i_units
+        ,i_size)
+select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,sum(netpaid) paid
+from ssales
+where i_color = 'orchid'
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+having sum(netpaid) > (select 0.05*avg(netpaid)
+                                 from ssales)
+;

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query25.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query25.q b/ql/src/test/queries/clientpositive/perf/cbo_query25.q
new file mode 100644
index 0000000..9611e28
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query25.q
@@ -0,0 +1,50 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query25.tpl and seed 1819994127
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query25.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query26.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query26.q b/ql/src/test/queries/clientpositive/perf/cbo_query26.q
new file mode 100644
index 0000000..8b874c8
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query26.q
@@ -0,0 +1,23 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query26.tpl and seed 1930872976
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query26.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query27.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query27.q b/ql/src/test/queries/clientpositive/perf/cbo_query27.q
new file mode 100644
index 0000000..48eaad5
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query27.q
@@ -0,0 +1,25 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query27.tpl and seed 2017787633
+explain cbo
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100;
+
+-- end query 1 in stream 0 using template query27.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query28.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query28.q b/ql/src/test/queries/clientpositive/perf/cbo_query28.q
new file mode 100644
index 0000000..ad9dacd
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query28.q
@@ -0,0 +1,59 @@
+set hive.mapred.mode=nonstrict;
+set hive.optimize.metadataonly=true;
+
+-- start query 1 in stream 0 using template query28.tpl and seed 444293455
+explain cbo
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100;
+
+-- end query 1 in stream 0 using template query28.tpl
+
+set hive.optimize.metadataonly=false;

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query29.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query29.q b/ql/src/test/queries/clientpositive/perf/cbo_query29.q
new file mode 100644
index 0000000..ea9ec12
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query29.q
@@ -0,0 +1,49 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query29.tpl and seed 2031708268
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query29.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query3.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query3.q b/ql/src/test/queries/clientpositive/perf/cbo_query3.q
new file mode 100644
index 0000000..b1bc55b
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query3.q
@@ -0,0 +1,23 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query3.tpl and seed 2031708268
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query3.tpl


[02/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query88.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query88.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query88.q.out
new file mode 100644
index 0000000..08079cd
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query88.q.out
@@ -0,0 +1,946 @@
+Warning: Shuffle Join MERGEJOIN[599][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[600][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[601][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[602][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 9' is a cross product
+Warning: Shuffle Join MERGEJOIN[603][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 10' is a cross product
+Warning: Shuffle Join MERGEJOIN[604][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6]] in Stage 'Reducer 11' is a cross product
+Warning: Shuffle Join MERGEJOIN[605][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7]] in Stage 'Reducer 12' is a cross product
+PREHOOK: query: explain
+select  *
+from
+ (select count(*) h8_30_to_9
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk   
+     and ss_hdemo_sk = household_demographics.hd_demo_sk 
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 8
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
+     and store.s_store_name = 'ese') s1,
+ (select count(*) h9_to_9_30 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 9 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s2,
+ (select count(*) h9_30_to_10 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 9
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s3,
+ (select count(*) h10_to_10_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s4,
+ (select count(*) h10_30_to_11
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s5,
+ (select count(*) h11_to_11_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 11
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s6,
+ (select count(*) h11_30_to_12
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 11
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s7,
+ (select count(*) h12_to_12_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 12
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s8
+PREHOOK: type: QUERY
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  *
+from
+ (select count(*) h8_30_to_9
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk   
+     and ss_hdemo_sk = household_demographics.hd_demo_sk 
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 8
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
+     and store.s_store_name = 'ese') s1,
+ (select count(*) h9_to_9_30 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 9 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s2,
+ (select count(*) h9_30_to_10 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 9
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s3,
+ (select count(*) h10_to_10_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s4,
+ (select count(*) h10_30_to_11
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s5,
+ (select count(*) h11_to_11_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 11
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s6,
+ (select count(*) h11_30_to_12
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 11
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s7,
+ (select count(*) h12_to_12_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 12
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s8
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 14 (BROADCAST_EDGE), Reducer 51 (BROADCAST_EDGE), Reducer 60 (BROADCAST_EDGE)
+Map 68 <- Reducer 19 (BROADCAST_EDGE), Reducer 52 (BROADCAST_EDGE), Reducer 61 (BROADCAST_EDGE)
+Map 69 <- Reducer 24 (BROADCAST_EDGE), Reducer 53 (BROADCAST_EDGE), Reducer 62 (BROADCAST_EDGE)
+Map 70 <- Reducer 29 (BROADCAST_EDGE), Reducer 54 (BROADCAST_EDGE), Reducer 63 (BROADCAST_EDGE)
+Map 71 <- Reducer 34 (BROADCAST_EDGE), Reducer 55 (BROADCAST_EDGE), Reducer 64 (BROADCAST_EDGE)
+Map 72 <- Reducer 39 (BROADCAST_EDGE), Reducer 56 (BROADCAST_EDGE), Reducer 65 (BROADCAST_EDGE)
+Map 73 <- Reducer 44 (BROADCAST_EDGE), Reducer 57 (BROADCAST_EDGE), Reducer 66 (BROADCAST_EDGE)
+Map 74 <- Reducer 49 (BROADCAST_EDGE), Reducer 58 (BROADCAST_EDGE), Reducer 67 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 38 (CUSTOM_SIMPLE_EDGE), Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (CUSTOM_SIMPLE_EDGE), Reducer 43 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (CUSTOM_SIMPLE_EDGE), Reducer 48 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 13 (SIMPLE_EDGE), Map 68 (SIMPLE_EDGE)
+Reducer 16 <- Map 50 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 17 <- Map 59 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
+Reducer 20 <- Map 13 (SIMPLE_EDGE), Map 69 (SIMPLE_EDGE)
+Reducer 21 <- Map 50 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Map 59 (SIMPLE_EDGE), Reducer 21 (SIMPLE_EDGE)
+Reducer 23 <- Reducer 22 (CUSTOM_SIMPLE_EDGE)
+Reducer 24 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Map 13 (SIMPLE_EDGE), Map 70 (SIMPLE_EDGE)
+Reducer 26 <- Map 50 (SIMPLE_EDGE), Reducer 25 (SIMPLE_EDGE)
+Reducer 27 <- Map 59 (SIMPLE_EDGE), Reducer 26 (SIMPLE_EDGE)
+Reducer 28 <- Reducer 27 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 50 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Map 13 (SIMPLE_EDGE), Map 71 (SIMPLE_EDGE)
+Reducer 31 <- Map 50 (SIMPLE_EDGE), Reducer 30 (SIMPLE_EDGE)
+Reducer 32 <- Map 59 (SIMPLE_EDGE), Reducer 31 (SIMPLE_EDGE)
+Reducer 33 <- Reducer 32 (CUSTOM_SIMPLE_EDGE)
+Reducer 34 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 35 <- Map 13 (SIMPLE_EDGE), Map 72 (SIMPLE_EDGE)
+Reducer 36 <- Map 50 (SIMPLE_EDGE), Reducer 35 (SIMPLE_EDGE)
+Reducer 37 <- Map 59 (SIMPLE_EDGE), Reducer 36 (SIMPLE_EDGE)
+Reducer 38 <- Reducer 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 39 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Map 59 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 40 <- Map 13 (SIMPLE_EDGE), Map 73 (SIMPLE_EDGE)
+Reducer 41 <- Map 50 (SIMPLE_EDGE), Reducer 40 (SIMPLE_EDGE)
+Reducer 42 <- Map 59 (SIMPLE_EDGE), Reducer 41 (SIMPLE_EDGE)
+Reducer 43 <- Reducer 42 (CUSTOM_SIMPLE_EDGE)
+Reducer 44 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 45 <- Map 13 (SIMPLE_EDGE), Map 74 (SIMPLE_EDGE)
+Reducer 46 <- Map 50 (SIMPLE_EDGE), Reducer 45 (SIMPLE_EDGE)
+Reducer 47 <- Map 59 (SIMPLE_EDGE), Reducer 46 (SIMPLE_EDGE)
+Reducer 48 <- Reducer 47 (CUSTOM_SIMPLE_EDGE)
+Reducer 49 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 51 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 52 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 53 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 54 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 55 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 56 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 57 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 58 <- Map 50 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Reducer 18 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 60 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 61 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 62 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 63 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 64 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 65 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 66 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 67 <- Map 59 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Reducer 23 (CUSTOM_SIMPLE_EDGE), Reducer 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Reducer 28 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Reducer 33 (CUSTOM_SIMPLE_EDGE), Reducer 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 12
+      File Output Operator [FS_230]
+        Select Operator [SEL_229] (rows=1 width=64)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          Merge Join Operator [MERGEJOIN_605] (rows=1 width=64)
+            Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 11 [CUSTOM_SIMPLE_EDGE]
+            PARTITION_ONLY_SHUFFLE [RS_226]
+              Merge Join Operator [MERGEJOIN_604] (rows=1 width=56)
+                Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+              <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+                PARTITION_ONLY_SHUFFLE [RS_223]
+                  Merge Join Operator [MERGEJOIN_603] (rows=1 width=48)
+                    Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                  <-Reducer 38 [CUSTOM_SIMPLE_EDGE] vectorized
+                    PARTITION_ONLY_SHUFFLE [RS_787]
+                      Group By Operator [GBY_786] (rows=1 width=8)
+                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                      <-Reducer 37 [CUSTOM_SIMPLE_EDGE]
+                        PARTITION_ONLY_SHUFFLE [RS_153]
+                          Group By Operator [GBY_152] (rows=1 width=8)
+                            Output:["_col0"],aggregations:["count()"]
+                            Merge Join Operator [MERGEJOIN_592] (rows=1352994 width=8)
+                              Conds:RS_148._col2=RS_704._col0(Inner)
+                            <-Map 59 [SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_704]
+                                PartitionCols:_col0
+                                Select Operator [SEL_693] (rows=155 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_692] (rows=155 width=92)
+                                    predicate:(s_store_name = 'ese')
+                                    TableScan [TS_9] (rows=1704 width=92)
+                                      default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name"]
+                            <-Reducer 36 [SIMPLE_EDGE]
+                              SHUFFLE [RS_148]
+                                PartitionCols:_col2
+                                Merge Join Operator [MERGEJOIN_591] (rows=1842898 width=0)
+                                  Conds:RS_145._col0=RS_668._col0(Inner),Output:["_col2"]
+                                <-Map 50 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_668]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_655] (rows=1515 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_647] (rows=1515 width=12)
+                                        predicate:((t_hour = 10) and (t_minute < 30))
+                                        TableScan [TS_6] (rows=86400 width=12)
+                                          default@time_dim,time_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["t_time_sk","t_hour","t_minute"]
+                                <-Reducer 35 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_145]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_590] (rows=56928540 width=4)
+                                      Conds:RS_785._col1=RS_618._col0(Inner),Output:["_col0","_col2"]
+                                    <-Map 13 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_618]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_607] (rows=817 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_606] (rows=817 width=12)
+                                            predicate:((((hd_dep_count = 3) and hd_vehicle_count is not null) or ((hd_dep_count = 0) and (hd_vehicle_count <= 2)) or ((hd_dep_count = 1) and (hd_vehicle_count <= 3))) and (hd_dep_count) IN (3, 0, 1) and (hd_vehicle_count <= 5))
+                                            TableScan [TS_3] (rows=7200 width=12)
+                                              default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_dep_count","hd_vehicle_count"]
+                                    <-Map 72 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_785]
+                                        PartitionCols:_col1
+                                        Select Operator [SEL_784] (rows=501695814 width=11)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_783] (rows=501695814 width=11)
+                                            predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_143_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_143_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_143_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_146_time_dim_t_time_sk_min) AND DynamicValue(RS_146_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_146_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_149_store_s_store_sk_min) AND DynamicValue(RS_149_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_149_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                            TableScan [TS_130] (rows=575995635 width=11)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                            <-Reducer 39 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_778]
+                                                Group By Operator [GBY_777] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_637]
+                                                    Group By Operator [GBY_629] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_619] (rows=817 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_607]
+                                            <-Reducer 56 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_780]
+                                                Group By Operator [GBY_779] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_687]
+                                                    Group By Operator [GBY_679] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_669] (rows=1515 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_655]
+                                            <-Reducer 65 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_782]
+                                                Group By Operator [GBY_781] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_723]
+                                                    Group By Operator [GBY_715] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_705] (rows=155 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_693]
+                  <-Reducer 9 [CUSTOM_SIMPLE_EDGE]
+                    PARTITION_ONLY_SHUFFLE [RS_220]
+                      Merge Join Operator [MERGEJOIN_602] (rows=1 width=40)
+                        Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4"]
+                      <-Reducer 33 [CUSTOM_SIMPLE_EDGE] vectorized
+                        PARTITION_ONLY_SHUFFLE [RS_776]
+                          Group By Operator [GBY_775] (rows=1 width=8)
+                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                          <-Reducer 32 [CUSTOM_SIMPLE_EDGE]
+                            PARTITION_ONLY_SHUFFLE [RS_127]
+                              Group By Operator [GBY_126] (rows=1 width=8)
+                                Output:["_col0"],aggregations:["count()"]
+                                Merge Join Operator [MERGEJOIN_589] (rows=1352994 width=8)
+                                  Conds:RS_122._col2=RS_702._col0(Inner)
+                                <-Map 59 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_702]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Select Operator [SEL_693]
+                                <-Reducer 31 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_122]
+                                    PartitionCols:_col2
+                                    Merge Join Operator [MERGEJOIN_588] (rows=1842898 width=0)
+                                      Conds:RS_119._col0=RS_666._col0(Inner),Output:["_col2"]
+                                    <-Map 50 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_666]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_654] (rows=1515 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_646] (rows=1515 width=12)
+                                            predicate:((t_hour = 10) and (t_minute >= 30))
+                                             Please refer to the previous TableScan [TS_6]
+                                    <-Reducer 30 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_119]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_587] (rows=56928540 width=4)
+                                          Conds:RS_774._col1=RS_616._col0(Inner),Output:["_col0","_col2"]
+                                        <-Map 13 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_616]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_607]
+                                        <-Map 71 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_774]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_773] (rows=501695814 width=11)
+                                              Output:["_col0","_col1","_col2"]
+                                              Filter Operator [FIL_772] (rows=501695814 width=11)
+                                                predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_117_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_117_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_117_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_120_time_dim_t_time_sk_min) AND DynamicValue(RS_120_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_120_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_123_store_s_store_sk_min) AND DynamicValue(RS_123_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_123_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_104] (rows=575995635 width=11)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                                <-Reducer 34 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_767]
+                                                    Group By Operator [GBY_766] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_636]
+                                                        Group By Operator [GBY_628] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_617] (rows=817 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_607]
+                                                <-Reducer 55 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_769]
+                                                    Group By Operator [GBY_768] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_686]
+                                                        Group By Operator [GBY_678] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_667] (rows=1515 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_654]
+                                                <-Reducer 64 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_771]
+                                                    Group By Operator [GBY_770] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_722]
+                                                        Group By Operator [GBY_714] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_703] (rows=155 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_693]
+                      <-Reducer 8 [CUSTOM_SIMPLE_EDGE]
+                        PARTITION_ONLY_SHUFFLE [RS_217]
+                          Merge Join Operator [MERGEJOIN_601] (rows=1 width=32)
+                            Conds:(Inner),Output:["_col0","_col1","_col2","_col3"]
+                          <-Reducer 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_765]
+                              Group By Operator [GBY_764] (rows=1 width=8)
+                                Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                              <-Reducer 27 [CUSTOM_SIMPLE_EDGE]
+                                PARTITION_ONLY_SHUFFLE [RS_101]
+                                  Group By Operator [GBY_100] (rows=1 width=8)
+                                    Output:["_col0"],aggregations:["count()"]
+                                    Merge Join Operator [MERGEJOIN_586] (rows=1352994 width=8)
+                                      Conds:RS_96._col2=RS_700._col0(Inner)
+                                    <-Map 59 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_700]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_693]
+                                    <-Reducer 26 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_96]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_585] (rows=1842898 width=0)
+                                          Conds:RS_93._col0=RS_664._col0(Inner),Output:["_col2"]
+                                        <-Map 50 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_664]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_653] (rows=1515 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_645] (rows=1515 width=12)
+                                                predicate:((t_hour = 11) and (t_minute < 30))
+                                                 Please refer to the previous TableScan [TS_6]
+                                        <-Reducer 25 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_93]
+                                            PartitionCols:_col0
+                                            Merge Join Operator [MERGEJOIN_584] (rows=56928540 width=4)
+                                              Conds:RS_763._col1=RS_614._col0(Inner),Output:["_col0","_col2"]
+                                            <-Map 13 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_614]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_607]
+                                            <-Map 70 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_763]
+                                                PartitionCols:_col1
+                                                Select Operator [SEL_762] (rows=501695814 width=11)
+                                                  Output:["_col0","_col1","_col2"]
+                                                  Filter Operator [FIL_761] (rows=501695814 width=11)
+                                                    predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_91_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_91_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_91_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_94_time_dim_t_time_sk_min) AND DynamicValue(RS_94_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_94_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_97_store_s_store_sk_min) AND DynamicValue(RS_97_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_97_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                                    TableScan [TS_78] (rows=575995635 width=11)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                                    <-Reducer 29 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_756]
+                                                        Group By Operator [GBY_755] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_635]
+                                                            Group By Operator [GBY_627] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_615] (rows=817 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_607]
+                                                    <-Reducer 54 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_758]
+                                                        Group By Operator [GBY_757] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_685]
+                                                            Group By Operator [GBY_677] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_665] (rows=1515 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_653]
+                                                    <-Reducer 63 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_760]
+                                                        Group By Operator [GBY_759] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_721]
+                                                            Group By Operator [GBY_713] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_701] (rows=155 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_693]
+                          <-Reducer 7 [CUSTOM_SIMPLE_EDGE]
+                            PARTITION_ONLY_SHUFFLE [RS_214]
+                              Merge Join Operator [MERGEJOIN_600] (rows=1 width=24)
+                                Conds:(Inner),Output:["_col0","_col1","_col2"]
+                              <-Reducer 23 [CUSTOM_SIMPLE_EDGE] vectorized
+                                PARTITION_ONLY_SHUFFLE [RS_754]
+                                  Group By Operator [GBY_753] (rows=1 width=8)
+                                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                  <-Reducer 22 [CUSTOM_SIMPLE_EDGE]
+                                    PARTITION_ONLY_SHUFFLE [RS_75]
+                                      Group By Operator [GBY_74] (rows=1 width=8)
+                                        Output:["_col0"],aggregations:["count()"]
+                                        Merge Join Operator [MERGEJOIN_583] (rows=1352994 width=8)
+                                          Conds:RS_70._col2=RS_698._col0(Inner)
+                                        <-Map 59 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_698]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_693]
+                                        <-Reducer 21 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_70]
+                                            PartitionCols:_col2
+                                            Merge Join Operator [MERGEJOIN_582] (rows=1842898 width=0)
+                                              Conds:RS_67._col0=RS_662._col0(Inner),Output:["_col2"]
+                                            <-Map 50 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_662]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_652] (rows=1515 width=4)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_644] (rows=1515 width=12)
+                                                    predicate:((t_hour = 11) and (t_minute >= 30))
+                                                     Please refer to the previous TableScan [TS_6]
+                                            <-Reducer 20 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_67]
+                                                PartitionCols:_col0
+                                                Merge Join Operator [MERGEJOIN_581] (rows=56928540 width=4)
+                                                  Conds:RS_752._col1=RS_612._col0(Inner),Output:["_col0","_col2"]
+                                                <-Map 13 [SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_612]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_607]
+                                                <-Map 69 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_752]
+                                                    PartitionCols:_col1
+                                                    Select Operator [SEL_751] (rows=501695814 width=11)
+                                                      Output:["_col0","_col1","_col2"]
+                                                      Filter Operator [FIL_750] (rows=501695814 width=11)
+                                                        predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_65_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_65_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_65_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_68_time_dim_t_time_sk_min) AND DynamicValue(RS_68_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_68_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_71_store_s_store_sk_min) AND DynamicValue(RS_71_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_71_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                                        TableScan [TS_52] (rows=575995635 width=11)
+                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                                        <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_745]
+                                                            Group By Operator [GBY_744] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              PARTITION_ONLY_SHUFFLE [RS_634]
+                                                                Group By Operator [GBY_626] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_613] (rows=817 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_607]
+                                                        <-Reducer 53 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_747]
+                                                            Group By Operator [GBY_746] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              PARTITION_ONLY_SHUFFLE [RS_684]
+                                                                Group By Operator [GBY_676] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_663] (rows=1515 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_652]
+                                                        <-Reducer 62 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_749]
+                                                            Group By Operator [GBY_748] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              PARTITION_ONLY_SHUFFLE [RS_720]
+                                                                Group By Operator [GBY_712] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_699] (rows=155 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_693]
+                              <-Reducer 6 [CUSTOM_SIMPLE_EDGE]
+                                PARTITION_ONLY_SHUFFLE [RS_211]
+                                  Merge Join Operator [MERGEJOIN_599] (rows=1 width=16)
+                                    Conds:(Inner),Output:["_col0","_col1"]
+                                  <-Reducer 18 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_743]
+                                      Group By Operator [GBY_742] (rows=1 width=8)
+                                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                      <-Reducer 17 [CUSTOM_SIMPLE_EDGE]
+                                        PARTITION_ONLY_SHUFFLE [RS_49]
+                                          Group By Operator [GBY_48] (rows=1 width=8)
+                                            Output:["_col0"],aggregations:["count()"]
+                                            Merge Join Operator [MERGEJOIN_580] (rows=1352994 width=8)
+                                              Conds:RS_44._col2=RS_696._col0(Inner)
+                                            <-Map 59 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_696]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_693]
+                                            <-Reducer 16 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_44]
+                                                PartitionCols:_col2
+                                                Merge Join Operator [MERGEJOIN_579] (rows=1842898 width=0)
+                                                  Conds:RS_41._col0=RS_660._col0(Inner),Output:["_col2"]
+                                                <-Map 50 [SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_660]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_651] (rows=1515 width=4)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_643] (rows=1515 width=12)
+                                                        predicate:((t_hour = 12) and (t_minute < 30))
+                                                         Please refer to the previous TableScan [TS_6]
+                                                <-Reducer 15 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_41]
+                                                    PartitionCols:_col0
+                                                    Merge Join Operator [MERGEJOIN_578] (rows=56928540 width=4)
+                                                      Conds:RS_741._col1=RS_610._col0(Inner),Output:["_col0","_col2"]
+                                                    <-Map 13 [SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_610]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_607]
+                                                    <-Map 68 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_741]
+                                                        PartitionCols:_col1
+                                                        Select Operator [SEL_740] (rows=501695814 width=11)
+                                                          Output:["_col0","_col1","_col2"]
+                                                          Filter Operator [FIL_739] (rows=501695814 width=11)
+                                                            predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_39_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_39_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_39_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_42_time_dim_t_time_sk_min) AND DynamicValue(RS_42_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_42_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_45_store_s_store_sk_min) AND DynamicValue(RS_45_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_45_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                                            TableScan [TS_26] (rows=575995635 width=11)
+                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                                            <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_734]
+                                                                Group By Operator [GBY_733] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_633]
+                                                                    Group By Operator [GBY_625] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_611] (rows=817 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_607]
+                                                            <-Reducer 52 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_736]
+                                                                Group By Operator [GBY_735] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_683]
+                                                                    Group By Operator [GBY_675] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_661] (rows=1515 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_651]
+                                                            <-Reducer 61 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_738]
+                                                                Group By Operator [GBY_737] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_719]
+                                                                    Group By Operator [GBY_711] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_697] (rows=155 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_693]
+                                  <-Reducer 5 [CUSTOM_SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_732]
+                                      Group By Operator [GBY_731] (rows=1 width=8)
+                                        Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                      <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                        PARTITION_ONLY_SHUFFLE [RS_23]
+                                          Group By Operator [GBY_22] (rows=1 width=8)
+                                            Output:["_col0"],aggregations:["count()"]
+                                            Merge Join Operator [MERGEJOIN_577] (rows=1352994 width=8)
+                                              Conds:RS_18._col2=RS_694._col0(Inner)
+                                            <-Map 59 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_694]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_693]
+                                            <-Reducer 3 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_18]
+                                                PartitionCols:_col2
+                                                Merge Join Operator [MERGEJOIN_576] (rows=1842898 width=0)
+                                                  Conds:RS_15._col0=RS_658._col0(Inner),Output:["_col2"]
+                                                <-Map 50 [SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_658]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_650] (rows=1515 width=4)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_642] (rows=1515 width=12)
+                                                        predicate:((t_hour = 8) and (t_minute >= 30))
+                                                         Please refer to the previous TableScan [TS_6]
+                                                <-Reducer 2 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_15]
+                                                    PartitionCols:_col0
+                                                    Merge Join Operator [MERGEJOIN_575] (rows=56928540 width=4)
+                                                      Conds:RS_730._col1=RS_608._col0(Inner),Output:["_col0","_col2"]
+                                                    <-Map 13 [SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_608]
+                                                        PartitionCols:_col0
+                                                         Please refer to the previous Select Operator [SEL_607]
+                                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_730]
+                                                        PartitionCols:_col1
+                                                        Select Operator [SEL_729] (rows=501695814 width=11)
+                                                          Output:["_col0","_col1","_col2"]
+                                                          Filter Operator [FIL_728] (rows=501695814 width=11)
+                                                            predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_13_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_13_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_13_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_16_time_dim_t_time_sk_min) AND DynamicValue(RS_16_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_16_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_19_store_s_store_sk_min) AND DynamicValue(RS_19_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_19_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                                            TableScan [TS_0] (rows=575995635 width=11)
+                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                                            <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_641]
+                                                                Group By Operator [GBY_640] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_632]
+                                                                    Group By Operator [GBY_624] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_609] (rows=817 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_607]
+                                                            <-Reducer 51 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_691]
+                                                                Group By Operator [GBY_690] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_682]
+                                                                    Group By Operator [GBY_674] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_659] (rows=1515 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_650]
+                                                            <-Reducer 60 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_727]
+                                                                Group By Operator [GBY_726] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  PARTITION_ONLY_SHUFFLE [RS_718]
+                                                                    Group By Operator [GBY_710] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_695] (rows=155 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_693]
+              <-Reducer 43 [CUSTOM_SIMPLE_EDGE] vectorized
+                PARTITION_ONLY_SHUFFLE [RS_798]
+                  Group By Operator [GBY_797] (rows=1 width=8)
+                    Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                  <-Reducer 42 [CUSTOM_SIMPLE_EDGE]
+                    PARTITION_ONLY_SHUFFLE [RS_179]
+                      Group By Operator [GBY_178] (rows=1 width=8)
+                        Output:["_col0"],aggregations:["count()"]
+                        Merge Join Operator [MERGEJOIN_595] (rows=1352994 width=8)
+                          Conds:RS_174._col2=RS_706._col0(Inner)
+                        <-Map 59 [SIMPLE_EDGE] vectorized
+                          PARTITION_ONLY_SHUFFLE [RS_706]
+                            PartitionCols:_col0
+                             Please refer to the previous Select Operator [SEL_693]
+                        <-Reducer 41 [SIMPLE_EDGE]
+                          SHUFFLE [RS_174]
+                            PartitionCols:_col2
+                            Merge Join Operator [MERGEJOIN_594] (rows=1842898 width=0)
+                              Conds:RS_171._col0=RS_670._col0(Inner),Output:["_col2"]
+                            <-Map 50 [SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_670]
+                                PartitionCols:_col0
+                                Select Operator [SEL_656] (rows=1515 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_648] (rows=1515 width=12)
+                                    predicate:((t_hour = 9) and (t_minute >= 30))
+                                     Please refer to the previous TableScan [TS_6]
+                            <-Reducer 40 [SIMPLE_EDGE]
+                              SHUFFLE [RS_171]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_593] (rows=56928540 width=4)
+                                  Conds:RS_796._col1=RS_620._col0(Inner),Output:["_col0","_col2"]
+                                <-Map 13 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_620]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Select Operator [SEL_607]
+                                <-Map 73 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_796]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_795] (rows=501695814 width=11)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_794] (rows=501695814 width=11)
+                                        predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_169_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_169_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_169_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_172_time_dim_t_time_sk_min) AND DynamicValue(RS_172_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_172_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_175_store_s_store_sk_min) AND DynamicValue(RS_175_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_175_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                        TableScan [TS_156] (rows=575995635 width=11)
+                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                        <-Reducer 44 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_789]
+                                            Group By Operator [GBY_788] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_638]
+                                                Group By Operator [GBY_630] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_621] (rows=817 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_607]
+                                        <-Reducer 57 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_791]
+                                            Group By Operator [GBY_790] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_688]
+                                                Group By Operator [GBY_680] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_671] (rows=1515 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_656]
+                                        <-Reducer 66 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_793]
+                                            Group By Operator [GBY_792] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_724]
+                                                Group By Operator [GBY_716] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_707] (rows=155 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_693]
+          <-Reducer 48 [CUSTOM_SIMPLE_EDGE] vectorized
+            PARTITION_ONLY_SHUFFLE [RS_809]
+              Group By Operator [GBY_808] (rows=1 width=8)
+                Output:["_col0"],aggregations:["count(VALUE._col0)"]
+              <-Reducer 47 [CUSTOM_SIMPLE_EDGE]
+                PARTITION_ONLY_SHUFFLE [RS_205]
+                  Group By Operator [GBY_204] (rows=1 width=8)
+                    Output:["_col0"],aggregations:["count()"]
+                    Merge Join Operator [MERGEJOIN_598] (rows=1352994 width=8)
+                      Conds:RS_200._col2=RS_708._col0(Inner)
+                    <-Map 59 [SIMPLE_EDGE] vectorized
+                      PARTITION_ONLY_SHUFFLE [RS_708]
+                        PartitionCols:_col0
+                         Please refer to the previous Select Operator [SEL_693]
+                    <-Reducer 46 [SIMPLE_EDGE]
+                      SHUFFLE [RS_200]
+                        PartitionCols:_col2
+                        Merge Join Operator [MERGEJOIN_597] (rows=1842898 width=0)
+                          Conds:RS_197._col0=RS_672._col0(Inner),Output:["_col2"]
+                        <-Map 50 [SIMPLE_EDGE] vectorized
+                          PARTITION_ONLY_SHUFFLE [RS_672]
+                            PartitionCols:_col0
+                            Select Operator [SEL_657] (rows=1515 width=4)
+                              Output:["_col0"]
+                              Filter Operator [FIL_649] (rows=1515 width=12)
+                                predicate:((t_hour = 9) and (t_minute < 30))
+                                 Please refer to the previous TableScan [TS_6]
+                        <-Reducer 45 [SIMPLE_EDGE]
+                          SHUFFLE [RS_197]
+                            PartitionCols:_col0
+                            Merge Join Operator [MERGEJOIN_596] (rows=56928540 width=4)
+                              Conds:RS_807._col1=RS_622._col0(Inner),Output:["_col0","_col2"]
+                            <-Map 13 [SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_622]
+                                PartitionCols:_col0
+                                 Please refer to the previous Select Operator [SEL_607]
+                            <-Map 74 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_807]
+                                PartitionCols:_col1
+                                Select Operator [SEL_806] (rows=501695814 width=11)
+                                  Output:["_col0","_col1","_col2"]
+                                  Filter Operator [FIL_805] (rows=501695814 width=11)
+                                    predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_195_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_195_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_195_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_198_time_dim_t_time_sk_min) AND DynamicValue(RS_198_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_198_time_dim_t_time_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_201_store_s_store_sk_min) AND DynamicValue(RS_201_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_201_store_s_store_sk_bloom_filter))) and ss_hdemo_sk is not null and ss_sold_time_sk is not null and ss_store_sk is not null)
+                                    TableScan [TS_182] (rows=575995635 width=11)
+                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_time_sk","ss_hdemo_sk","ss_store_sk"]
+                                    <-Reducer 49 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_800]
+                                        Group By Operator [GBY_799] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_639]
+                                            Group By Operator [GBY_631] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_623] (rows=817 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_607]
+                                    <-Reducer 58 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_802]
+                                        Group By Operator [GBY_801] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 50 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_689]
+                                            Group By Operator [GBY_681] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_673] (rows=1515 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_657]
+                                    <-Reducer 67 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_804]
+                                        Group By Operator [GBY_803] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 59 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_725]
+                                            Group By Operator [GBY_717] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_709] (rows=155 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_693]
+


[57/75] [abbrv] hive git commit: HIVE-20701: Allow HiveStreaming to receive a key value to commit atomically together with the transaction (Jaume M reviewed by Prasanth Jayachandran)

Posted by se...@apache.org.
HIVE-20701: Allow HiveStreaming to receive a key value to commit atomically together with the transaction (Jaume M reviewed by Prasanth Jayachandran)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/7765e90a
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/7765e90a
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/7765e90a

Branch: refs/heads/master-tez092
Commit: 7765e90aad44747860b3c1adbe8a4857d864912d
Parents: cbe3228
Author: Jaume Marhuenda <ja...@gmail.com>
Authored: Mon Oct 22 14:18:20 2018 -0700
Committer: Prasanth Jayachandran <pr...@apache.org>
Committed: Mon Oct 22 14:18:49 2018 -0700

----------------------------------------------------------------------
 .../streaming/AbstractStreamingTransaction.java |  6 ++-
 .../hive/streaming/HiveStreamingConnection.java | 13 +++++--
 .../hive/streaming/StreamingConnection.java     | 23 ++++++++---
 .../hive/streaming/StreamingTransaction.java    | 14 ++++++-
 .../apache/hive/streaming/TransactionBatch.java | 26 +++++++++++--
 .../streaming/UnManagedSingleTransaction.java   |  3 +-
 .../apache/hive/streaming/TestStreaming.java    | 41 +++++++++++++++++++-
 7 files changed, 109 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/7765e90a/streaming/src/java/org/apache/hive/streaming/AbstractStreamingTransaction.java
----------------------------------------------------------------------
diff --git a/streaming/src/java/org/apache/hive/streaming/AbstractStreamingTransaction.java b/streaming/src/java/org/apache/hive/streaming/AbstractStreamingTransaction.java
index a99fdba..6ab3ffe 100644
--- a/streaming/src/java/org/apache/hive/streaming/AbstractStreamingTransaction.java
+++ b/streaming/src/java/org/apache/hive/streaming/AbstractStreamingTransaction.java
@@ -22,6 +22,7 @@ import org.apache.hadoop.hive.metastore.api.TxnToWriteId;
 
 import java.io.InputStream;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
@@ -151,6 +152,9 @@ abstract class AbstractStreamingTransaction
   }
 
   public void commit() throws StreamingException {
-    commitWithPartitions(null);
+    commit(null);
+  }
+  public void commit(Set<String> partitions) throws StreamingException {
+    commit(partitions, null, null);
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/7765e90a/streaming/src/java/org/apache/hive/streaming/HiveStreamingConnection.java
----------------------------------------------------------------------
diff --git a/streaming/src/java/org/apache/hive/streaming/HiveStreamingConnection.java b/streaming/src/java/org/apache/hive/streaming/HiveStreamingConnection.java
index f79b844..74fc531 100644
--- a/streaming/src/java/org/apache/hive/streaming/HiveStreamingConnection.java
+++ b/streaming/src/java/org/apache/hive/streaming/HiveStreamingConnection.java
@@ -146,6 +146,7 @@ public class HiveStreamingConnection implements StreamingConnection {
   private boolean manageTransactions;
   private int countTransactions = 0;
   private Set<String> partitions;
+  private Long tableId;
 
   private HiveStreamingConnection(Builder builder) throws StreamingException {
     this.database = builder.database.toLowerCase();
@@ -574,12 +575,18 @@ public class HiveStreamingConnection implements StreamingConnection {
 
   @Override
   public void commitTransaction() throws StreamingException {
-    commitTransactionWithPartition(null);
+    commitTransaction(null);
   }
 
   @Override
-  public void commitTransactionWithPartition(Set<String> partitions)
+  public void commitTransaction(Set<String> partitions)
       throws StreamingException {
+    commitTransaction(partitions, null, null);
+  }
+
+  @Override
+  public void commitTransaction(Set<String> partitions, String key,
+      String value) throws StreamingException {
     checkState();
 
     Set<String> createdPartitions = new HashSet<>();
@@ -598,7 +605,7 @@ public class HiveStreamingConnection implements StreamingConnection {
       connectionStats.incrementTotalPartitions(partitions.size());
     }
 
-    currentTransactionBatch.commitWithPartitions(createdPartitions);
+    currentTransactionBatch.commit(createdPartitions, key, value);
     this.partitions.addAll(
         currentTransactionBatch.getPartitions());
     connectionStats.incrementCreatedPartitions(createdPartitions.size());

http://git-wip-us.apache.org/repos/asf/hive/blob/7765e90a/streaming/src/java/org/apache/hive/streaming/StreamingConnection.java
----------------------------------------------------------------------
diff --git a/streaming/src/java/org/apache/hive/streaming/StreamingConnection.java b/streaming/src/java/org/apache/hive/streaming/StreamingConnection.java
index 92016e5..ba4c6a5 100644
--- a/streaming/src/java/org/apache/hive/streaming/StreamingConnection.java
+++ b/streaming/src/java/org/apache/hive/streaming/StreamingConnection.java
@@ -66,13 +66,26 @@ public interface StreamingConnection extends ConnectionInfo, PartitionHandler {
   void commitTransaction() throws StreamingException;
 
   /**
-   * Commit a transaction to make the writes visible for readers. Include
-   * other partitions that may have been added independently.
-   *
+   * Commits the transaction together with a key value atomically.
    * @param partitions - extra partitions to commit.
-   * @throws StreamingException - if there are errors when committing the open transaction.
+   * @param key - key to commit.
+   * @param value - value to commit.
+   * @throws StreamingException - if there are errors when committing
+   * the open transaction.
    */
-  default void commitTransactionWithPartition(@Nullable Set<String> partitions)
+  default void commitTransaction(@Nullable Set<String> partitions,
+      @Nullable String key, @Nullable String value) throws StreamingException {
+    throw new UnsupportedOperationException();
+  }
+
+    /**
+     * Commit a transaction to make the writes visible for readers. Include
+     * other partitions that may have been added independently.
+     *
+     * @param partitions - extra partitions to commit.
+     * @throws StreamingException - if there are errors when committing the open transaction.
+     */
+  default void commitTransaction(@Nullable Set<String> partitions)
       throws StreamingException {
     throw new UnsupportedOperationException();
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/7765e90a/streaming/src/java/org/apache/hive/streaming/StreamingTransaction.java
----------------------------------------------------------------------
diff --git a/streaming/src/java/org/apache/hive/streaming/StreamingTransaction.java b/streaming/src/java/org/apache/hive/streaming/StreamingTransaction.java
index 83b2f15..c0ee034 100644
--- a/streaming/src/java/org/apache/hive/streaming/StreamingTransaction.java
+++ b/streaming/src/java/org/apache/hive/streaming/StreamingTransaction.java
@@ -19,6 +19,8 @@
 package org.apache.hive.streaming;
 
 import org.apache.hadoop.hive.metastore.api.TxnToWriteId;
+
+import javax.annotation.Nullable;
 import java.io.InputStream;
 import java.util.List;
 import java.util.Set;
@@ -45,7 +47,17 @@ public interface StreamingTransaction {
    * @param partitions to commit.
    * @throws StreamingException
    */
-  void commitWithPartitions(Set<String> partitions) throws StreamingException;
+  void commit(@Nullable Set<String> partitions) throws StreamingException;
+
+  /**
+   * Commits atomically together with a key and a value.
+   * @param partitions to commit.
+   * @param key to commit.
+   * @param value to commit.
+   * @throws StreamingException
+   */
+  void commit(@Nullable Set<String> partitions, @Nullable String key,
+      @Nullable String value) throws StreamingException;
 
   /**
    * Abort a transaction.

http://git-wip-us.apache.org/repos/asf/hive/blob/7765e90a/streaming/src/java/org/apache/hive/streaming/TransactionBatch.java
----------------------------------------------------------------------
diff --git a/streaming/src/java/org/apache/hive/streaming/TransactionBatch.java b/streaming/src/java/org/apache/hive/streaming/TransactionBatch.java
index dabbe21..a625759 100644
--- a/streaming/src/java/org/apache/hive/streaming/TransactionBatch.java
+++ b/streaming/src/java/org/apache/hive/streaming/TransactionBatch.java
@@ -80,6 +80,11 @@ public class TransactionBatch extends AbstractStreamingTransaction {
 
   private String agentInfo;
   private int numTxns;
+
+  /**
+   * Id of the table from the streaming connection.
+   */
+  private final long tableId;
   /**
    * Tracks the state of each transaction.
    */
@@ -107,6 +112,7 @@ public class TransactionBatch extends AbstractStreamingTransaction {
       this.recordWriter = conn.getRecordWriter();
       this.agentInfo = conn.getAgentInfo();
       this.numTxns = conn.getTransactionBatchSize();
+      this.tableId = conn.getTable().getTTable().getId();
 
       setupHeartBeatThread();
 
@@ -244,19 +250,26 @@ public class TransactionBatch extends AbstractStreamingTransaction {
     }
   }
 
-  public void commitWithPartitions(Set<String> partitions) throws StreamingException {
+  public void commit(Set<String> partitions, String key, String value)
+      throws StreamingException {
     checkIsClosed();
     boolean success = false;
     try {
-      commitImpl(partitions);
+      commitImpl(partitions, key, value);
       success = true;
     } finally {
       markDead(success);
     }
   }
 
-  private void commitImpl(Set<String> partitions) throws StreamingException {
+  private void commitImpl(Set<String> partitions, String key, String value)
+      throws StreamingException {
     try {
+      if ((key == null && value != null) || (key != null && value == null)) {
+        throw new StreamingException(String.format(
+            "If key is set, the value should be as well and vice versa,"
+                + " key, value = %s, %s", key, value));
+      }
       recordWriter.flush();
       TxnToWriteId txnToWriteId = txnToWriteIds.get(currentTxnIndex);
       if (conn.isDynamicPartitioning()) {
@@ -274,7 +287,12 @@ public class TransactionBatch extends AbstractStreamingTransaction {
       }
       transactionLock.lock();
       try {
-        conn.getMSC().commitTxn(txnToWriteId.getTxnId());
+        if (key != null) {
+          conn.getMSC().commitTxnWithKeyValue(txnToWriteId.getTxnId(),
+              tableId, key, value);
+        } else {
+          conn.getMSC().commitTxn(txnToWriteId.getTxnId());
+        }
         // increment the min txn id so that heartbeat thread will heartbeat only from the next open transaction.
         // the current transaction is going to committed or fail, so don't need heartbeat for current transaction.
         if (currentTxnIndex + 1 < txnToWriteIds.size()) {

http://git-wip-us.apache.org/repos/asf/hive/blob/7765e90a/streaming/src/java/org/apache/hive/streaming/UnManagedSingleTransaction.java
----------------------------------------------------------------------
diff --git a/streaming/src/java/org/apache/hive/streaming/UnManagedSingleTransaction.java b/streaming/src/java/org/apache/hive/streaming/UnManagedSingleTransaction.java
index 68b0906..75779d5 100644
--- a/streaming/src/java/org/apache/hive/streaming/UnManagedSingleTransaction.java
+++ b/streaming/src/java/org/apache/hive/streaming/UnManagedSingleTransaction.java
@@ -69,7 +69,8 @@ public class UnManagedSingleTransaction extends AbstractStreamingTransaction {
   }
 
   @Override
-  public void commitWithPartitions(Set<String> partitions) throws StreamingException {
+  public void commit(Set<String> partitions, String key, String value)
+      throws StreamingException {
     checkIsClosed();
     boolean success = false;
     try {

http://git-wip-us.apache.org/repos/asf/hive/blob/7765e90a/streaming/src/test/org/apache/hive/streaming/TestStreaming.java
----------------------------------------------------------------------
diff --git a/streaming/src/test/org/apache/hive/streaming/TestStreaming.java b/streaming/src/test/org/apache/hive/streaming/TestStreaming.java
index 1c9e43f..50433b6 100644
--- a/streaming/src/test/org/apache/hive/streaming/TestStreaming.java
+++ b/streaming/src/test/org/apache/hive/streaming/TestStreaming.java
@@ -439,6 +439,43 @@ public class TestStreaming {
   }
 
   @Test
+  public void testCommitWithKeyValue() throws Exception {
+    queryTable(driver, "drop table if exists default.keyvalue");
+    queryTable(driver, "create table default.keyvalue (a string, b string) stored as orc " +
+        "TBLPROPERTIES('transactional'='true')");
+    queryTable(driver, "insert into default.keyvalue values('foo','bar')");
+    queryTable(driver, "ALTER TABLE default.keyvalue SET TBLPROPERTIES('_metamykey' = 'myvalue')");
+    List<String> rs = queryTable(driver, "select * from default.keyvalue");
+    Assert.assertEquals(1, rs.size());
+    Assert.assertEquals("foo\tbar", rs.get(0));
+    StrictDelimitedInputWriter wr = StrictDelimitedInputWriter.newBuilder()
+        .withFieldDelimiter(',')
+        .build();
+    HiveStreamingConnection connection = HiveStreamingConnection.newBuilder()
+        .withDatabase("Default")
+        .withTable("keyvalue")
+        .withAgentInfo("UT_" + Thread.currentThread().getName())
+        .withTransactionBatchSize(2)
+        .withRecordWriter(wr)
+        .withHiveConf(conf)
+        .connect();
+    connection.beginTransaction();
+    connection.write("a1,b2".getBytes());
+    connection.write("a3,b4".getBytes());
+    connection.commitTransaction(null,  "_metamykey", "myvalue");
+    connection.close();
+
+    rs = queryTable(driver, "select ROW__ID, a, b, INPUT__FILE__NAME from default.keyvalue order by ROW__ID");
+    Assert.assertTrue(rs.get(1), rs.get(1).startsWith("{\"writeid\":2,\"bucketid\":536870912,\"rowid\":0}\ta1\tb2"));
+    Assert.assertTrue(rs.get(1), rs.get(1).endsWith("keyvalue/delta_0000002_0000003/bucket_00000"));
+    Assert.assertTrue(rs.get(2), rs.get(2).startsWith("{\"writeid\":2,\"bucketid\":536870912,\"rowid\":1}\ta3\tb4"));
+    Assert.assertTrue(rs.get(2), rs.get(2).endsWith("keyvalue/delta_0000002_0000003/bucket_00000"));
+
+    rs = queryTable(driver, "SHOW TBLPROPERTIES default.keyvalue('_metamykey')");
+    Assert.assertEquals(rs.get(0), "_metamykey\tmyvalue", rs.get(0));
+  }
+
+  @Test
   public void testConnectionWithWriteId() throws Exception {
     queryTable(driver, "drop table if exists default.writeidconnection");
     queryTable(driver, "create table default.writeidconnection (a string, b string) stored as orc " +
@@ -1139,7 +1176,7 @@ public class TestStreaming {
       Assert.fail("Partition shouldn't exist so a NoSuchObjectException should have been raised");
     } catch (NoSuchObjectException e) {}
 
-    transactionConnection.commitTransactionWithPartition(partitions);
+    transactionConnection.commitTransaction(partitions);
 
     // Ensure partition is present
     Partition p = msClient.getPartition(dbName, tblName, newPartVals);
@@ -1217,7 +1254,7 @@ public class TestStreaming {
 
     partitionsOne.addAll(partitionsTwo);
     Set<String> allPartitions = partitionsOne;
-    transactionConnection.commitTransactionWithPartition(allPartitions);
+    transactionConnection.commitTransaction(allPartitions);
 
     // Ensure partition is present
     for (String partition : allPartitions) {


[36/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query14.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query14.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query14.q.out
new file mode 100644
index 0000000..457cdce
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query14.q.out
@@ -0,0 +1,612 @@
+Warning: Shuffle Join MERGEJOIN[1431][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[1443][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[1433][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 13' is a cross product
+Warning: Shuffle Join MERGEJOIN[1456][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 14' is a cross product
+Warning: Shuffle Join MERGEJOIN[1435][tables = [$hdt$_2, $hdt$_3]] in Stage 'Reducer 18' is a cross product
+Warning: Shuffle Join MERGEJOIN[1469][tables = [$hdt$_2, $hdt$_3, $hdt$_1]] in Stage 'Reducer 19' is a cross product
+PREHOOK: query: explain cbo
+with  cross_items as
+ (select i_item_sk ss_item_sk
+ from item,
+ (select iss.i_brand_id brand_id
+     ,iss.i_class_id class_id
+     ,iss.i_category_id category_id
+ from store_sales
+     ,item iss
+     ,date_dim d1
+ where ss_item_sk = iss.i_item_sk
+   and ss_sold_date_sk = d1.d_date_sk
+   and d1.d_year between 1999 AND 1999 + 2
+ intersect 
+ select ics.i_brand_id
+     ,ics.i_class_id
+     ,ics.i_category_id
+ from catalog_sales
+     ,item ics
+     ,date_dim d2
+ where cs_item_sk = ics.i_item_sk
+   and cs_sold_date_sk = d2.d_date_sk
+   and d2.d_year between 1999 AND 1999 + 2
+ intersect
+ select iws.i_brand_id
+     ,iws.i_class_id
+     ,iws.i_category_id
+ from web_sales
+     ,item iws
+     ,date_dim d3
+ where ws_item_sk = iws.i_item_sk
+   and ws_sold_date_sk = d3.d_date_sk
+   and d3.d_year between 1999 AND 1999 + 2) x
+ where i_brand_id = brand_id
+      and i_class_id = class_id
+      and i_category_id = category_id
+),
+ avg_sales as
+ (select avg(quantity*list_price) average_sales
+  from (select ss_quantity quantity
+             ,ss_list_price list_price
+       from store_sales
+           ,date_dim
+       where ss_sold_date_sk = d_date_sk
+         and d_year between 1999 and 2001 
+       union all 
+       select cs_quantity quantity 
+             ,cs_list_price list_price
+       from catalog_sales
+           ,date_dim
+       where cs_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2 
+       union all
+       select ws_quantity quantity
+             ,ws_list_price list_price
+       from web_sales
+           ,date_dim
+       where ws_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2) x)
+  select  channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
+ from(
+       select 'store' channel, i_brand_id,i_class_id
+             ,i_category_id,sum(ss_quantity*ss_list_price) sales
+             , count(*) number_sales
+       from store_sales
+           ,item
+           ,date_dim
+       where ss_item_sk in (select ss_item_sk from cross_items)
+         and ss_item_sk = i_item_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
+       from catalog_sales
+           ,item
+           ,date_dim
+       where cs_item_sk in (select ss_item_sk from cross_items)
+         and cs_item_sk = i_item_sk
+         and cs_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
+       from web_sales
+           ,item
+           ,date_dim
+       where ws_item_sk in (select ss_item_sk from cross_items)
+         and ws_item_sk = i_item_sk
+         and ws_sold_date_sk = d_date_sk
+         and d_year = 1998+2
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
+ ) y
+ group by rollup (channel, i_brand_id,i_class_id,i_category_id)
+ order by channel,i_brand_id,i_class_id,i_category_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with  cross_items as
+ (select i_item_sk ss_item_sk
+ from item,
+ (select iss.i_brand_id brand_id
+     ,iss.i_class_id class_id
+     ,iss.i_category_id category_id
+ from store_sales
+     ,item iss
+     ,date_dim d1
+ where ss_item_sk = iss.i_item_sk
+   and ss_sold_date_sk = d1.d_date_sk
+   and d1.d_year between 1999 AND 1999 + 2
+ intersect 
+ select ics.i_brand_id
+     ,ics.i_class_id
+     ,ics.i_category_id
+ from catalog_sales
+     ,item ics
+     ,date_dim d2
+ where cs_item_sk = ics.i_item_sk
+   and cs_sold_date_sk = d2.d_date_sk
+   and d2.d_year between 1999 AND 1999 + 2
+ intersect
+ select iws.i_brand_id
+     ,iws.i_class_id
+     ,iws.i_category_id
+ from web_sales
+     ,item iws
+     ,date_dim d3
+ where ws_item_sk = iws.i_item_sk
+   and ws_sold_date_sk = d3.d_date_sk
+   and d3.d_year between 1999 AND 1999 + 2) x
+ where i_brand_id = brand_id
+      and i_class_id = class_id
+      and i_category_id = category_id
+),
+ avg_sales as
+ (select avg(quantity*list_price) average_sales
+  from (select ss_quantity quantity
+             ,ss_list_price list_price
+       from store_sales
+           ,date_dim
+       where ss_sold_date_sk = d_date_sk
+         and d_year between 1999 and 2001 
+       union all 
+       select cs_quantity quantity 
+             ,cs_list_price list_price
+       from catalog_sales
+           ,date_dim
+       where cs_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2 
+       union all
+       select ws_quantity quantity
+             ,ws_list_price list_price
+       from web_sales
+           ,date_dim
+       where ws_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2) x)
+  select  channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
+ from(
+       select 'store' channel, i_brand_id,i_class_id
+             ,i_category_id,sum(ss_quantity*ss_list_price) sales
+             , count(*) number_sales
+       from store_sales
+           ,item
+           ,date_dim
+       where ss_item_sk in (select ss_item_sk from cross_items)
+         and ss_item_sk = i_item_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
+       from catalog_sales
+           ,item
+           ,date_dim
+       where cs_item_sk in (select ss_item_sk from cross_items)
+         and cs_item_sk = i_item_sk
+         and cs_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
+       from web_sales
+           ,item
+           ,date_dim
+       where ws_item_sk in (select ss_item_sk from cross_items)
+         and ws_item_sk = i_item_sk
+         and ws_sold_date_sk = d_date_sk
+         and d_year = 1998+2
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
+ ) y
+ group by rollup (channel, i_brand_id,i_class_id,i_category_id)
+ order by channel,i_brand_id,i_class_id,i_category_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject(channel=[$0], i_brand_id=[$1], i_class_id=[$2], i_category_id=[$3], $f4=[$4], $f5=[$5])
+    HiveAggregate(group=[{0, 1, 2, 3}], groups=[[{0, 1, 2, 3}, {0, 1, 2}, {0, 1}, {0}, {}]], agg#0=[sum($4)], agg#1=[sum($5)])
+      HiveProject(channel=[$0], i_brand_id=[$1], i_class_id=[$2], i_category_id=[$3], sales=[$4], number_sales=[$5])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store'], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], sales=[$3], number_sales=[$4])
+            HiveJoin(condition=[>($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[count()])
+                  HiveProject($f0=[$2], $f1=[$3], $f2=[$4], $f3=[*(CAST($7):DECIMAL(10, 0), $8)])
+                    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_item_sk=[$0])
+                        HiveJoin(condition=[AND(AND(=($1, $4), =($2, $5)), =($3, $6))], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                              HiveTableScan(table=[[default, item]], table:alias=[item])
+                          HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                            HiveFilter(condition=[=($3, 3)])
+                              HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+                                HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                  HiveUnion(all=[true])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[iss])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[ics])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[iws])
+                      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_quantity=[$10], ss_list_price=[$12])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 11))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{}], agg#0=[count($0)])
+                              HiveProject(quantity=[$0], list_price=[$1])
+                                HiveUnion(all=[true])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[count($0)])
+                    HiveProject($f0=[*(CAST($0):DECIMAL(10, 0), $1)])
+                      HiveUnion(all=[true])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'catalog'], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], sales=[$3], number_sales=[$4])
+            HiveJoin(condition=[>($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[count()])
+                  HiveProject($f0=[$2], $f1=[$3], $f2=[$4], $f3=[*(CAST($7):DECIMAL(10, 0), $8)])
+                    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_item_sk=[$0])
+                        HiveJoin(condition=[AND(AND(=($1, $4), =($2, $5)), =($3, $6))], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                              HiveTableScan(table=[[default, item]], table:alias=[item])
+                          HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                            HiveFilter(condition=[=($3, 3)])
+                              HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+                                HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                  HiveUnion(all=[true])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[iss])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[ics])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[iws])
+                      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_quantity=[$18], cs_list_price=[$20])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(d_date_sk=[$0])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 11))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{}], agg#0=[count($0)])
+                              HiveProject(quantity=[$0], list_price=[$1])
+                                HiveUnion(all=[true])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[count($0)])
+                    HiveProject($f0=[*(CAST($0):DECIMAL(10, 0), $1)])
+                      HiveUnion(all=[true])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'web'], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], sales=[$3], number_sales=[$4])
+            HiveJoin(condition=[>($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[count()])
+                  HiveProject($f0=[$2], $f1=[$3], $f2=[$4], $f3=[*(CAST($7):DECIMAL(10, 0), $8)])
+                    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_item_sk=[$0])
+                        HiveJoin(condition=[AND(AND(=($1, $4), =($2, $5)), =($3, $6))], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                              HiveTableScan(table=[[default, item]], table:alias=[item])
+                          HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                            HiveFilter(condition=[=($3, 3)])
+                              HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+                                HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                  HiveUnion(all=[true])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[iss])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[ics])
+                                    HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                      HiveAggregate(group=[{4, 5, 6}], agg#0=[count()])
+                                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3])
+                                              HiveFilter(condition=[IS NOT NULL($0)])
+                                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                            HiveProject(d_date_sk=[$0])
+                                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                                HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                                          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                            HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                              HiveTableScan(table=[[default, item]], table:alias=[iws])
+                      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_quantity=[$18], ws_list_price=[$20])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(d_date_sk=[$0])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 11))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{}], agg#0=[count($0)])
+                              HiveProject(quantity=[$0], list_price=[$1])
+                                HiveUnion(all=[true])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[count($0)])
+                    HiveProject($f0=[*(CAST($0):DECIMAL(10, 0), $1)])
+                      HiveUnion(all=[true])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1999, 2001)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0])
+                              HiveFilter(condition=[BETWEEN(false, $6, 1998, 2000)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query15.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query15.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query15.q.out
new file mode 100644
index 0000000..b260731
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query15.q.out
@@ -0,0 +1,68 @@
+PREHOOK: query: explain cbo
+select  ca_zip
+       ,sum(cs_sales_price)
+ from catalog_sales
+     ,customer
+     ,customer_address
+     ,date_dim
+ where cs_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
+                                   '85392', '85460', '80348', '81792')
+ 	      or ca_state in ('CA','WA','GA')
+ 	      or cs_sales_price > 500)
+ 	and cs_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip
+ order by ca_zip
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  ca_zip
+       ,sum(cs_sales_price)
+ from catalog_sales
+     ,customer
+     ,customer_address
+     ,date_dim
+ where cs_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
+                                   '85392', '85460', '80348', '81792')
+ 	      or ca_state in ('CA','WA','GA')
+ 	      or cs_sales_price > 500)
+ 	and cs_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip
+ order by ca_zip
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(ca_zip=[$0], $f1=[$1])
+    HiveAggregate(group=[{3}], agg#0=[sum($8)])
+      HiveJoin(condition=[AND(=($7, $0), OR($4, $9, $5))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+            HiveFilter(condition=[IS NOT NULL($4)])
+              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+          HiveProject(ca_address_sk=[$0], ca_zip=[$9], IN=[IN(substr($9, 1, 5), _UTF-16LE'85669', _UTF-16LE'86197', _UTF-16LE'88274', _UTF-16LE'83405', _UTF-16LE'86475', _UTF-16LE'85392', _UTF-16LE'85460', _UTF-16LE'80348', _UTF-16LE'81792')], IN3=[IN($8, _UTF-16LE'CA', _UTF-16LE'WA', _UTF-16LE'GA')])
+            HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+        HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_sales_price=[$2], >=[$3], d_date_sk=[$4])
+          HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_sales_price=[$21], >=[>($21, 500)])
+              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[AND(=($10, 2), =($6, 2000))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query16.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query16.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query16.q.out
new file mode 100644
index 0000000..ddbf80a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query16.q.out
@@ -0,0 +1,102 @@
+PREHOOK: query: explain cbo
+select  
+   count(distinct cs_order_number) as `order count`
+  ,sum(cs_ext_ship_cost) as `total shipping cost`
+  ,sum(cs_net_profit) as `total net profit`
+from
+   catalog_sales cs1
+  ,date_dim
+  ,customer_address
+  ,call_center
+where
+    d_date between '2001-4-01' and 
+           (cast('2001-4-01' as date) + 60 days)
+and cs1.cs_ship_date_sk = d_date_sk
+and cs1.cs_ship_addr_sk = ca_address_sk
+and ca_state = 'NY'
+and cs1.cs_call_center_sk = cc_call_center_sk
+and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish',
+                  'Daviess County'
+)
+and exists (select *
+            from catalog_sales cs2
+            where cs1.cs_order_number = cs2.cs_order_number
+              and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
+and not exists(select *
+               from catalog_returns cr1
+               where cs1.cs_order_number = cr1.cr_order_number)
+order by count(distinct cs_order_number)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   count(distinct cs_order_number) as `order count`
+  ,sum(cs_ext_ship_cost) as `total shipping cost`
+  ,sum(cs_net_profit) as `total net profit`
+from
+   catalog_sales cs1
+  ,date_dim
+  ,customer_address
+  ,call_center
+where
+    d_date between '2001-4-01' and 
+           (cast('2001-4-01' as date) + 60 days)
+and cs1.cs_ship_date_sk = d_date_sk
+and cs1.cs_ship_addr_sk = ca_address_sk
+and ca_state = 'NY'
+and cs1.cs_call_center_sk = cc_call_center_sk
+and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish',
+                  'Daviess County'
+)
+and exists (select *
+            from catalog_sales cs2
+            where cs1.cs_order_number = cs2.cs_order_number
+              and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
+and not exists(select *
+               from catalog_returns cr1
+               where cs1.cs_order_number = cr1.cr_order_number)
+order by count(distinct cs_order_number)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2])
+  HiveSortLimit(sort0=[$3], dir0=[ASC], fetch=[100])
+    HiveProject(order count=[$0], total shipping cost=[$1], total net profit=[$2], (tok_functiondi count (tok_table_or_col cs_order_number))=[$0])
+      HiveAggregate(group=[{}], agg#0=[count(DISTINCT $4)], agg#1=[sum($5)], agg#2=[sum($6)])
+        HiveFilter(condition=[IS NULL($14)])
+          HiveJoin(condition=[=($4, $13)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveSemiJoin(condition=[AND(<>($3, $13), =($4, $14))], joinType=[inner])
+              HiveProject(cs_ship_date_sk=[$2], cs_ship_addr_sk=[$3], cs_call_center_sk=[$4], cs_warehouse_sk=[$5], cs_order_number=[$6], cs_ext_ship_cost=[$7], cs_net_profit=[$8], d_date_sk=[$9], d_date=[$10], ca_address_sk=[$0], ca_state=[$1], cc_call_center_sk=[$11], cc_county=[$12])
+                HiveJoin(condition=[=($4, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_state=[CAST(_UTF-16LE'NY'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[=($8, _UTF-16LE'NY')])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_ship_date_sk=[$2], cs_ship_addr_sk=[$10], cs_call_center_sk=[$11], cs_warehouse_sk=[$14], cs_order_number=[$17], cs_ext_ship_cost=[$28], cs_net_profit=[$33])
+                        HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($10), IS NOT NULL($11))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs1])
+                      HiveProject(d_date_sk=[$0], d_date=[$2])
+                        HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-04-01 00:00:00, 2001-05-31 00:00:00)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(cc_call_center_sk=[$0], cc_county=[$25])
+                    HiveFilter(condition=[IN($25, _UTF-16LE'Ziebach County', _UTF-16LE'Levy County', _UTF-16LE'Huron County', _UTF-16LE'Franklin Parish', _UTF-16LE'Daviess County')])
+                      HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+              HiveProject(cs_warehouse_sk=[$14], cs_order_number=[$17])
+                HiveFilter(condition=[IS NOT NULL($14)])
+                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs2])
+            HiveProject(cr_order_number0=[$16], $f1=[true])
+              HiveTableScan(table=[[default, catalog_returns]], table:alias=[cr1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query17.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query17.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query17.q.out
new file mode 100644
index 0000000..d100578
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query17.q.out
@@ -0,0 +1,139 @@
+PREHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,s_state
+       ,count(ss_quantity) as store_sales_quantitycount
+       ,avg(ss_quantity) as store_sales_quantityave
+       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
+       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
+       ,count(sr_return_quantity) as_store_returns_quantitycount
+       ,avg(sr_return_quantity) as_store_returns_quantityave
+       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
+       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
+       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
+ from store_sales
+     ,store_returns
+     ,catalog_sales
+     ,date_dim d1
+     ,date_dim d2
+     ,date_dim d3
+     ,store
+     ,item
+ where d1.d_quarter_name = '2000Q1'
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+ group by i_item_id
+         ,i_item_desc
+         ,s_state
+ order by i_item_id
+         ,i_item_desc
+         ,s_state
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,s_state
+       ,count(ss_quantity) as store_sales_quantitycount
+       ,avg(ss_quantity) as store_sales_quantityave
+       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
+       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
+       ,count(sr_return_quantity) as_store_returns_quantitycount
+       ,avg(sr_return_quantity) as_store_returns_quantityave
+       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
+       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
+       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
+       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
+ from store_sales
+     ,store_returns
+     ,catalog_sales
+     ,date_dim d1
+     ,date_dim d2
+     ,date_dim d3
+     ,store
+     ,item
+ where d1.d_quarter_name = '2000Q1'
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+   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_quarter_name in ('2000Q1','2000Q2','2000Q3')
+ group by i_item_id
+         ,i_item_desc
+         ,s_state
+ order by i_item_id
+         ,i_item_desc
+         ,s_state
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], s_state=[$2], store_sales_quantitycount=[$3], store_sales_quantityave=[/(CAST($4):DOUBLE, $3)], store_sales_quantitystdev=[POWER(/(-($5, /(*($6, $6), $3)), CASE(=($3, 1), null, -($3, 1))), 0.5)], store_sales_quantitycov=[/(POWER(/(-($5, /(*($6, $6), $3)), CASE(=($3, 1), null, -($3, 1))), 0.5), /(CAST($4):DOUBLE, $3))], as_store_returns_quantitycount=[$7], as_store_returns_quantityave=[/(CAST($8):DOUBLE, $7)], as_store_returns_quantitystdev=[POWER(/(-($9, /(*($10, $10), $7)), CASE(=($7, 1), null, -($7, 1))), 0.5)], store_returns_quantitycov=[/(POWER(/(-($9, /(*($10, $10), $7)), CASE(=($7, 1), null, -($7, 1))), 0.5), /(CAST($8):DOUBLE, $7))], catalog_sales_quantitycount=[$11], catalog_sales_quantityave=[/(CAST($12):DOUBLE, $11)], catalog_sales_quantitystdev=[/(POWER(/(-($13, /(*($14, $14), $11)), CASE(=($11, 1), null, -($11, 1))), 0.5), /(CAST($12):DOUBLE, $11))], catalog_sales_quantitycov=[/(POWER(/(-($13, /(*($14, $14), $11)), CASE(=($
 11, 1), null, -($11, 1))), 0.5), /(CAST($12):DOUBLE, $11))])
+    HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)], agg#1=[sum($3)], agg#2=[sum($7)], agg#3=[sum($6)], agg#4=[count($4)], agg#5=[sum($4)], agg#6=[sum($9)], agg#7=[sum($8)], agg#8=[count($5)], agg#9=[sum($5)], agg#10=[sum($11)], agg#11=[sum($10)])
+      HiveProject($f0=[$8], $f1=[$9], $f2=[$22], $f3=[$5], $f4=[$19], $f5=[$13], $f30=[CAST($5):DOUBLE], $f7=[*(CAST($5):DOUBLE, CAST($5):DOUBLE)], $f40=[CAST($19):DOUBLE], $f9=[*(CAST($19):DOUBLE, CAST($19):DOUBLE)], $f50=[CAST($13):DOUBLE], $f11=[*(CAST($13):DOUBLE, CAST($13):DOUBLE)])
+        HiveJoin(condition=[=($21, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[AND(AND(=($2, $17), =($1, $16)), =($4, $18))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_quantity=[$10])
+                  HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[=($15, _UTF-16LE'2000Q1')])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2], cs_quantity=[$3], d_date_sk=[$4], sr_returned_date_sk=[$5], sr_item_sk=[$6], sr_customer_sk=[$7], sr_ticket_number=[$8], sr_return_quantity=[$9], d_date_sk0=[$10])
+              HiveJoin(condition=[AND(=($7, $1), =($6, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_quantity=[$18])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[IN($15, _UTF-16LE'2000Q1', _UTF-16LE'2000Q2', _UTF-16LE'2000Q3')])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$1], sr_customer_sk=[$2], sr_ticket_number=[$3], sr_return_quantity=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9], sr_return_quantity=[$10])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[IN($15, _UTF-16LE'2000Q1', _UTF-16LE'2000Q2', _UTF-16LE'2000Q3')])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+          HiveProject(s_store_sk=[$0], s_state=[$24])
+            HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query18.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query18.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query18.q.out
new file mode 100644
index 0000000..72c7628
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query18.q.out
@@ -0,0 +1,111 @@
+PREHOOK: query: explain cbo
+select  i_item_id,
+        ca_country,
+        ca_state, 
+        ca_county,
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
+ from catalog_sales, customer_demographics cd1, 
+      customer_demographics cd2, customer, customer_address, date_dim, item
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd1.cd_demo_sk and
+       cs_bill_customer_sk = c_customer_sk and
+       cd1.cd_gender = 'M' and 
+       cd1.cd_education_status = 'College' and
+       c_current_cdemo_sk = cd2.cd_demo_sk and
+       c_current_addr_sk = ca_address_sk and
+       c_birth_month in (9,5,12,4,1,10) and
+       d_year = 2001 and
+       ca_state in ('ND','WI','AL'
+                   ,'NC','OK','MS','TN')
+ group by rollup (i_item_id, ca_country, ca_state, ca_county)
+ order by ca_country,
+        ca_state, 
+        ca_county,
+	i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id,
+        ca_country,
+        ca_state, 
+        ca_county,
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
+ from catalog_sales, customer_demographics cd1, 
+      customer_demographics cd2, customer, customer_address, date_dim, item
+ where cs_sold_date_sk = d_date_sk and
+       cs_item_sk = i_item_sk and
+       cs_bill_cdemo_sk = cd1.cd_demo_sk and
+       cs_bill_customer_sk = c_customer_sk and
+       cd1.cd_gender = 'M' and 
+       cd1.cd_education_status = 'College' and
+       c_current_cdemo_sk = cd2.cd_demo_sk and
+       c_current_addr_sk = ca_address_sk and
+       c_birth_month in (9,5,12,4,1,10) and
+       d_year = 2001 and
+       ca_state in ('ND','WI','AL'
+                   ,'NC','OK','MS','TN')
+ group by rollup (i_item_id, ca_country, ca_state, ca_county)
+ order by ca_country,
+        ca_state, 
+        ca_county,
+	i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$3], sort3=[$0], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject($f0=[$3], $f1=[$2], $f2=[$1], $f3=[$0], $f4=[/($4, $5)], $f5=[/($6, $7)], $f6=[/($8, $9)], $f7=[/($10, $11)], $f8=[/($12, $13)], $f9=[/($14, $15)], $f10=[/($16, $17)])
+    HiveAggregate(group=[{5, 6, 7, 10}], groups=[[{5, 6, 7, 10}, {6, 7, 10}, {7, 10}, {10}, {}]], agg#0=[sum($15)], agg#1=[count($15)], agg#2=[sum($16)], agg#3=[count($16)], agg#4=[sum($17)], agg#5=[count($17)], agg#6=[sum($18)], agg#7=[count($18)], agg#8=[sum($19)], agg#9=[count($19)], agg#10=[sum($3)], agg#11=[count($3)], agg#12=[sum($22)], agg#13=[count($22)])
+      HiveJoin(condition=[=($12, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($1, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($2, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4], CAST=[CAST($13):DECIMAL(12, 2)])
+              HiveFilter(condition=[AND(IN($12, 9, 5, 12, 4, 1, 10), IS NOT NULL($2), IS NOT NULL($4))])
+                HiveTableScan(table=[[default, customer]], table:alias=[customer])
+            HiveProject(ca_address_sk=[$0], ca_county=[$7], ca_state=[$8], ca_country=[$10])
+              HiveFilter(condition=[IN($8, _UTF-16LE'ND', _UTF-16LE'WI', _UTF-16LE'AL', _UTF-16LE'NC', _UTF-16LE'OK', _UTF-16LE'MS', _UTF-16LE'TN')])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+          HiveProject(cd_demo_sk=[$0])
+            HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+        HiveProject(i_item_sk=[$0], i_item_id=[$1], cs_sold_date_sk=[$2], cs_bill_customer_sk=[$3], cs_bill_cdemo_sk=[$4], cs_item_sk=[$5], CAST=[$6], CAST5=[$7], CAST6=[$8], CAST7=[$9], CAST8=[$10], d_date_sk=[$11], cd_demo_sk=[$12], CAST0=[$13])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(i_item_sk=[$0], i_item_id=[$1])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+            HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_bill_cdemo_sk=[$4], cs_item_sk=[$15], CAST=[CAST($18):DECIMAL(12, 2)], CAST5=[CAST($20):DECIMAL(12, 2)], CAST6=[CAST($27):DECIMAL(12, 2)], CAST7=[CAST($21):DECIMAL(12, 2)], CAST8=[CAST($33):DECIMAL(12, 2)])
+                  HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($3), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[=($6, 2001)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(cd_demo_sk=[$0], CAST=[CAST($6):DECIMAL(12, 2)])
+                HiveFilter(condition=[AND(=($1, _UTF-16LE'M'), =($3, _UTF-16LE'College'))])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query19.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query19.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query19.q.out
new file mode 100644
index 0000000..0027cf4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query19.q.out
@@ -0,0 +1,90 @@
+PREHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item,customer,customer_address,store
+ where d_date_sk = ss_sold_date_sk
+   and ss_item_sk = i_item_sk
+   and i_manager_id=7
+   and d_moy=11
+   and d_year=1999
+   and ss_customer_sk = c_customer_sk 
+   and c_current_addr_sk = ca_address_sk
+   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
+   and ss_store_sk = s_store_sk 
+ group by i_brand
+      ,i_brand_id
+      ,i_manufact_id
+      ,i_manufact
+ order by ext_price desc
+         ,i_brand
+         ,i_brand_id
+         ,i_manufact_id
+         ,i_manufact
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item,customer,customer_address,store
+ where d_date_sk = ss_sold_date_sk
+   and ss_item_sk = i_item_sk
+   and i_manager_id=7
+   and d_moy=11
+   and d_year=1999
+   and ss_customer_sk = c_customer_sk 
+   and c_current_addr_sk = ca_address_sk
+   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
+   and ss_store_sk = s_store_sk 
+ group by i_brand
+      ,i_brand_id
+      ,i_manufact_id
+      ,i_manufact
+ order by ext_price desc
+         ,i_brand
+         ,i_brand_id
+         ,i_manufact_id
+         ,i_manufact
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(brand_id=[$0], brand=[$1], i_manufact_id=[$2], i_manufact=[$3], ext_price=[$4])
+  HiveSortLimit(sort0=[$4], sort1=[$5], sort2=[$6], sort3=[$2], sort4=[$3], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+    HiveProject(brand_id=[$0], brand=[$1], i_manufact_id=[$2], i_manufact=[$3], ext_price=[$4], (tok_table_or_col i_brand)=[$1], (tok_table_or_col i_brand_id)=[$0])
+      HiveAggregate(group=[{11, 12, 13, 14}], agg#0=[sum($8)])
+        HiveJoin(condition=[AND(<>($3, $16), =($7, $15))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                HiveFilter(condition=[IS NOT NULL($4)])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0], substr=[substr($9, 1, 5)])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5], i_item_sk=[$6], i_brand_id=[$7], i_brand=[$8], i_manufact_id=[$9], i_manufact=[$10])
+              HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ext_sales_price=[$15])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($8, 11), =($6, 1999))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8], i_manufact_id=[$13], i_manufact=[$14])
+                  HiveFilter(condition=[=($20, 7)])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveProject(s_store_sk=[$0], substr=[substr($25, 1, 5)])
+            HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out
new file mode 100644
index 0000000..c245b9b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query2.q.out
@@ -0,0 +1,170 @@
+PREHOOK: query: explain cbo
+with wscs as
+ (select sold_date_sk
+        ,sales_price
+  from (select ws_sold_date_sk sold_date_sk
+              ,ws_ext_sales_price sales_price
+        from web_sales) x
+        union all
+       (select cs_sold_date_sk sold_date_sk
+              ,cs_ext_sales_price sales_price
+        from catalog_sales)),
+ wswscs as 
+ (select d_week_seq,
+        sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
+ from wscs
+     ,date_dim
+ where d_date_sk = sold_date_sk
+ group by d_week_seq)
+ select d_week_seq1
+       ,round(sun_sales1/sun_sales2,2)
+       ,round(mon_sales1/mon_sales2,2)
+       ,round(tue_sales1/tue_sales2,2)
+       ,round(wed_sales1/wed_sales2,2)
+       ,round(thu_sales1/thu_sales2,2)
+       ,round(fri_sales1/fri_sales2,2)
+       ,round(sat_sales1/sat_sales2,2)
+ from
+ (select wswscs.d_week_seq d_week_seq1
+        ,sun_sales sun_sales1
+        ,mon_sales mon_sales1
+        ,tue_sales tue_sales1
+        ,wed_sales wed_sales1
+        ,thu_sales thu_sales1
+        ,fri_sales fri_sales1
+        ,sat_sales sat_sales1
+  from wswscs,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001) y,
+ (select wswscs.d_week_seq d_week_seq2
+        ,sun_sales sun_sales2
+        ,mon_sales mon_sales2
+        ,tue_sales tue_sales2
+        ,wed_sales wed_sales2
+        ,thu_sales thu_sales2
+        ,fri_sales fri_sales2
+        ,sat_sales sat_sales2
+  from wswscs
+      ,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001+1) z
+ where d_week_seq1=d_week_seq2-53
+ order by d_week_seq1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with wscs as
+ (select sold_date_sk
+        ,sales_price
+  from (select ws_sold_date_sk sold_date_sk
+              ,ws_ext_sales_price sales_price
+        from web_sales) x
+        union all
+       (select cs_sold_date_sk sold_date_sk
+              ,cs_ext_sales_price sales_price
+        from catalog_sales)),
+ wswscs as 
+ (select d_week_seq,
+        sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
+ from wscs
+     ,date_dim
+ where d_date_sk = sold_date_sk
+ group by d_week_seq)
+ select d_week_seq1
+       ,round(sun_sales1/sun_sales2,2)
+       ,round(mon_sales1/mon_sales2,2)
+       ,round(tue_sales1/tue_sales2,2)
+       ,round(wed_sales1/wed_sales2,2)
+       ,round(thu_sales1/thu_sales2,2)
+       ,round(fri_sales1/fri_sales2,2)
+       ,round(sat_sales1/sat_sales2,2)
+ from
+ (select wswscs.d_week_seq d_week_seq1
+        ,sun_sales sun_sales1
+        ,mon_sales mon_sales1
+        ,tue_sales tue_sales1
+        ,wed_sales wed_sales1
+        ,thu_sales thu_sales1
+        ,fri_sales fri_sales1
+        ,sat_sales sat_sales1
+  from wswscs,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001) y,
+ (select wswscs.d_week_seq d_week_seq2
+        ,sun_sales sun_sales2
+        ,mon_sales mon_sales2
+        ,tue_sales tue_sales2
+        ,wed_sales wed_sales2
+        ,thu_sales thu_sales2
+        ,fri_sales fri_sales2
+        ,sat_sales sat_sales2
+  from wswscs
+      ,date_dim 
+  where date_dim.d_week_seq = wswscs.d_week_seq and
+        d_year = 2001+1) z
+ where d_week_seq1=d_week_seq2-53
+ order by d_week_seq1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC])
+  HiveProject(d_week_seq1=[$0], _o__c1=[round(/($1, $9), 2)], _o__c2=[round(/($2, $10), 2)], _o__c3=[round(/($3, $11), 2)], _o__c4=[round(/($4, $12), 2)], _o__c5=[round(/($5, $13), 2)], _o__c6=[round(/($6, $14), 2)], _o__c7=[round(/($7, $15), 2)])
+    HiveJoin(condition=[=($0, $16)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
+          HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
+            HiveProject($f0=[$3], $f1=[CASE($4, $1, null)], $f2=[CASE($5, $1, null)], $f3=[CASE($6, $1, null)], $f4=[CASE($7, $1, null)], $f5=[CASE($8, $1, null)], $f6=[CASE($9, $1, null)], $f7=[CASE($10, $1, null)])
+              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
+                  HiveUnion(all=[true])
+                    HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$23])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(cs_sold_date_sk=[$0], cs_ext_sales_price=[$23])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0], d_week_seq=[$4], ==[=($14, _UTF-16LE'Sunday')], =3=[=($14, _UTF-16LE'Monday')], =4=[=($14, _UTF-16LE'Tuesday')], =5=[=($14, _UTF-16LE'Wednesday')], =6=[=($14, _UTF-16LE'Thursday')], =7=[=($14, _UTF-16LE'Friday')], =8=[=($14, _UTF-16LE'Saturday')])
+                  HiveFilter(condition=[IS NOT NULL($4)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(d_week_seq=[$4])
+          HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($4))])
+            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(sun_sales2=[$1], mon_sales2=[$2], tue_sales2=[$3], wed_sales2=[$4], thu_sales2=[$5], fri_sales2=[$6], sat_sales2=[$7], -=[-($0, 53)])
+        HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)], agg#4=[sum($5)], agg#5=[sum($6)], agg#6=[sum($7)])
+              HiveProject($f0=[$3], $f1=[CASE($4, $1, null)], $f2=[CASE($5, $1, null)], $f3=[CASE($6, $1, null)], $f4=[CASE($7, $1, null)], $f5=[CASE($8, $1, null)], $f6=[CASE($9, $1, null)], $f7=[CASE($10, $1, null)])
+                HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$1])
+                    HiveUnion(all=[true])
+                      HiveProject(ws_sold_date_sk=[$0], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(cs_sold_date_sk=[$0], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_week_seq=[$4], ==[=($14, _UTF-16LE'Sunday')], =3=[=($14, _UTF-16LE'Monday')], =4=[=($14, _UTF-16LE'Tuesday')], =5=[=($14, _UTF-16LE'Wednesday')], =6=[=($14, _UTF-16LE'Thursday')], =7=[=($14, _UTF-16LE'Friday')], =8=[=($14, _UTF-16LE'Saturday')])
+                    HiveFilter(condition=[IS NOT NULL($4)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(d_week_seq=[$4])
+            HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($4))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[11/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query64.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query64.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query64.q.out
new file mode 100644
index 0000000..aebd6b4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query64.q.out
@@ -0,0 +1,758 @@
+PREHOOK: query: explain
+with cs_ui as
+ (select cs_item_sk
+        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
+  from catalog_sales
+      ,catalog_returns
+  where cs_item_sk = cr_item_sk
+    and cs_order_number = cr_order_number
+  group by cs_item_sk
+  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
+cross_sales as
+ (select i_product_name product_name
+     ,i_item_sk item_sk
+     ,s_store_name store_name
+     ,s_zip store_zip
+     ,ad1.ca_street_number b_street_number
+     ,ad1.ca_street_name b_streen_name
+     ,ad1.ca_city b_city
+     ,ad1.ca_zip b_zip
+     ,ad2.ca_street_number c_street_number
+     ,ad2.ca_street_name c_street_name
+     ,ad2.ca_city c_city
+     ,ad2.ca_zip c_zip
+     ,d1.d_year as syear
+     ,d2.d_year as fsyear
+     ,d3.d_year s2year
+     ,count(*) cnt
+     ,sum(ss_wholesale_cost) s1
+     ,sum(ss_list_price) s2
+     ,sum(ss_coupon_amt) s3
+  FROM   store_sales
+        ,store_returns
+        ,cs_ui
+        ,date_dim d1
+        ,date_dim d2
+        ,date_dim d3
+        ,store
+        ,customer
+        ,customer_demographics cd1
+        ,customer_demographics cd2
+        ,promotion
+        ,household_demographics hd1
+        ,household_demographics hd2
+        ,customer_address ad1
+        ,customer_address ad2
+        ,income_band ib1
+        ,income_band ib2
+        ,item
+  WHERE  ss_store_sk = s_store_sk AND
+         ss_sold_date_sk = d1.d_date_sk AND
+         ss_customer_sk = c_customer_sk AND
+         ss_cdemo_sk= cd1.cd_demo_sk AND
+         ss_hdemo_sk = hd1.hd_demo_sk AND
+         ss_addr_sk = ad1.ca_address_sk and
+         ss_item_sk = i_item_sk and
+         ss_item_sk = sr_item_sk and
+         ss_ticket_number = sr_ticket_number and
+         ss_item_sk = cs_ui.cs_item_sk and
+         c_current_cdemo_sk = cd2.cd_demo_sk AND
+         c_current_hdemo_sk = hd2.hd_demo_sk AND
+         c_current_addr_sk = ad2.ca_address_sk and
+         c_first_sales_date_sk = d2.d_date_sk and
+         c_first_shipto_date_sk = d3.d_date_sk and
+         ss_promo_sk = p_promo_sk and
+         hd1.hd_income_band_sk = ib1.ib_income_band_sk and
+         hd2.hd_income_band_sk = ib2.ib_income_band_sk and
+         cd1.cd_marital_status <> cd2.cd_marital_status and
+         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
+         i_current_price between 35 and 35 + 10 and
+         i_current_price between 35 + 1 and 35 + 15
+group by i_product_name
+       ,i_item_sk
+       ,s_store_name
+       ,s_zip
+       ,ad1.ca_street_number
+       ,ad1.ca_street_name
+       ,ad1.ca_city
+       ,ad1.ca_zip
+       ,ad2.ca_street_number
+       ,ad2.ca_street_name
+       ,ad2.ca_city
+       ,ad2.ca_zip
+       ,d1.d_year
+       ,d2.d_year
+       ,d3.d_year
+)
+select cs1.product_name
+     ,cs1.store_name
+     ,cs1.store_zip
+     ,cs1.b_street_number
+     ,cs1.b_streen_name
+     ,cs1.b_city
+     ,cs1.b_zip
+     ,cs1.c_street_number
+     ,cs1.c_street_name
+     ,cs1.c_city
+     ,cs1.c_zip
+     ,cs1.syear
+     ,cs1.cnt
+     ,cs1.s1
+     ,cs1.s2
+     ,cs1.s3
+     ,cs2.s1
+     ,cs2.s2
+     ,cs2.s3
+     ,cs2.syear
+     ,cs2.cnt
+from cross_sales cs1,cross_sales cs2
+where cs1.item_sk=cs2.item_sk and
+     cs1.syear = 2000 and
+     cs2.syear = 2000 + 1 and
+     cs2.cnt <= cs1.cnt and
+     cs1.store_name = cs2.store_name and
+     cs1.store_zip = cs2.store_zip
+order by cs1.product_name
+       ,cs1.store_name
+       ,cs2.cnt
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@income_band
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with cs_ui as
+ (select cs_item_sk
+        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
+  from catalog_sales
+      ,catalog_returns
+  where cs_item_sk = cr_item_sk
+    and cs_order_number = cr_order_number
+  group by cs_item_sk
+  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
+cross_sales as
+ (select i_product_name product_name
+     ,i_item_sk item_sk
+     ,s_store_name store_name
+     ,s_zip store_zip
+     ,ad1.ca_street_number b_street_number
+     ,ad1.ca_street_name b_streen_name
+     ,ad1.ca_city b_city
+     ,ad1.ca_zip b_zip
+     ,ad2.ca_street_number c_street_number
+     ,ad2.ca_street_name c_street_name
+     ,ad2.ca_city c_city
+     ,ad2.ca_zip c_zip
+     ,d1.d_year as syear
+     ,d2.d_year as fsyear
+     ,d3.d_year s2year
+     ,count(*) cnt
+     ,sum(ss_wholesale_cost) s1
+     ,sum(ss_list_price) s2
+     ,sum(ss_coupon_amt) s3
+  FROM   store_sales
+        ,store_returns
+        ,cs_ui
+        ,date_dim d1
+        ,date_dim d2
+        ,date_dim d3
+        ,store
+        ,customer
+        ,customer_demographics cd1
+        ,customer_demographics cd2
+        ,promotion
+        ,household_demographics hd1
+        ,household_demographics hd2
+        ,customer_address ad1
+        ,customer_address ad2
+        ,income_band ib1
+        ,income_band ib2
+        ,item
+  WHERE  ss_store_sk = s_store_sk AND
+         ss_sold_date_sk = d1.d_date_sk AND
+         ss_customer_sk = c_customer_sk AND
+         ss_cdemo_sk= cd1.cd_demo_sk AND
+         ss_hdemo_sk = hd1.hd_demo_sk AND
+         ss_addr_sk = ad1.ca_address_sk and
+         ss_item_sk = i_item_sk and
+         ss_item_sk = sr_item_sk and
+         ss_ticket_number = sr_ticket_number and
+         ss_item_sk = cs_ui.cs_item_sk and
+         c_current_cdemo_sk = cd2.cd_demo_sk AND
+         c_current_hdemo_sk = hd2.hd_demo_sk AND
+         c_current_addr_sk = ad2.ca_address_sk and
+         c_first_sales_date_sk = d2.d_date_sk and
+         c_first_shipto_date_sk = d3.d_date_sk and
+         ss_promo_sk = p_promo_sk and
+         hd1.hd_income_band_sk = ib1.ib_income_band_sk and
+         hd2.hd_income_band_sk = ib2.ib_income_band_sk and
+         cd1.cd_marital_status <> cd2.cd_marital_status and
+         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
+         i_current_price between 35 and 35 + 10 and
+         i_current_price between 35 + 1 and 35 + 15
+group by i_product_name
+       ,i_item_sk
+       ,s_store_name
+       ,s_zip
+       ,ad1.ca_street_number
+       ,ad1.ca_street_name
+       ,ad1.ca_city
+       ,ad1.ca_zip
+       ,ad2.ca_street_number
+       ,ad2.ca_street_name
+       ,ad2.ca_city
+       ,ad2.ca_zip
+       ,d1.d_year
+       ,d2.d_year
+       ,d3.d_year
+)
+select cs1.product_name
+     ,cs1.store_name
+     ,cs1.store_zip
+     ,cs1.b_street_number
+     ,cs1.b_streen_name
+     ,cs1.b_city
+     ,cs1.b_zip
+     ,cs1.c_street_number
+     ,cs1.c_street_name
+     ,cs1.c_city
+     ,cs1.c_zip
+     ,cs1.syear
+     ,cs1.cnt
+     ,cs1.s1
+     ,cs1.s2
+     ,cs1.s3
+     ,cs2.s1
+     ,cs2.s2
+     ,cs2.s3
+     ,cs2.syear
+     ,cs2.cnt
+from cross_sales cs1,cross_sales cs2
+where cs1.item_sk=cs2.item_sk and
+     cs1.syear = 2000 and
+     cs2.syear = 2000 + 1 and
+     cs2.cnt <= cs1.cnt and
+     cs1.store_name = cs2.store_name and
+     cs1.store_zip = cs2.store_zip
+order by cs1.product_name
+       ,cs1.store_name
+       ,cs2.cnt
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@income_band
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 33 <- Reducer 29 (BROADCAST_EDGE), Reducer 36 (BROADCAST_EDGE), Reducer 42 (BROADCAST_EDGE)
+Map 39 <- Reducer 36 (BROADCAST_EDGE)
+Map 50 <- Reducer 12 (BROADCAST_EDGE), Reducer 32 (BROADCAST_EDGE), Reducer 38 (BROADCAST_EDGE), Reducer 46 (BROADCAST_EDGE)
+Map 51 <- Reducer 38 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 15 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Reducer 20 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+Reducer 14 <- Map 49 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+Reducer 15 <- Reducer 14 (SIMPLE_EDGE)
+Reducer 17 <- Map 16 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
+Reducer 18 <- Map 48 (SIMPLE_EDGE), Reducer 17 (SIMPLE_EDGE)
+Reducer 19 <- Map 16 (SIMPLE_EDGE), Reducer 25 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 16 (SIMPLE_EDGE)
+Reducer 20 <- Map 48 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (SIMPLE_EDGE), Reducer 28 (SIMPLE_EDGE)
+Reducer 23 <- Map 47 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Map 21 (SIMPLE_EDGE), Reducer 31 (SIMPLE_EDGE)
+Reducer 25 <- Map 47 (SIMPLE_EDGE), Reducer 24 (SIMPLE_EDGE)
+Reducer 27 <- Map 26 (SIMPLE_EDGE), Reducer 34 (SIMPLE_EDGE)
+Reducer 28 <- Reducer 27 (SIMPLE_EDGE), Reducer 41 (ONE_TO_ONE_EDGE)
+Reducer 29 <- Map 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 21 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Map 26 (SIMPLE_EDGE), Reducer 37 (SIMPLE_EDGE)
+Reducer 31 <- Reducer 30 (SIMPLE_EDGE), Reducer 45 (ONE_TO_ONE_EDGE)
+Reducer 32 <- Map 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 34 <- Map 33 (SIMPLE_EDGE), Map 35 (SIMPLE_EDGE)
+Reducer 36 <- Map 35 (CUSTOM_SIMPLE_EDGE)
+Reducer 37 <- Map 35 (SIMPLE_EDGE), Map 50 (SIMPLE_EDGE)
+Reducer 38 <- Map 35 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Map 26 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 40 <- Map 39 (SIMPLE_EDGE), Map 43 (SIMPLE_EDGE)
+Reducer 41 <- Reducer 40 (SIMPLE_EDGE)
+Reducer 42 <- Reducer 41 (CUSTOM_SIMPLE_EDGE)
+Reducer 44 <- Map 43 (SIMPLE_EDGE), Map 51 (SIMPLE_EDGE)
+Reducer 45 <- Reducer 44 (SIMPLE_EDGE)
+Reducer 46 <- Reducer 45 (CUSTOM_SIMPLE_EDGE)
+Reducer 5 <- Map 26 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Map 49 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 18 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Map 49 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 11 vectorized
+      File Output Operator [FS_1001]
+        Select Operator [SEL_1000] (rows=2169965329 width=1702)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20"]
+        <-Reducer 10 [SIMPLE_EDGE]
+          SHUFFLE [RS_199]
+            Select Operator [SEL_198] (rows=2169965329 width=1694)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"]
+              Filter Operator [FIL_197] (rows=2169965329 width=1694)
+                predicate:(_col19 <= _col12)
+                Merge Join Operator [MERGEJOIN_897] (rows=6509895988 width=1694)
+                  Conds:RS_971._col2, _col1, _col3=RS_999._col1, _col0, _col2(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col19","_col20","_col21","_col22"]
+                <-Reducer 9 [SIMPLE_EDGE] vectorized
+                  PARTITION_ONLY_SHUFFLE [RS_971]
+                    PartitionCols:_col2, _col1, _col3
+                    Select Operator [SEL_970] (rows=2299138 width=1354)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"]
+                      Group By Operator [GBY_969] (rows=2299138 width=1362)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8, KEY._col9, KEY._col10, KEY._col11, KEY._col12, KEY._col13
+                      <-Reducer 8 [SIMPLE_EDGE]
+                        SHUFFLE [RS_94]
+                          PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13
+                          Group By Operator [GBY_93] (rows=2299138 width=1362)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"],aggregations:["count()","sum(_col37)","sum(_col38)","sum(_col39)"],keys:_col26, _col40, _col27, _col7, _col8, _col9, _col10, _col13, _col15, _col21, _col22, _col23, _col24, _col41
+                            Select Operator [SEL_92] (rows=2331650 width=1292)
+                              Output:["_col7","_col8","_col9","_col10","_col13","_col15","_col21","_col22","_col23","_col24","_col26","_col27","_col37","_col38","_col39","_col40","_col41"]
+                              Filter Operator [FIL_91] (rows=2331650 width=1292)
+                                predicate:(_col45 <> _col17)
+                                Merge Join Operator [MERGEJOIN_881] (rows=2331650 width=1292)
+                                  Conds:RS_88._col32=RS_926._col0(Inner),Output:["_col7","_col8","_col9","_col10","_col13","_col15","_col17","_col21","_col22","_col23","_col24","_col26","_col27","_col37","_col38","_col39","_col40","_col41","_col45"]
+                                <-Map 49 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_926]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_925] (rows=1861800 width=89)
+                                      Output:["_col0","_col1"]
+                                      TableScan [TS_68] (rows=1861800 width=89)
+                                        default@customer_demographics,cd1,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_marital_status"]
+                                <-Reducer 7 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_88]
+                                    PartitionCols:_col32
+                                    Merge Join Operator [MERGEJOIN_880] (rows=2299138 width=1205)
+                                      Conds:RS_85._col0=RS_86._col13(Inner),Output:["_col7","_col8","_col9","_col10","_col13","_col15","_col17","_col21","_col22","_col23","_col24","_col26","_col27","_col32","_col37","_col38","_col39","_col40","_col41"]
+                                    <-Reducer 6 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_85]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_871] (rows=70357394 width=458)
+                                          Conds:RS_82._col1=RS_927._col0(Inner),Output:["_col0","_col7","_col8","_col9","_col10","_col13","_col15","_col17"]
+                                        <-Map 49 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_927]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_925]
+                                        <-Reducer 5 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_82]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_870] (rows=69376329 width=376)
+                                              Conds:RS_79._col4=RS_914._col0(Inner),Output:["_col0","_col1","_col7","_col8","_col9","_col10","_col13","_col15"]
+                                            <-Map 26 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_914]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_910] (rows=73049 width=8)
+                                                  Output:["_col0","_col1"]
+                                                  TableScan [TS_8] (rows=73049 width=8)
+                                                    default@date_dim,d2,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                            <-Reducer 4 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_79]
+                                                PartitionCols:_col4
+                                                Merge Join Operator [MERGEJOIN_869] (rows=69376329 width=376)
+                                                  Conds:RS_76._col5=RS_913._col0(Inner),Output:["_col0","_col1","_col4","_col7","_col8","_col9","_col10","_col13"]
+                                                <-Map 26 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_913]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_910]
+                                                <-Reducer 3 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_76]
+                                                    PartitionCols:_col5
+                                                    Merge Join Operator [MERGEJOIN_868] (rows=69376329 width=376)
+                                                      Conds:RS_73._col2=RS_907._col0(Inner),Output:["_col0","_col1","_col4","_col5","_col7","_col8","_col9","_col10"]
+                                                    <-Map 21 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_907]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_906] (rows=7200 width=4)
+                                                          Output:["_col0"]
+                                                          Filter Operator [FIL_905] (rows=7200 width=8)
+                                                            predicate:hd_income_band_sk is not null
+                                                            TableScan [TS_5] (rows=7200 width=8)
+                                                              default@household_demographics,hd2,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_income_band_sk"]
+                                                    <-Reducer 2 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_73]
+                                                        PartitionCols:_col2
+                                                        Merge Join Operator [MERGEJOIN_867] (rows=69376329 width=380)
+                                                          Conds:RS_900._col3=RS_902._col0(Inner),Output:["_col0","_col1","_col2","_col4","_col5","_col7","_col8","_col9","_col10"]
+                                                        <-Map 16 [SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_902]
+                                                            PartitionCols:_col0
+                                                            Select Operator [SEL_901] (rows=40000000 width=365)
+                                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                              TableScan [TS_3] (rows=40000000 width=365)
+                                                                default@customer_address,ad2,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_street_number","ca_street_name","ca_city","ca_zip"]
+                                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_900]
+                                                            PartitionCols:_col3
+                                                            Select Operator [SEL_899] (rows=69376329 width=23)
+                                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                                              Filter Operator [FIL_898] (rows=69376329 width=23)
+                                                                predicate:(c_current_addr_sk is not null and c_current_cdemo_sk is not null and c_current_hdemo_sk is not null and c_first_sales_date_sk is not null and c_first_shipto_date_sk is not null)
+                                                                TableScan [TS_0] (rows=80000000 width=23)
+                                                                  default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_hdemo_sk","c_current_addr_sk","c_first_shipto_date_sk","c_first_sales_date_sk"]
+                                    <-Reducer 18 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_86]
+                                        PartitionCols:_col13
+                                        Select Operator [SEL_67] (rows=2651207 width=784)
+                                          Output:["_col3","_col4","_col5","_col6","_col8","_col9","_col13","_col14","_col19","_col20","_col21","_col22","_col23"]
+                                          Merge Join Operator [MERGEJOIN_879] (rows=2651207 width=784)
+                                            Conds:RS_64._col1, _col7=RS_967._col0, _col1(Inner),Output:["_col2","_col3","_col8","_col9","_col10","_col11","_col12","_col17","_col18","_col20","_col21","_col22","_col23"]
+                                          <-Map 48 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_967]
+                                              PartitionCols:_col0, _col1
+                                              Select Operator [SEL_966] (rows=57591150 width=8)
+                                                Output:["_col0","_col1"]
+                                                TableScan [TS_44] (rows=57591150 width=8)
+                                                  default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number"]
+                                          <-Reducer 17 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_64]
+                                              PartitionCols:_col1, _col7
+                                              Merge Join Operator [MERGEJOIN_878] (rows=1608052 width=657)
+                                                Conds:RS_61._col5=RS_903._col0(Inner),Output:["_col1","_col2","_col3","_col7","_col8","_col9","_col10","_col11","_col12","_col17","_col18","_col20","_col21","_col22","_col23"]
+                                              <-Map 16 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_903]
+                                                  PartitionCols:_col0
+                                                   Please refer to the previous Select Operator [SEL_901]
+                                              <-Reducer 23 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_61]
+                                                  PartitionCols:_col5
+                                                  Merge Join Operator [MERGEJOIN_877] (rows=1608052 width=296)
+                                                    Conds:RS_58._col6=RS_964._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col17","_col18"]
+                                                  <-Map 47 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_964]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_963] (rows=1704 width=181)
+                                                        Output:["_col0","_col1","_col2"]
+                                                        Filter Operator [FIL_962] (rows=1704 width=181)
+                                                          predicate:(s_store_name is not null and s_zip is not null)
+                                                          TableScan [TS_39] (rows=1704 width=181)
+                                                            default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_zip"]
+                                                  <-Reducer 22 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_58]
+                                                      PartitionCols:_col6
+                                                      Merge Join Operator [MERGEJOIN_876] (rows=1608052 width=119)
+                                                        Conds:RS_55._col4=RS_908._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                      <-Map 21 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_908]
+                                                          PartitionCols:_col0
+                                                           Please refer to the previous Select Operator [SEL_906]
+                                                      <-Reducer 28 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_55]
+                                                          PartitionCols:_col4
+                                                          Merge Join Operator [MERGEJOIN_875] (rows=1608052 width=119)
+                                                            Conds:RS_52._col1=RS_953._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                          <-Reducer 41 [ONE_TO_ONE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_953]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_952] (rows=13257 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_951] (rows=13257 width=228)
+                                                                  predicate:(_col1 > (2 * _col2))
+                                                                  Group By Operator [GBY_950] (rows=39773 width=228)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                                                                  <-Reducer 40 [SIMPLE_EDGE]
+                                                                    SHUFFLE [RS_32]
+                                                                      PartitionCols:_col0
+                                                                      Group By Operator [GBY_31] (rows=6482999 width=228)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","sum(_col5)"],keys:_col0
+                                                                        Merge Join Operator [MERGEJOIN_874] (rows=183085709 width=227)
+                                                                          Conds:RS_946._col0, _col1=RS_948._col0, _col1(Inner),Output:["_col0","_col2","_col5"]
+                                                                        <-Map 43 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_948]
+                                                                            PartitionCols:_col0, _col1
+                                                                            Select Operator [SEL_947] (rows=28798881 width=120)
+                                                                              Output:["_col0","_col1","_col2"]
+                                                                              TableScan [TS_25] (rows=28798881 width=337)
+                                                                                default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_item_sk","cr_order_number","cr_refunded_cash","cr_reversed_charge","cr_store_credit"]
+                                                                        <-Map 39 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_946]
+                                                                            PartitionCols:_col0, _col1
+                                                                            Select Operator [SEL_945] (rows=287989836 width=119)
+                                                                              Output:["_col0","_col1","_col2"]
+                                                                              Filter Operator [FIL_944] (rows=287989836 width=119)
+                                                                                predicate:(cs_item_sk BETWEEN DynamicValue(RS_47_item_i_item_sk_min) AND DynamicValue(RS_47_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_47_item_i_item_sk_bloom_filter)))
+                                                                                TableScan [TS_23] (rows=287989836 width=119)
+                                                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_item_sk","cs_order_number","cs_ext_list_price"]
+                                                                                <-Reducer 36 [BROADCAST_EDGE] vectorized
+                                                                                  BROADCAST [RS_941]
+                                                                                    Group By Operator [GBY_939] (rows=1 width=12)
+                                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                    <-Map 35 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                      PARTITION_ONLY_SHUFFLE [RS_937]
+                                                                                        Group By Operator [GBY_935] (rows=1 width=12)
+                                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                          Select Operator [SEL_932] (rows=518 width=4)
+                                                                                            Output:["_col0"]
+                                                                                            Select Operator [SEL_930] (rows=518 width=111)
+                                                                                              Output:["_col0","_col1"]
+                                                                                              Filter Operator [FIL_929] (rows=518 width=312)
+                                                                                                predicate:((i_color) IN ('maroon', 'burnished', 'dim', 'steel', 'navajo', 'chocolate') and i_current_price BETWEEN 35 AND 45 and i_current_price BETWEEN 36 AND 50)
+                                                                                                TableScan [TS_17] (rows=462000 width=311)
+                                                                                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_color","i_product_name"]
+                                                          <-Reducer 27 [SIMPLE_EDGE]
+                                                            SHUFFLE [RS_52]
+                                                              PartitionCols:_col1
+                                                              Merge Join Operator [MERGEJOIN_873] (rows=1608052 width=119)
+                                                                Conds:RS_49._col0=RS_917._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                              <-Map 26 [SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_917]
+                                                                  PartitionCols:_col0
+                                                                  Select Operator [SEL_915] (rows=652 width=4)
+                                                                    Output:["_col0"]
+                                                                    Filter Operator [FIL_911] (rows=652 width=8)
+                                                                      predicate:(d_year = 2000)
+                                                                       Please refer to the previous TableScan [TS_8]
+                                                              <-Reducer 34 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_49]
+                                                                  PartitionCols:_col0
+                                                                  Merge Join Operator [MERGEJOIN_872] (rows=4503592 width=119)
+                                                                    Conds:RS_961._col1=RS_931._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                                  <-Map 35 [SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_931]
+                                                                      PartitionCols:_col0
+                                                                       Please refer to the previous Select Operator [SEL_930]
+                                                                  <-Map 33 [SIMPLE_EDGE] vectorized
+                                                                    SHUFFLE [RS_961]
+                                                                      PartitionCols:_col1
+                                                                      Select Operator [SEL_960] (rows=417313408 width=351)
+                                                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+                                                                        Filter Operator [FIL_959] (rows=417313408 width=355)
+                                                                          predicate:((ss_item_sk BETWEEN DynamicValue(RS_47_item_i_item_sk_min) AND DynamicValue(RS_47_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_47_item_i_item_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_53_catalog_sales_cs_item_sk_min) AND DynamicValue(RS_53_catalog_sales_cs_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_53_catalog_sales_cs_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_50_d1_d_date_sk_min) AND DynamicValue(RS_50_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_50_d1_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_cdemo_sk is not null and ss_customer_sk is not null and ss_hdemo_sk is not null and ss_promo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                                          TableScan [TS_14] (rows=575995635 width=355)
+                                                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_cdemo_sk","ss_hdemo_sk","ss_addr_sk","ss_store_sk","ss_promo_sk","ss_ticket_number","ss_wholesale_cost","ss_list_price","ss_coupon_amt"]
+                                                                          <-Reducer 36 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_940]
+                                                                               Please refer to the previous Group By Operator [GBY_939]
+                                                                          <-Reducer 29 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_943]
+                                                                              Group By Operator [GBY_942] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                              <-Map 26 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                SHUFFLE [RS_923]
+                                                                                  Group By Operator [GBY_921] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                    Select Operator [SEL_918] (rows=652 width=4)
+                                                                                      Output:["_col0"]
+                                                                                       Please refer to the previous Select Operator [SEL_915]
+                                                                          <-Reducer 42 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_958]
+                                                                              Group By Operator [GBY_957] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                              <-Reducer 41 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                PARTITION_ONLY_SHUFFLE [RS_956]
+                                                                                  Group By Operator [GBY_955] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                    Select Operator [SEL_954] (rows=13257 width=4)
+                                                                                      Output:["_col0"]
+                                                                                       Please refer to the previous Select Operator [SEL_952]
+                <-Reducer 15 [SIMPLE_EDGE] vectorized
+                  SHUFFLE [RS_999]
+                    PartitionCols:_col1, _col0, _col2
+                    Select Operator [SEL_998] (rows=2299138 width=525)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                      Group By Operator [GBY_997] (rows=2299138 width=1362)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8, KEY._col9, KEY._col10, KEY._col11, KEY._col12, KEY._col13
+                      <-Reducer 14 [SIMPLE_EDGE]
+                        SHUFFLE [RS_191]
+                          PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10, _col11, _col12, _col13
+                          Group By Operator [GBY_190] (rows=2299138 width=1362)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17"],aggregations:["count()","sum(_col37)","sum(_col38)","sum(_col39)"],keys:_col26, _col40, _col27, _col7, _col8, _col9, _col10, _col13, _col15, _col21, _col22, _col23, _col24, _col41
+                            Select Operator [SEL_189] (rows=2331650 width=1292)
+                              Output:["_col7","_col8","_col9","_col10","_col13","_col15","_col21","_col22","_col23","_col24","_col26","_col27","_col37","_col38","_col39","_col40","_col41"]
+                              Filter Operator [FIL_188] (rows=2331650 width=1292)
+                                predicate:(_col45 <> _col17)
+                                Merge Join Operator [MERGEJOIN_896] (rows=2331650 width=1292)
+                                  Conds:RS_185._col32=RS_928._col0(Inner),Output:["_col7","_col8","_col9","_col10","_col13","_col15","_col17","_col21","_col22","_col23","_col24","_col26","_col27","_col37","_col38","_col39","_col40","_col41","_col45"]
+                                <-Map 49 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_928]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Select Operator [SEL_925]
+                                <-Reducer 13 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_185]
+                                    PartitionCols:_col32
+                                    Merge Join Operator [MERGEJOIN_895] (rows=2299138 width=1205)
+                                      Conds:RS_182._col0=RS_183._col13(Inner),Output:["_col7","_col8","_col9","_col10","_col13","_col15","_col17","_col21","_col22","_col23","_col24","_col26","_col27","_col32","_col37","_col38","_col39","_col40","_col41"]
+                                    <-Reducer 6 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_182]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Merge Join Operator [MERGEJOIN_871]
+                                    <-Reducer 20 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_183]
+                                        PartitionCols:_col13
+                                        Select Operator [SEL_164] (rows=2651207 width=784)
+                                          Output:["_col3","_col4","_col5","_col6","_col8","_col9","_col13","_col14","_col19","_col20","_col21","_col22","_col23"]
+                                          Merge Join Operator [MERGEJOIN_894] (rows=2651207 width=784)
+                                            Conds:RS_161._col1, _col7=RS_968._col0, _col1(Inner),Output:["_col2","_col3","_col8","_col9","_col10","_col11","_col12","_col17","_col18","_col20","_col21","_col22","_col23"]
+                                          <-Map 48 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_968]
+                                              PartitionCols:_col0, _col1
+                                               Please refer to the previous Select Operator [SEL_966]
+                                          <-Reducer 19 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_161]
+                                              PartitionCols:_col1, _col7
+                                              Merge Join Operator [MERGEJOIN_893] (rows=1608052 width=657)
+                                                Conds:RS_158._col5=RS_904._col0(Inner),Output:["_col1","_col2","_col3","_col7","_col8","_col9","_col10","_col11","_col12","_col17","_col18","_col20","_col21","_col22","_col23"]
+                                              <-Map 16 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_904]
+                                                  PartitionCols:_col0
+                                                   Please refer to the previous Select Operator [SEL_901]
+                                              <-Reducer 25 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_158]
+                                                  PartitionCols:_col5
+                                                  Merge Join Operator [MERGEJOIN_892] (rows=1608052 width=296)
+                                                    Conds:RS_155._col6=RS_965._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col17","_col18"]
+                                                  <-Map 47 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_965]
+                                                      PartitionCols:_col0
+                                                       Please refer to the previous Select Operator [SEL_963]
+                                                  <-Reducer 24 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_155]
+                                                      PartitionCols:_col6
+                                                      Merge Join Operator [MERGEJOIN_891] (rows=1608052 width=119)
+                                                        Conds:RS_152._col4=RS_909._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                      <-Map 21 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_909]
+                                                          PartitionCols:_col0
+                                                           Please refer to the previous Select Operator [SEL_906]
+                                                      <-Reducer 31 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_152]
+                                                          PartitionCols:_col4
+                                                          Merge Join Operator [MERGEJOIN_890] (rows=1608052 width=119)
+                                                            Conds:RS_149._col1=RS_986._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                          <-Reducer 45 [ONE_TO_ONE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_986]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_985] (rows=13257 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_984] (rows=13257 width=228)
+                                                                  predicate:(_col1 > (2 * _col2))
+                                                                  Group By Operator [GBY_983] (rows=39773 width=228)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                                                                  <-Reducer 44 [SIMPLE_EDGE]
+                                                                    SHUFFLE [RS_129]
+                                                                      PartitionCols:_col0
+                                                                      Group By Operator [GBY_128] (rows=6482999 width=228)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","sum(_col5)"],keys:_col0
+                                                                        Merge Join Operator [MERGEJOIN_889] (rows=183085709 width=227)
+                                                                          Conds:RS_982._col0, _col1=RS_949._col0, _col1(Inner),Output:["_col0","_col2","_col5"]
+                                                                        <-Map 43 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_949]
+                                                                            PartitionCols:_col0, _col1
+                                                                             Please refer to the previous Select Operator [SEL_947]
+                                                                        <-Map 51 [SIMPLE_EDGE] vectorized
+                                                                          SHUFFLE [RS_982]
+                                                                            PartitionCols:_col0, _col1
+                                                                            Select Operator [SEL_981] (rows=287989836 width=119)
+                                                                              Output:["_col0","_col1","_col2"]
+                                                                              Filter Operator [FIL_980] (rows=287989836 width=119)
+                                                                                predicate:(cs_item_sk BETWEEN DynamicValue(RS_144_item_i_item_sk_min) AND DynamicValue(RS_144_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_144_item_i_item_sk_bloom_filter)))
+                                                                                TableScan [TS_120] (rows=287989836 width=119)
+                                                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_item_sk","cs_order_number","cs_ext_list_price"]
+                                                                                <-Reducer 38 [BROADCAST_EDGE] vectorized
+                                                                                  BROADCAST [RS_977]
+                                                                                    Group By Operator [GBY_975] (rows=1 width=12)
+                                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                    <-Map 35 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                      PARTITION_ONLY_SHUFFLE [RS_938]
+                                                                                        Group By Operator [GBY_936] (rows=1 width=12)
+                                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                          Select Operator [SEL_934] (rows=518 width=4)
+                                                                                            Output:["_col0"]
+                                                                                             Please refer to the previous Select Operator [SEL_930]
+                                                          <-Reducer 30 [SIMPLE_EDGE]
+                                                            SHUFFLE [RS_149]
+                                                              PartitionCols:_col1
+                                                              Merge Join Operator [MERGEJOIN_888] (rows=1608052 width=119)
+                                                                Conds:RS_146._col0=RS_919._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                              <-Map 26 [SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_919]
+                                                                  PartitionCols:_col0
+                                                                  Select Operator [SEL_916] (rows=652 width=4)
+                                                                    Output:["_col0"]
+                                                                    Filter Operator [FIL_912] (rows=652 width=8)
+                                                                      predicate:(d_year = 2001)
+                                                                       Please refer to the previous TableScan [TS_8]
+                                                              <-Reducer 37 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_146]
+                                                                  PartitionCols:_col0
+                                                                  Merge Join Operator [MERGEJOIN_887] (rows=4503592 width=119)
+                                                                    Conds:RS_996._col1=RS_933._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                                                  <-Map 35 [SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_933]
+                                                                      PartitionCols:_col0
+                                                                       Please refer to the previous Select Operator [SEL_930]
+                                                                  <-Map 50 [SIMPLE_EDGE] vectorized
+                                                                    SHUFFLE [RS_996]
+                                                                      PartitionCols:_col1
+                                                                      Select Operator [SEL_995] (rows=417313408 width=351)
+                                                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+                                                                        Filter Operator [FIL_994] (rows=417313408 width=355)
+                                                                          predicate:((ss_item_sk BETWEEN DynamicValue(RS_144_item_i_item_sk_min) AND DynamicValue(RS_144_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_144_item_i_item_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_150_catalog_sales_cs_item_sk_min) AND DynamicValue(RS_150_catalog_sales_cs_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_150_catalog_sales_cs_item_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_194_item_i_item_sk_min) AND DynamicValue(RS_194_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_194_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_147_d1_d_date_sk_min) AND DynamicValue(RS_147_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_147_d1_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_cdemo_sk is not null and ss_customer_sk is not null and ss_hdemo_sk is not null and 
 ss_promo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                                          TableScan [TS_111] (rows=575995635 width=355)
+                                                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_cdemo_sk","ss_hdemo_sk","ss_addr_sk","ss_store_sk","ss_promo_sk","ss_ticket_number","ss_wholesale_cost","ss_list_price","ss_coupon_amt"]
+                                                                          <-Reducer 38 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_976]
+                                                                               Please refer to the previous Group By Operator [GBY_975]
+                                                                          <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_993]
+                                                                              Group By Operator [GBY_992] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                              <-Reducer 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                PARTITION_ONLY_SHUFFLE [RS_974]
+                                                                                  Group By Operator [GBY_973] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                    Select Operator [SEL_972] (rows=2299138 width=8)
+                                                                                      Output:["_col0"]
+                                                                                       Please refer to the previous Select Operator [SEL_970]
+                                                                          <-Reducer 32 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_979]
+                                                                              Group By Operator [GBY_978] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                              <-Map 26 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                SHUFFLE [RS_924]
+                                                                                  Group By Operator [GBY_922] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                    Select Operator [SEL_920] (rows=652 width=4)
+                                                                                      Output:["_col0"]
+                                                                                       Please refer to the previous Select Operator [SEL_916]
+                                                                          <-Reducer 46 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_991]
+                                                                              Group By Operator [GBY_990] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                              <-Reducer 45 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                PARTITION_ONLY_SHUFFLE [RS_989]
+                                                                                  Group By Operator [GBY_988] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                    Select Operator [SEL_987] (rows=13257 width=4)
+                                                                                      Output:["_col0"]
+                                                                                       Please refer to the previous Select Operator [SEL_985]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query65.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query65.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query65.q.out
new file mode 100644
index 0000000..87d0f6f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query65.q.out
@@ -0,0 +1,220 @@
+PREHOOK: query: explain
+select 
+	s_store_name,
+	i_item_desc,
+	sc.revenue,
+	i_current_price,
+	i_wholesale_cost,
+	i_brand
+ from store, item,
+     (select ss_store_sk, avg(revenue) as ave
+ 	from
+ 	    (select  ss_store_sk, ss_item_sk, 
+ 		     sum(ss_sales_price) as revenue
+ 		from store_sales, date_dim
+ 		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 		group by ss_store_sk, ss_item_sk) sa
+ 	group by ss_store_sk) sb,
+     (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
+ 	from store_sales, date_dim
+ 	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 	group by ss_store_sk, ss_item_sk) sc
+ where sb.ss_store_sk = sc.ss_store_sk and 
+       sc.revenue <= 0.1 * sb.ave and
+       s_store_sk = sc.ss_store_sk and
+       i_item_sk = sc.ss_item_sk
+ order by s_store_name, i_item_desc
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select 
+	s_store_name,
+	i_item_desc,
+	sc.revenue,
+	i_current_price,
+	i_wholesale_cost,
+	i_brand
+ from store, item,
+     (select ss_store_sk, avg(revenue) as ave
+ 	from
+ 	    (select  ss_store_sk, ss_item_sk, 
+ 		     sum(ss_sales_price) as revenue
+ 		from store_sales, date_dim
+ 		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 		group by ss_store_sk, ss_item_sk) sa
+ 	group by ss_store_sk) sb,
+     (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
+ 	from store_sales, date_dim
+ 	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 	group by ss_store_sk, ss_item_sk) sc
+ where sb.ss_store_sk = sc.ss_store_sk and 
+       sc.revenue <= 0.1 * sb.ave and
+       s_store_sk = sc.ss_store_sk and
+       i_item_sk = sc.ss_item_sk
+ order by s_store_name, i_item_desc
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 10 (BROADCAST_EDGE)
+Map 14 <- Reducer 13 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Map 14 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 12 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 15 (SIMPLE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Map 16 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 3 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_173]
+        Limit [LIM_172] (rows=100 width=705)
+          Number of rows:100
+          Select Operator [SEL_171] (rows=65392 width=704)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_48]
+              Select Operator [SEL_47] (rows=65392 width=704)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                Merge Join Operator [MERGEJOIN_134] (rows=65392 width=704)
+                  Conds:RS_44._col1=RS_170._col0(Inner),Output:["_col2","_col6","_col8","_col9","_col10","_col11"]
+                <-Map 16 [SIMPLE_EDGE] vectorized
+                  SHUFFLE [RS_170]
+                    PartitionCols:_col0
+                    Select Operator [SEL_169] (rows=462000 width=511)
+                      Output:["_col0","_col1","_col2","_col3","_col4"]
+                      TableScan [TS_35] (rows=462000 width=511)
+                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_desc","i_current_price","i_wholesale_cost","i_brand"]
+                <-Reducer 5 [SIMPLE_EDGE]
+                  SHUFFLE [RS_44]
+                    PartitionCols:_col1
+                    Merge Join Operator [MERGEJOIN_133] (rows=65392 width=204)
+                      Conds:RS_41._col0=RS_168._col0(Inner),Output:["_col1","_col2","_col6"]
+                    <-Map 15 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_168]
+                        PartitionCols:_col0
+                        Select Operator [SEL_167] (rows=1704 width=92)
+                          Output:["_col0","_col1"]
+                          TableScan [TS_33] (rows=1704 width=92)
+                            default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name"]
+                    <-Reducer 4 [ONE_TO_ONE_EDGE]
+                      FORWARD [RS_41]
+                        PartitionCols:_col0
+                        Filter Operator [FIL_40] (rows=65392 width=231)
+                          predicate:(_col2 <= _col4)
+                          Merge Join Operator [MERGEJOIN_132] (rows=196176 width=231)
+                            Conds:RS_151._col0=RS_166._col0(Inner),Output:["_col0","_col1","_col2","_col4"]
+                          <-Reducer 3 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_151]
+                              PartitionCols:_col0
+                              Group By Operator [GBY_150] (rows=184637 width=118)
+                                Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_11]
+                                  PartitionCols:_col0, _col1
+                                  Group By Operator [GBY_10] (rows=6093021 width=118)
+                                    Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col2, _col1
+                                    Merge Join Operator [MERGEJOIN_130] (rows=91197860 width=89)
+                                      Conds:RS_149._col0=RS_137._col0(Inner),Output:["_col1","_col2","_col3"]
+                                    <-Map 9 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_137]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_136] (rows=317 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_135] (rows=317 width=8)
+                                            predicate:d_month_seq BETWEEN 1212 AND 1223
+                                            TableScan [TS_3] (rows=73049 width=8)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_149]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_148] (rows=525329897 width=118)
+                                          Output:["_col0","_col1","_col2","_col3"]
+                                          Filter Operator [FIL_147] (rows=525329897 width=118)
+                                            predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_7_date_dim_d_date_sk_min) AND DynamicValue(RS_7_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_7_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                            TableScan [TS_0] (rows=575995635 width=118)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_sales_price"]
+                                            <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_146]
+                                                Group By Operator [GBY_145] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_143]
+                                                    Group By Operator [GBY_141] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_138] (rows=317 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_136]
+                          <-Reducer 12 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_166]
+                              PartitionCols:_col0
+                              Select Operator [SEL_165] (rows=17 width=115)
+                                Output:["_col0","_col1"]
+                                Group By Operator [GBY_164] (rows=17 width=123)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","count(_col2)"],keys:_col1
+                                  Select Operator [SEL_163] (rows=184637 width=118)
+                                    Output:["_col1","_col2"]
+                                    Group By Operator [GBY_162] (rows=184637 width=118)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                    <-Reducer 11 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_25]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_24] (rows=6093021 width=118)
+                                          Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col2, _col1
+                                          Merge Join Operator [MERGEJOIN_131] (rows=91197860 width=89)
+                                            Conds:RS_161._col0=RS_139._col0(Inner),Output:["_col1","_col2","_col3"]
+                                          <-Map 9 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_139]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_136]
+                                          <-Map 14 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_161]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_160] (rows=525329897 width=118)
+                                                Output:["_col0","_col1","_col2","_col3"]
+                                                Filter Operator [FIL_159] (rows=525329897 width=118)
+                                                  predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_21_date_dim_d_date_sk_min) AND DynamicValue(RS_21_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_21_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_37_store_sales_ss_store_sk_min) AND DynamicValue(RS_37_store_sales_ss_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_37_store_sales_ss_store_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                  TableScan [TS_14] (rows=575995635 width=118)
+                                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_sales_price"]
+                                                  <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_156]
+                                                      Group By Operator [GBY_155] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_144]
+                                                          Group By Operator [GBY_142] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_140] (rows=317 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_136]
+                                                  <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_158]
+                                                      Group By Operator [GBY_157] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Reducer 3 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_154]
+                                                          Group By Operator [GBY_153] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_152] (rows=184637 width=2)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Group By Operator [GBY_150]
+


[07/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query75.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query75.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query75.q.out
new file mode 100644
index 0000000..fee4e83
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query75.q.out
@@ -0,0 +1,662 @@
+PREHOOK: query: explain
+WITH all_sales AS (
+ SELECT d_year
+       ,i_brand_id
+       ,i_class_id
+       ,i_category_id
+       ,i_manufact_id
+       ,SUM(sales_cnt) AS sales_cnt
+       ,SUM(sales_amt) AS sales_amt
+ FROM (SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt
+             ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt
+       FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk
+                          JOIN date_dim ON d_date_sk=cs_sold_date_sk
+                          LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number 
+                                                    AND cs_item_sk=cr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt
+             ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt
+       FROM store_sales JOIN item ON i_item_sk=ss_item_sk
+                        JOIN date_dim ON d_date_sk=ss_sold_date_sk
+                        LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number 
+                                                AND ss_item_sk=sr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt
+             ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt
+       FROM web_sales JOIN item ON i_item_sk=ws_item_sk
+                      JOIN date_dim ON d_date_sk=ws_sold_date_sk
+                      LEFT JOIN web_returns ON (ws_order_number=wr_order_number 
+                                            AND ws_item_sk=wr_item_sk)
+       WHERE i_category='Sports') sales_detail
+ GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+ SELECT  prev_yr.d_year AS prev_year
+                          ,curr_yr.d_year AS year
+                          ,curr_yr.i_brand_id
+                          ,curr_yr.i_class_id
+                          ,curr_yr.i_category_id
+                          ,curr_yr.i_manufact_id
+                          ,prev_yr.sales_cnt AS prev_yr_cnt
+                          ,curr_yr.sales_cnt AS curr_yr_cnt
+                          ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff
+                          ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff
+ FROM all_sales curr_yr, all_sales prev_yr
+ WHERE curr_yr.i_brand_id=prev_yr.i_brand_id
+   AND curr_yr.i_class_id=prev_yr.i_class_id
+   AND curr_yr.i_category_id=prev_yr.i_category_id
+   AND curr_yr.i_manufact_id=prev_yr.i_manufact_id
+   AND curr_yr.d_year=2002
+   AND prev_yr.d_year=2002-1
+   AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9
+ ORDER BY sales_cnt_diff
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+WITH all_sales AS (
+ SELECT d_year
+       ,i_brand_id
+       ,i_class_id
+       ,i_category_id
+       ,i_manufact_id
+       ,SUM(sales_cnt) AS sales_cnt
+       ,SUM(sales_amt) AS sales_amt
+ FROM (SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt
+             ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt
+       FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk
+                          JOIN date_dim ON d_date_sk=cs_sold_date_sk
+                          LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number 
+                                                    AND cs_item_sk=cr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt
+             ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt
+       FROM store_sales JOIN item ON i_item_sk=ss_item_sk
+                        JOIN date_dim ON d_date_sk=ss_sold_date_sk
+                        LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number 
+                                                AND ss_item_sk=sr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt
+             ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt
+       FROM web_sales JOIN item ON i_item_sk=ws_item_sk
+                      JOIN date_dim ON d_date_sk=ws_sold_date_sk
+                      LEFT JOIN web_returns ON (ws_order_number=wr_order_number 
+                                            AND ws_item_sk=wr_item_sk)
+       WHERE i_category='Sports') sales_detail
+ GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+ SELECT  prev_yr.d_year AS prev_year
+                          ,curr_yr.d_year AS year
+                          ,curr_yr.i_brand_id
+                          ,curr_yr.i_class_id
+                          ,curr_yr.i_category_id
+                          ,curr_yr.i_manufact_id
+                          ,prev_yr.sales_cnt AS prev_yr_cnt
+                          ,curr_yr.sales_cnt AS curr_yr_cnt
+                          ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff
+                          ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff
+ FROM all_sales curr_yr, all_sales prev_yr
+ WHERE curr_yr.i_brand_id=prev_yr.i_brand_id
+   AND curr_yr.i_class_id=prev_yr.i_class_id
+   AND curr_yr.i_category_id=prev_yr.i_category_id
+   AND curr_yr.i_manufact_id=prev_yr.i_manufact_id
+   AND curr_yr.d_year=2002
+   AND prev_yr.d_year=2002-1
+   AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9
+ ORDER BY sales_cnt_diff
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 12 (BROADCAST_EDGE), Reducer 38 (BROADCAST_EDGE)
+Map 45 <- Reducer 16 (BROADCAST_EDGE), Reducer 39 (BROADCAST_EDGE)
+Map 47 <- Reducer 20 (BROADCAST_EDGE), Reducer 40 (BROADCAST_EDGE)
+Map 49 <- Reducer 28 (BROADCAST_EDGE), Reducer 41 (BROADCAST_EDGE)
+Map 50 <- Reducer 32 (BROADCAST_EDGE), Reducer 42 (BROADCAST_EDGE)
+Map 51 <- Reducer 36 (BROADCAST_EDGE), Reducer 43 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Map 11 (SIMPLE_EDGE), Map 45 (SIMPLE_EDGE)
+Reducer 14 <- Map 37 (SIMPLE_EDGE), Reducer 13 (SIMPLE_EDGE)
+Reducer 15 <- Map 46 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 16 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 11 (SIMPLE_EDGE), Map 47 (SIMPLE_EDGE)
+Reducer 18 <- Map 37 (SIMPLE_EDGE), Reducer 17 (SIMPLE_EDGE)
+Reducer 19 <- Map 48 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 11 (SIMPLE_EDGE)
+Reducer 20 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 21 <- Map 11 (SIMPLE_EDGE), Map 49 (SIMPLE_EDGE)
+Reducer 22 <- Map 37 (SIMPLE_EDGE), Reducer 21 (SIMPLE_EDGE)
+Reducer 23 <- Map 44 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE), Union 24 (CONTAINS)
+Reducer 25 <- Union 24 (SIMPLE_EDGE), Union 26 (CONTAINS)
+Reducer 27 <- Union 26 (SIMPLE_EDGE)
+Reducer 28 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 11 (SIMPLE_EDGE), Map 50 (SIMPLE_EDGE)
+Reducer 3 <- Map 37 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Map 37 (SIMPLE_EDGE), Reducer 29 (SIMPLE_EDGE)
+Reducer 31 <- Map 46 (SIMPLE_EDGE), Reducer 30 (SIMPLE_EDGE), Union 24 (CONTAINS)
+Reducer 32 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 33 <- Map 11 (SIMPLE_EDGE), Map 51 (SIMPLE_EDGE)
+Reducer 34 <- Map 37 (SIMPLE_EDGE), Reducer 33 (SIMPLE_EDGE)
+Reducer 35 <- Map 48 (SIMPLE_EDGE), Reducer 34 (SIMPLE_EDGE), Union 26 (CONTAINS)
+Reducer 36 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 38 <- Map 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 39 <- Map 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Map 44 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 40 <- Map 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 41 <- Map 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 42 <- Map 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 43 <- Map 37 (CUSTOM_SIMPLE_EDGE)
+Reducer 6 <- Union 5 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 8 <- Union 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 27 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 10 vectorized
+      File Output Operator [FS_633]
+        Select Operator [SEL_632] (rows=100 width=160)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+          Limit [LIM_631] (rows=100 width=152)
+            Number of rows:100
+            Select Operator [SEL_630] (rows=3422897230256 width=151)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+            <-Reducer 9 [SIMPLE_EDGE]
+              SHUFFLE [RS_169]
+                Select Operator [SEL_168] (rows=3422897230256 width=151)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                  Filter Operator [FIL_167] (rows=3422897230256 width=479)
+                    predicate:((_col13 / _col6) < 0.9)
+                    Merge Join Operator [MERGEJOIN_512] (rows=10268691690770 width=479)
+                      Conds:RS_625._col0, _col1, _col2, _col3=RS_629._col0, _col1, _col2, _col3(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col11","_col12","_col13"]
+                    <-Reducer 27 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_629]
+                        PartitionCols:_col0, _col1, _col2, _col3
+                        Select Operator [SEL_628] (rows=84235776 width=247)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                          Group By Operator [GBY_627] (rows=84235776 width=135)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                            Group By Operator [GBY_626] (rows=736356923 width=131)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                            <-Union 26 [SIMPLE_EDGE]
+                              <-Reducer 25 [CONTAINS] vectorized
+                                Reduce Output Operator [RS_663]
+                                  PartitionCols:_col0, _col1, _col2, _col3
+                                  Group By Operator [GBY_662] (rows=736356923 width=131)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                    Group By Operator [GBY_661] (rows=621178955 width=131)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                                    <-Union 24 [SIMPLE_EDGE]
+                                      <-Reducer 23 [CONTAINS]
+                                        Reduce Output Operator [RS_536]
+                                          PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                          Group By Operator [GBY_535] (rows=621178955 width=131)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                            Select Operator [SEL_533] (rows=170474971 width=131)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Merge Join Operator [MERGEJOIN_532] (rows=170474971 width=234)
+                                                Conds:RS_99._col1, _col2=RS_618._col0, _col1(Left Outer),Output:["_col3","_col4","_col7","_col8","_col9","_col10","_col13","_col14"]
+                                              <-Map 44 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_618]
+                                                  PartitionCols:_col0, _col1
+                                                  Select Operator [SEL_616] (rows=28798881 width=121)
+                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                    TableScan [TS_9] (rows=28798881 width=121)
+                                                      default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_item_sk","cr_order_number","cr_return_quantity","cr_return_amount"]
+                                              <-Reducer 22 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_99]
+                                                  PartitionCols:_col1, _col2
+                                                  Merge Join Operator [MERGEJOIN_504] (rows=96821196 width=138)
+                                                    Conds:RS_96._col1=RS_593._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col7","_col8","_col9","_col10"]
+                                                  <-Map 37 [SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_593]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_586] (rows=45745 width=19)
+                                                        Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                        Filter Operator [FIL_585] (rows=45745 width=109)
+                                                          predicate:((i_category = 'Sports') and i_brand_id is not null and i_category_id is not null and i_class_id is not null and i_manufact_id is not null)
+                                                          TableScan [TS_6] (rows=462000 width=109)
+                                                            default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand_id","i_class_id","i_category_id","i_category","i_manufact_id"]
+                                                  <-Reducer 21 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_96]
+                                                      PartitionCols:_col1
+                                                      Merge Join Operator [MERGEJOIN_503] (rows=101592102 width=122)
+                                                        Conds:RS_660._col0=RS_565._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                      <-Map 11 [SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_565]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_556] (rows=652 width=4)
+                                                            Output:["_col0"]
+                                                            Filter Operator [FIL_552] (rows=652 width=8)
+                                                              predicate:(d_year = 2002)
+                                                              TableScan [TS_3] (rows=73049 width=8)
+                                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                                      <-Map 49 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_660]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_659] (rows=286549727 width=127)
+                                                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                            Filter Operator [FIL_658] (rows=286549727 width=127)
+                                                              predicate:((cs_item_sk BETWEEN DynamicValue(RS_97_item_i_item_sk_min) AND DynamicValue(RS_97_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_97_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_94_date_dim_d_date_sk_min) AND DynamicValue(RS_94_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_94_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                              TableScan [TS_82] (rows=287989836 width=127)
+                                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_order_number","cs_quantity","cs_ext_sales_price"]
+                                                              <-Reducer 28 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_655]
+                                                                  Group By Operator [GBY_654] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_580]
+                                                                      Group By Operator [GBY_574] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_566] (rows=652 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_556]
+                                                              <-Reducer 41 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_657]
+                                                                  Group By Operator [GBY_656] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 37 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_608]
+                                                                      Group By Operator [GBY_602] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_594] (rows=45745 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_586]
+                                      <-Reducer 31 [CONTAINS]
+                                        Reduce Output Operator [RS_545]
+                                          PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                          Group By Operator [GBY_544] (rows=621178955 width=131)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                            Select Operator [SEL_542] (rows=450703984 width=131)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Merge Join Operator [MERGEJOIN_541] (rows=450703984 width=204)
+                                                Conds:RS_120._col1, _col2=RS_643._col0, _col1(Left Outer),Output:["_col3","_col4","_col7","_col8","_col9","_col10","_col13","_col14"]
+                                              <-Map 46 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_643]
+                                                  PartitionCols:_col0, _col1
+                                                  Select Operator [SEL_641] (rows=57591150 width=119)
+                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                    TableScan [TS_30] (rows=57591150 width=119)
+                                                      default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number","sr_return_quantity","sr_return_amt"]
+                                              <-Reducer 30 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_120]
+                                                  PartitionCols:_col1, _col2
+                                                  Merge Join Operator [MERGEJOIN_507] (rows=187186493 width=124)
+                                                    Conds:RS_117._col1=RS_595._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col7","_col8","_col9","_col10"]
+                                                  <-Map 37 [SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_595]
+                                                      PartitionCols:_col0
+                                                       Please refer to the previous Select Operator [SEL_586]
+                                                  <-Reducer 29 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_117]
+                                                      PartitionCols:_col1
+                                                      Merge Join Operator [MERGEJOIN_506] (rows=196410188 width=109)
+                                                        Conds:RS_670._col0=RS_567._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                      <-Map 11 [SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_567]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_557] (rows=652 width=4)
+                                                            Output:["_col0"]
+                                                            Filter Operator [FIL_553] (rows=652 width=8)
+                                                              predicate:(d_year = 2002)
+                                                               Please refer to the previous TableScan [TS_3]
+                                                      <-Map 50 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_670]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_669] (rows=550076554 width=122)
+                                                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                            Filter Operator [FIL_668] (rows=550076554 width=122)
+                                                              predicate:((ss_item_sk BETWEEN DynamicValue(RS_118_item_i_item_sk_min) AND DynamicValue(RS_118_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_118_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_115_date_dim_d_date_sk_min) AND DynamicValue(RS_115_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_115_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                              TableScan [TS_103] (rows=575995635 width=122)
+                                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ticket_number","ss_quantity","ss_ext_sales_price"]
+                                                              <-Reducer 32 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_665]
+                                                                  Group By Operator [GBY_664] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_581]
+                                                                      Group By Operator [GBY_575] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_568] (rows=652 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_557]
+                                                              <-Reducer 42 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_667]
+                                                                  Group By Operator [GBY_666] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 37 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_609]
+                                                                      Group By Operator [GBY_603] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_596] (rows=45745 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_586]
+                              <-Reducer 35 [CONTAINS]
+                                Reduce Output Operator [RS_550]
+                                  PartitionCols:_col0, _col1, _col2, _col3
+                                  Group By Operator [GBY_549] (rows=736356923 width=131)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                    Select Operator [SEL_547] (rows=115177968 width=131)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                      Merge Join Operator [MERGEJOIN_546] (rows=115177968 width=220)
+                                        Conds:RS_148._col1, _col2=RS_653._col0, _col1(Left Outer),Output:["_col3","_col4","_col7","_col8","_col9","_col10","_col13","_col14"]
+                                      <-Map 48 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_653]
+                                          PartitionCols:_col0, _col1
+                                          Select Operator [SEL_651] (rows=14398467 width=118)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            TableScan [TS_58] (rows=14398467 width=118)
+                                              default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_item_sk","wr_order_number","wr_return_quantity","wr_return_amt"]
+                                      <-Reducer 34 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_148]
+                                          PartitionCols:_col1, _col2
+                                          Merge Join Operator [MERGEJOIN_510] (rows=48990732 width=139)
+                                            Conds:RS_145._col1=RS_597._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col7","_col8","_col9","_col10"]
+                                          <-Map 37 [SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_597]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_586]
+                                          <-Reducer 33 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_145]
+                                              PartitionCols:_col1
+                                              Merge Join Operator [MERGEJOIN_509] (rows=51404771 width=123)
+                                                Conds:RS_677._col0=RS_569._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_569]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_558] (rows=652 width=4)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_554] (rows=652 width=8)
+                                                      predicate:(d_year = 2002)
+                                                       Please refer to the previous TableScan [TS_3]
+                                              <-Map 51 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_677]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_676] (rows=143966864 width=127)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                    Filter Operator [FIL_675] (rows=143966864 width=127)
+                                                      predicate:((ws_item_sk BETWEEN DynamicValue(RS_146_item_i_item_sk_min) AND DynamicValue(RS_146_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_146_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_143_date_dim_d_date_sk_min) AND DynamicValue(RS_143_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_143_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                                      TableScan [TS_131] (rows=144002668 width=127)
+                                                        default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_order_number","ws_quantity","ws_ext_sales_price"]
+                                                      <-Reducer 36 [BROADCAST_EDGE] vectorized
+                                                        BROADCAST [RS_672]
+                                                          Group By Operator [GBY_671] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                          <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_582]
+                                                              Group By Operator [GBY_576] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                Select Operator [SEL_570] (rows=652 width=4)
+                                                                  Output:["_col0"]
+                                                                   Please refer to the previous Select Operator [SEL_558]
+                                                      <-Reducer 43 [BROADCAST_EDGE] vectorized
+                                                        BROADCAST [RS_674]
+                                                          Group By Operator [GBY_673] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                          <-Map 37 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_610]
+                                                              Group By Operator [GBY_604] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                Select Operator [SEL_598] (rows=45745 width=4)
+                                                                  Output:["_col0"]
+                                                                   Please refer to the previous Select Operator [SEL_586]
+                    <-Reducer 8 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_625]
+                        PartitionCols:_col0, _col1, _col2, _col3
+                        Select Operator [SEL_624] (rows=84235776 width=247)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                          Group By Operator [GBY_623] (rows=84235776 width=135)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col0, _col1, _col2, _col3
+                            Group By Operator [GBY_622] (rows=736356923 width=131)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                            <-Union 7 [SIMPLE_EDGE]
+                              <-Reducer 19 [CONTAINS]
+                                Reduce Output Operator [RS_531]
+                                  PartitionCols:_col0, _col1, _col2, _col3
+                                  Group By Operator [GBY_530] (rows=736356923 width=131)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                    Select Operator [SEL_528] (rows=115177968 width=131)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                      Merge Join Operator [MERGEJOIN_527] (rows=115177968 width=220)
+                                        Conds:RS_66._col1, _col2=RS_652._col0, _col1(Left Outer),Output:["_col3","_col4","_col7","_col8","_col9","_col10","_col13","_col14"]
+                                      <-Map 48 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_652]
+                                          PartitionCols:_col0, _col1
+                                           Please refer to the previous Select Operator [SEL_651]
+                                      <-Reducer 18 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_66]
+                                          PartitionCols:_col1, _col2
+                                          Merge Join Operator [MERGEJOIN_501] (rows=48990732 width=139)
+                                            Conds:RS_63._col1=RS_591._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col7","_col8","_col9","_col10"]
+                                          <-Map 37 [SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_591]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_586]
+                                          <-Reducer 17 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_63]
+                                              PartitionCols:_col1
+                                              Merge Join Operator [MERGEJOIN_500] (rows=51404771 width=123)
+                                                Conds:RS_650._col0=RS_563._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_563]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_555] (rows=652 width=4)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_551] (rows=652 width=8)
+                                                      predicate:(d_year = 2001)
+                                                       Please refer to the previous TableScan [TS_3]
+                                              <-Map 47 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_650]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_649] (rows=143966864 width=127)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                    Filter Operator [FIL_648] (rows=143966864 width=127)
+                                                      predicate:((ws_item_sk BETWEEN DynamicValue(RS_64_item_i_item_sk_min) AND DynamicValue(RS_64_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_64_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_61_date_dim_d_date_sk_min) AND DynamicValue(RS_61_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_61_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                                      TableScan [TS_49] (rows=144002668 width=127)
+                                                        default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_order_number","ws_quantity","ws_ext_sales_price"]
+                                                      <-Reducer 20 [BROADCAST_EDGE] vectorized
+                                                        BROADCAST [RS_645]
+                                                          Group By Operator [GBY_644] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                          <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_579]
+                                                              Group By Operator [GBY_573] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                Select Operator [SEL_564] (rows=652 width=4)
+                                                                  Output:["_col0"]
+                                                                   Please refer to the previous Select Operator [SEL_555]
+                                                      <-Reducer 40 [BROADCAST_EDGE] vectorized
+                                                        BROADCAST [RS_647]
+                                                          Group By Operator [GBY_646] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                          <-Map 37 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_607]
+                                                              Group By Operator [GBY_601] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                Select Operator [SEL_592] (rows=45745 width=4)
+                                                                  Output:["_col0"]
+                                                                   Please refer to the previous Select Operator [SEL_586]
+                              <-Reducer 6 [CONTAINS] vectorized
+                                Reduce Output Operator [RS_621]
+                                  PartitionCols:_col0, _col1, _col2, _col3
+                                  Group By Operator [GBY_620] (rows=736356923 width=131)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                    Group By Operator [GBY_619] (rows=621178955 width=131)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                                    <-Union 5 [SIMPLE_EDGE]
+                                      <-Reducer 15 [CONTAINS]
+                                        Reduce Output Operator [RS_526]
+                                          PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                          Group By Operator [GBY_525] (rows=621178955 width=131)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                            Select Operator [SEL_523] (rows=450703984 width=131)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Merge Join Operator [MERGEJOIN_522] (rows=450703984 width=204)
+                                                Conds:RS_38._col1, _col2=RS_642._col0, _col1(Left Outer),Output:["_col3","_col4","_col7","_col8","_col9","_col10","_col13","_col14"]
+                                              <-Map 46 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_642]
+                                                  PartitionCols:_col0, _col1
+                                                   Please refer to the previous Select Operator [SEL_641]
+                                              <-Reducer 14 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_38]
+                                                  PartitionCols:_col1, _col2
+                                                  Merge Join Operator [MERGEJOIN_498] (rows=187186493 width=124)
+                                                    Conds:RS_35._col1=RS_589._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col7","_col8","_col9","_col10"]
+                                                  <-Map 37 [SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_589]
+                                                      PartitionCols:_col0
+                                                       Please refer to the previous Select Operator [SEL_586]
+                                                  <-Reducer 13 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_35]
+                                                      PartitionCols:_col1
+                                                      Merge Join Operator [MERGEJOIN_497] (rows=196410188 width=109)
+                                                        Conds:RS_640._col0=RS_561._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                      <-Map 11 [SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_561]
+                                                          PartitionCols:_col0
+                                                           Please refer to the previous Select Operator [SEL_555]
+                                                      <-Map 45 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_640]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_639] (rows=550076554 width=122)
+                                                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                            Filter Operator [FIL_638] (rows=550076554 width=122)
+                                                              predicate:((ss_item_sk BETWEEN DynamicValue(RS_36_item_i_item_sk_min) AND DynamicValue(RS_36_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_36_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_33_date_dim_d_date_sk_min) AND DynamicValue(RS_33_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_33_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                              TableScan [TS_21] (rows=575995635 width=122)
+                                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ticket_number","ss_quantity","ss_ext_sales_price"]
+                                                              <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_635]
+                                                                  Group By Operator [GBY_634] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_578]
+                                                                      Group By Operator [GBY_572] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_562] (rows=652 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_555]
+                                                              <-Reducer 39 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_637]
+                                                                  Group By Operator [GBY_636] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 37 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_606]
+                                                                      Group By Operator [GBY_600] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_590] (rows=45745 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_586]
+                                      <-Reducer 4 [CONTAINS]
+                                        Reduce Output Operator [RS_517]
+                                          PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                                          Group By Operator [GBY_516] (rows=621178955 width=131)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],keys:_col0, _col1, _col2, _col3, _col4, _col5
+                                            Select Operator [SEL_514] (rows=170474971 width=131)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Merge Join Operator [MERGEJOIN_513] (rows=170474971 width=234)
+                                                Conds:RS_17._col1, _col2=RS_617._col0, _col1(Left Outer),Output:["_col3","_col4","_col7","_col8","_col9","_col10","_col13","_col14"]
+                                              <-Map 44 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_617]
+                                                  PartitionCols:_col0, _col1
+                                                   Please refer to the previous Select Operator [SEL_616]
+                                              <-Reducer 3 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_17]
+                                                  PartitionCols:_col1, _col2
+                                                  Merge Join Operator [MERGEJOIN_495] (rows=96821196 width=138)
+                                                    Conds:RS_14._col1=RS_587._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col7","_col8","_col9","_col10"]
+                                                  <-Map 37 [SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_587]
+                                                      PartitionCols:_col0
+                                                       Please refer to the previous Select Operator [SEL_586]
+                                                  <-Reducer 2 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_14]
+                                                      PartitionCols:_col1
+                                                      Merge Join Operator [MERGEJOIN_494] (rows=101592102 width=122)
+                                                        Conds:RS_615._col0=RS_559._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                      <-Map 11 [SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_559]
+                                                          PartitionCols:_col0
+                                                           Please refer to the previous Select Operator [SEL_555]
+                                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                                        SHUFFLE [RS_615]
+                                                          PartitionCols:_col0
+                                                          Select Operator [SEL_614] (rows=286549727 width=127)
+                                                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                            Filter Operator [FIL_613] (rows=286549727 width=127)
+                                                              predicate:((cs_item_sk BETWEEN DynamicValue(RS_15_item_i_item_sk_min) AND DynamicValue(RS_15_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_15_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_12_date_dim_d_date_sk_min) AND DynamicValue(RS_12_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_12_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                              TableScan [TS_0] (rows=287989836 width=127)
+                                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_order_number","cs_quantity","cs_ext_sales_price"]
+                                                              <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_584]
+                                                                  Group By Operator [GBY_583] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_577]
+                                                                      Group By Operator [GBY_571] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_560] (rows=652 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_555]
+                                                              <-Reducer 38 [BROADCAST_EDGE] vectorized
+                                                                BROADCAST [RS_612]
+                                                                  Group By Operator [GBY_611] (rows=1 width=12)
+                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                  <-Map 37 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_605]
+                                                                      Group By Operator [GBY_599] (rows=1 width=12)
+                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                        Select Operator [SEL_588] (rows=45745 width=4)
+                                                                          Output:["_col0"]
+                                                                           Please refer to the previous Select Operator [SEL_586]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query76.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query76.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query76.q.out
new file mode 100644
index 0000000..56d4500
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query76.q.out
@@ -0,0 +1,197 @@
+PREHOOK: query: explain
+select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
+        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
+         FROM store_sales, item, date_dim
+         WHERE ss_addr_sk IS NULL
+           AND ss_sold_date_sk=d_date_sk
+           AND ss_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
+         FROM web_sales, item, date_dim
+         WHERE ws_web_page_sk IS NULL
+           AND ws_sold_date_sk=d_date_sk
+           AND ws_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
+         FROM catalog_sales, item, date_dim
+         WHERE cs_warehouse_sk IS NULL
+           AND cs_sold_date_sk=d_date_sk
+           AND cs_item_sk=i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
+        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
+         FROM store_sales, item, date_dim
+         WHERE ss_addr_sk IS NULL
+           AND ss_sold_date_sk=d_date_sk
+           AND ss_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
+         FROM web_sales, item, date_dim
+         WHERE ws_web_page_sk IS NULL
+           AND ws_sold_date_sk=d_date_sk
+           AND ws_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
+         FROM catalog_sales, item, date_dim
+         WHERE cs_warehouse_sk IS NULL
+           AND cs_sold_date_sk=d_date_sk
+           AND cs_item_sk=i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Map 16 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE), Union 4 (CONTAINS)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 11 (SIMPLE_EDGE)
+Reducer 3 <- Map 12 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE), Union 4 (CONTAINS)
+Reducer 5 <- Union 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 1 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
+Reducer 8 <- Map 14 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE), Union 4 (CONTAINS)
+Reducer 9 <- Map 1 (SIMPLE_EDGE), Map 15 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_175]
+        Limit [LIM_174] (rows=100 width=408)
+          Number of rows:100
+          Select Operator [SEL_173] (rows=5600 width=408)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_172]
+              Group By Operator [GBY_171] (rows=5600 width=408)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+              <-Union 4 [SIMPLE_EDGE]
+                <-Reducer 10 [CONTAINS]
+                  Reduce Output Operator [RS_161]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4
+                    Group By Operator [GBY_160] (rows=224000 width=408)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["count()","sum(_col5)"],keys:_col0, _col1, _col2, _col3, _col4
+                      Top N Key Operator [TNK_159] (rows=26219002 width=388)
+                        keys:_col0, _col1, _col2, _col3, _col4,sort order:+++++,top n:100
+                        Select Operator [SEL_157] (rows=1433911 width=399)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          Merge Join Operator [MERGEJOIN_156] (rows=1433911 width=209)
+                            Conds:RS_39._col0=RS_185._col0(Inner),Output:["_col2","_col4","_col6","_col7"]
+                          <-Map 16 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_185]
+                              PartitionCols:_col0
+                              Select Operator [SEL_184] (rows=73049 width=12)
+                                Output:["_col0","_col1","_col2"]
+                                TableScan [TS_34] (rows=73049 width=12)
+                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                          <-Reducer 9 [SIMPLE_EDGE]
+                            SHUFFLE [RS_39]
+                              PartitionCols:_col0
+                              Merge Join Operator [MERGEJOIN_142] (rows=1433911 width=205)
+                                Conds:RS_183._col1=RS_165._col0(Inner),Output:["_col0","_col2","_col4"]
+                              <-Map 1 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_165]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_162] (rows=462000 width=94)
+                                    Output:["_col0","_col1"]
+                                    TableScan [TS_0] (rows=462000 width=94)
+                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_category"]
+                              <-Map 15 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_183]
+                                  PartitionCols:_col1
+                                  Select Operator [SEL_182] (rows=1433911 width=119)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_181] (rows=1433911 width=123)
+                                      predicate:(cs_sold_date_sk is not null and cs_warehouse_sk is null)
+                                      TableScan [TS_29] (rows=287989836 width=123)
+                                        default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_warehouse_sk","cs_item_sk","cs_ext_sales_price"]
+                <-Reducer 3 [CONTAINS]
+                  Reduce Output Operator [RS_149]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4
+                    Group By Operator [GBY_148] (rows=224000 width=408)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["count()","sum(_col5)"],keys:_col0, _col1, _col2, _col3, _col4
+                      Top N Key Operator [TNK_147] (rows=26219002 width=388)
+                        keys:_col0, _col1, _col2, _col3, _col4,sort order:+++++,top n:100
+                        Select Operator [SEL_145] (rows=24749363 width=387)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          Merge Join Operator [MERGEJOIN_144] (rows=24749363 width=204)
+                            Conds:RS_10._col2=RS_170._col0(Inner),Output:["_col1","_col4","_col6","_col7"]
+                          <-Map 12 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_170]
+                              PartitionCols:_col0
+                              Select Operator [SEL_169] (rows=73049 width=12)
+                                Output:["_col0","_col1","_col2"]
+                                TableScan [TS_5] (rows=73049 width=12)
+                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                          <-Reducer 2 [SIMPLE_EDGE]
+                            SHUFFLE [RS_10]
+                              PartitionCols:_col2
+                              Merge Join Operator [MERGEJOIN_138] (rows=24749363 width=200)
+                                Conds:RS_163._col0=RS_168._col1(Inner),Output:["_col1","_col2","_col4"]
+                              <-Map 1 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_163]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select Operator [SEL_162]
+                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_168]
+                                  PartitionCols:_col1
+                                  Select Operator [SEL_167] (rows=24749363 width=114)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_166] (rows=24749363 width=118)
+                                      predicate:(ss_addr_sk is null and ss_sold_date_sk is not null)
+                                      TableScan [TS_2] (rows=575995635 width=118)
+                                        default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
+                <-Reducer 8 [CONTAINS]
+                  Reduce Output Operator [RS_155]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4
+                    Group By Operator [GBY_154] (rows=224000 width=408)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["count()","sum(_col5)"],keys:_col0, _col1, _col2, _col3, _col4
+                      Top N Key Operator [TNK_153] (rows=26219002 width=388)
+                        keys:_col0, _col1, _col2, _col3, _col4,sort order:+++++,top n:100
+                        Select Operator [SEL_151] (rows=35728 width=394)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          Merge Join Operator [MERGEJOIN_150] (rows=35728 width=209)
+                            Conds:RS_24._col0=RS_180._col0(Inner),Output:["_col2","_col4","_col6","_col7"]
+                          <-Map 14 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_180]
+                              PartitionCols:_col0
+                              Select Operator [SEL_179] (rows=73049 width=12)
+                                Output:["_col0","_col1","_col2"]
+                                TableScan [TS_19] (rows=73049 width=12)
+                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                          <-Reducer 7 [SIMPLE_EDGE]
+                            SHUFFLE [RS_24]
+                              PartitionCols:_col0
+                              Merge Join Operator [MERGEJOIN_140] (rows=35728 width=205)
+                                Conds:RS_178._col1=RS_164._col0(Inner),Output:["_col0","_col2","_col4"]
+                              <-Map 1 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_164]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Select Operator [SEL_162]
+                              <-Map 13 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_178]
+                                  PartitionCols:_col1
+                                  Select Operator [SEL_177] (rows=35728 width=119)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_176] (rows=35728 width=123)
+                                      predicate:(ws_sold_date_sk is not null and ws_web_page_sk is null)
+                                      TableScan [TS_14] (rows=144002668 width=123)
+                                        default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_web_page_sk","ws_ext_sales_price"]
+


[34/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query31.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query31.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query31.q.out
new file mode 100644
index 0000000..41321f4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query31.q.out
@@ -0,0 +1,199 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(ca_county=[$0], d_year=[CAST(2000):INTEGER], web_q1_q2_increase=[/($14, $9)], store_q1_q2_increase=[/($1, $4)], web_q2_q3_increase=[/($12, $14)], store_q2_q3_increase=[/($7, $1)])
+  HiveJoin(condition=[AND(AND(=($0, $8), CASE($5, CASE($10, >(/($14, $9), /($1, $4)), >(null, /($1, $4))), CASE($10, >(/($14, $9), null), null))), CASE($2, CASE($15, >(/($12, $14), /($7, $1)), >(null, /($7, $1))), CASE($15, >(/($12, $14), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0)])
+          HiveAggregate(group=[{1}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                HiveFilter(condition=[IS NOT NULL($7)])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[AND(=($10, 2), =($6, 2000))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0)])
+          HiveAggregate(group=[{1}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                HiveFilter(condition=[IS NOT NULL($7)])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[AND(=($10, 1), =($6, 2000))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(ca_county=[$0], $f1=[$1])
+        HiveAggregate(group=[{1}], agg#0=[sum($4)])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ca_address_sk=[$0], ca_county=[$7])
+              HiveFilter(condition=[IS NOT NULL($7)])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[AND(=($10, 3), =($6, 2000))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+    HiveProject($f0=[$0], $f3=[$1], >=[$2], ca_county=[$3], $f1=[$4], $f00=[$5], $f30=[$6], >0=[$7])
+      HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0)])
+            HiveAggregate(group=[{1}], agg#0=[sum($4)])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                  HiveFilter(condition=[IS NOT NULL($7)])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($10, 1), =($6, 2000))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(ca_county=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($4)])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                  HiveFilter(condition=[IS NOT NULL($7)])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($10, 3), =($6, 2000))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject($f0=[$0], $f3=[$1], >=[>($1, 0)])
+          HiveAggregate(group=[{1}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                HiveFilter(condition=[IS NOT NULL($7)])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[AND(=($10, 2), =($6, 2000))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query32.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query32.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query32.q.out
new file mode 100644
index 0000000..c7fb1dd
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query32.q.out
@@ -0,0 +1,89 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0])
+    HiveAggregate(group=[{}], agg#0=[sum($2)])
+      HiveJoin(condition=[AND(>($2, $5), =($6, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_discount_amt=[$22])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+          HiveProject(d_date_sk=[$0])
+            HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00)])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(cs_item_sk=[$0], CAST3=[$1], i_item_sk=[$2])
+          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cs_item_sk=[$0], CAST3=[CAST(*(1.3, /($1, $2))):DECIMAL(14, 7)])
+              HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+                HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_discount_amt=[$22])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(i_item_sk=[$0])
+              HiveFilter(condition=[=($13, 269)])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query33.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query33.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query33.q.out
new file mode 100644
index 0000000..e8824dd
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query33.q.out
@@ -0,0 +1,238 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+  HiveProject(i_manufact_id=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(i_manufact_id=[$0], $f1=[$1])
+        HiveUnion(all=[true])
+          HiveProject(i_manufact_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
+                    HiveFilter(condition=[IS NOT NULL($13)])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_manufact_id=[$0])
+                    HiveAggregate(group=[{13}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Books'), IS NOT NULL($13))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_addr_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -6)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_manufact_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
+                    HiveFilter(condition=[IS NOT NULL($13)])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_manufact_id=[$0])
+                    HiveAggregate(group=[{13}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Books'), IS NOT NULL($13))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], cs_sold_date_sk=[$1], cs_bill_addr_sk=[$2], cs_item_sk=[$3], cs_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -6)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_manufact_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
+                    HiveFilter(condition=[IS NOT NULL($13)])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_manufact_id=[$0])
+                    HiveAggregate(group=[{13}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Books'), IS NOT NULL($13))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ws_sold_date_sk=[$1], ws_item_sk=[$2], ws_bill_addr_sk=[$3], ws_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -6)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query34.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query34.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query34.q.out
new file mode 100644
index 0000000..6e7384e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query34.q.out
@@ -0,0 +1,98 @@
+PREHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0 
+	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
+	else null 
+	end)  > 1.2
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County',
+                           'Fairfield County','Jackson County','Barrow County','Pennington County')
+    group by ss_ticket_number,ss_customer_sk) dn,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 15 and 20
+    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0 
+	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
+	else null 
+	end)  > 1.2
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County',
+                           'Fairfield County','Jackson County','Barrow County','Pennington County')
+    group by ss_ticket_number,ss_customer_sk) dn,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 15 and 20
+    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[DESC-nulls-last])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], c_salutation=[$1], c_preferred_cust_flag=[$4], ss_ticket_number=[$5], cnt=[$7])
+    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(c_customer_sk=[$0], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10])
+        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+      HiveProject(ss_ticket_number=[$0], ss_customer_sk=[$1], $f2=[$2])
+        HiveFilter(condition=[BETWEEN(false, $2, 15, 20)])
+          HiveProject(ss_ticket_number=[$1], ss_customer_sk=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 4}], agg#0=[count()])
+              HiveJoin(condition=[=($3, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($2, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_store_sk=[$7], ss_ticket_number=[$9])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($3))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(IN($6, 2000, 2001, 2002), OR(BETWEEN(false, $9, 1, 3), BETWEEN(false, $9, 25, 28)))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(hd_demo_sk=[$0])
+                    HiveFilter(condition=[AND(IN($2, _UTF-16LE'>10000', _UTF-16LE'unknown'), >($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1.2), null))])
+                      HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(s_store_sk=[$0])
+                  HiveFilter(condition=[IN($23, _UTF-16LE'Mobile County', _UTF-16LE'Maverick County', _UTF-16LE'Huron County', _UTF-16LE'Kittitas County', _UTF-16LE'Fairfield County', _UTF-16LE'Jackson County', _UTF-16LE'Barrow County', _UTF-16LE'Pennington County')])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query35.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query35.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query35.q.out
new file mode 100644
index 0000000..e79c6b7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query35.q.out
@@ -0,0 +1,173 @@
+PREHOOK: query: explain cbo
+select   
+  ca_state,
+  cd_gender,
+  cd_marital_status,
+  count(*) cnt1,
+  avg(cd_dep_count),
+  max(cd_dep_count),
+  sum(cd_dep_count),
+  cd_dep_employed_count,
+  count(*) cnt2,
+  avg(cd_dep_employed_count),
+  max(cd_dep_employed_count),
+  sum(cd_dep_employed_count),
+  cd_dep_college_count,
+  count(*) cnt3,
+  avg(cd_dep_college_count),
+  max(cd_dep_college_count),
+  sum(cd_dep_college_count)
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_qoy < 4) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4))
+ group by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select   
+  ca_state,
+  cd_gender,
+  cd_marital_status,
+  count(*) cnt1,
+  avg(cd_dep_count),
+  max(cd_dep_count),
+  sum(cd_dep_count),
+  cd_dep_employed_count,
+  count(*) cnt2,
+  avg(cd_dep_employed_count),
+  max(cd_dep_employed_count),
+  sum(cd_dep_employed_count),
+  cd_dep_college_count,
+  count(*) cnt3,
+  avg(cd_dep_college_count),
+  max(cd_dep_college_count),
+  sum(cd_dep_college_count)
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_qoy < 4) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4))
+ group by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(ca_state=[$0], cd_gender=[$1], cd_marital_status=[$2], cnt1=[$3], _o__c4=[$4], _o__c5=[$5], _o__c6=[$6], cd_dep_employed_count=[$7], cnt2=[$8], _o__c9=[$9], _o__c10=[$10], _o__c11=[$11], cd_dep_college_count=[$12], cnt3=[$13], _o__c14=[$14], _o__c15=[$15], _o__c16=[$16])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$17], sort4=[$7], sort5=[$12], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], fetch=[100])
+    HiveProject(ca_state=[$0], cd_gender=[$1], cd_marital_status=[$2], cnt1=[$6], _o__c4=[/(CAST($7):DOUBLE, $8)], _o__c5=[$9], _o__c6=[$7], cd_dep_employed_count=[$4], cnt2=[$6], _o__c9=[/(CAST($10):DOUBLE, $11)], _o__c10=[$12], _o__c11=[$10], cd_dep_college_count=[$5], cnt3=[$6], _o__c14=[/(CAST($13):DOUBLE, $14)], _o__c15=[$15], _o__c16=[$13], (tok_table_or_col cd_dep_count)=[$3])
+      HiveAggregate(group=[{4, 6, 7, 8, 9, 10}], agg#0=[count()], agg#1=[sum($8)], agg#2=[count($8)], agg#3=[max($8)], agg#4=[sum($9)], agg#5=[count($9)], agg#6=[max($9)], agg#7=[sum($10)], agg#8=[count($10)], agg#9=[max($10)])
+        HiveFilter(condition=[OR(IS NOT NULL($12), IS NOT NULL($14))])
+          HiveJoin(condition=[=($0, $13)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $11)], joinType=[left], algorithm=[none], cost=[not available])
+              HiveSemiJoin(condition=[=($0, $11)], joinType=[inner])
+                HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                        HiveTableScan(table=[[default, customer]], table:alias=[c])
+                    HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                      HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
+                  HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_dep_count=[$6], cd_dep_employed_count=[$7], cd_dep_college_count=[$8])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+                HiveProject(ss_customer_sk0=[$1])
+                  HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($6, 1999), <($10, 4))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(ws_bill_customer_sk0=[$0], $f1=[true])
+                HiveAggregate(group=[{1}])
+                  HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($6, 1999), <($10, 4))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(cs_ship_customer_sk0=[$0], $f1=[true])
+              HiveAggregate(group=[{1}])
+                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_ship_customer_sk=[$7])
+                    HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[AND(=($6, 1999), <($10, 4))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out
new file mode 100644
index 0000000..d403126
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query36.q.out
@@ -0,0 +1,90 @@
+PREHOOK: query: explain cbo
+select  
+    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,item
+   ,store
+ where
+    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 s_state in ('SD','FL','MI','LA',
+                 'MO','SC','AL','GA')
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then i_category end
+  ,rank_within_parent
+  limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,item
+   ,store
+ where
+    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 s_state in ('SD','FL','MI','LA',
+                 'MO','SC','AL','GA')
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then i_category end
+  ,rank_within_parent
+  limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(gross_margin=[$0], i_category=[$1], i_class=[$2], lochierarchy=[$3], rank_within_parent=[$4])
+  HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(gross_margin=[/($2, $3)], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($4, 1), grouping($4, 0))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($4, 1), grouping($4, 0)), CASE(=(grouping($4, 0), 0), $0, null) ORDER BY /($2, $3) NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok_table_or_col i_category))=[CASE(=(+(grouping($4, 1), grouping($4, 0)), 0), $0, null)])
+      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], GROUPING__ID=[$4])
+        HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], GROUPING__ID=[GROUPING__ID()])
+          HiveProject($f0=[$9], $f1=[$8], $f2=[$4], $f3=[$3])
+            HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($6, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_ext_sales_price=[$15], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0])
+                    HiveFilter(condition=[=($6, 1999)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                HiveProject(s_store_sk=[$0])
+                  HiveFilter(condition=[IN($24, _UTF-16LE'SD', _UTF-16LE'FL', _UTF-16LE'MI', _UTF-16LE'LA', _UTF-16LE'MO', _UTF-16LE'SC', _UTF-16LE'AL', _UTF-16LE'GA')])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(i_item_sk=[$0], i_class=[$10], i_category=[$12])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query37.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query37.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query37.q.out
new file mode 100644
index 0000000..f054717
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query37.q.out
@@ -0,0 +1,62 @@
+PREHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 22 and 22 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
+ and i_manufact_id in (678,964,918,849)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 22 and 22 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
+ and i_manufact_id in (678,964,918,849)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], i_current_price=[$2])
+    HiveAggregate(group=[{2, 3, 4}])
+      HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cs_item_sk=[$15])
+            HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5])
+            HiveFilter(condition=[AND(IN($13, 678, 964, 918, 849), BETWEEN(false, $5, 22, 52))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], d_date_sk=[$2])
+          HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(inv_date_sk=[$0], inv_item_sk=[$1])
+              HiveFilter(condition=[BETWEEN(false, $3, 100, 500)])
+                HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-06-02 00:00:00, 2001-08-01 00:00:00)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query38.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query38.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query38.q.out
new file mode 100644
index 0000000..01e87d2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query38.q.out
@@ -0,0 +1,108 @@
+PREHOOK: query: explain cbo
+select  count(*) from (
+    select distinct c_last_name, c_first_name, d_date
+    from store_sales, date_dim, customer
+          where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+      and store_sales.ss_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from catalog_sales, date_dim, customer
+          where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+      and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from web_sales, date_dim, customer
+          where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+      and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+) hot_cust
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  count(*) from (
+    select distinct c_last_name, c_first_name, d_date
+    from store_sales, date_dim, customer
+          where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+      and store_sales.ss_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from catalog_sales, date_dim, customer
+          where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+      and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from web_sales, date_dim, customer
+          where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+      and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+) hot_cust
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0])
+    HiveAggregate(group=[{}], agg#0=[count()])
+      HiveProject(c_last_name=[$0], c_first_name=[$1], d_date=[$2], $f3=[$3])
+        HiveFilter(condition=[=($3, 3)])
+          HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+            HiveProject(c_last_name=[$0], c_first_name=[$1], d_date=[$2], $f3=[$3])
+              HiveUnion(all=[true])
+                HiveProject(c_last_name=[$1], c_first_name=[$0], d_date=[$2], $f3=[$3])
+                  HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                    HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                      HiveAggregate(group=[{1, 2, 6}])
+                        HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0], d_date=[$2])
+                              HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(c_last_name=[$1], c_first_name=[$0], d_date=[$2], $f3=[$3])
+                  HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                    HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                      HiveAggregate(group=[{1, 2, 6}])
+                        HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3])
+                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0], d_date=[$2])
+                              HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(c_last_name=[$1], c_first_name=[$0], d_date=[$2], $f3=[$3])
+                  HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                    HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                      HiveAggregate(group=[{1, 2, 6}])
+                        HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0], d_date=[$2])
+                              HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out
new file mode 100644
index 0000000..272bedc
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query39.q.out
@@ -0,0 +1,156 @@
+PREHOOK: query: explain cbo
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], d_moy=[CAST(4):INTEGER], mean=[$2], cov=[$3], w_warehouse_sk1=[$4], i_item_sk1=[$5], d_moy1=[CAST(5):INTEGER], mean1=[$6], cov1=[$7])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$6], sort5=[$7], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC])
+    HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[$6], cov=[$7], w_warehouse_sk0=[$0], i_item_sk0=[$1], mean0=[$2], cov0=[$3])
+      HiveJoin(condition=[AND(=($5, $1), =($4, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[/(CAST($5):DOUBLE, $4)], cov=[CASE(=(/(CAST($5):DOUBLE, $4), 0), null, /(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null, -($4, 1))), 0.5), /(CAST($5):DOUBLE, $4)))])
+          HiveFilter(condition=[CASE(=(/(CAST($5):DOUBLE, $4), 0), false, >(/(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null, -($4, 1))), 0.5), /(CAST($5):DOUBLE, $4)), 1))])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
+              HiveProject($f0=[$6], $f1=[$5], $f2=[$3], $f4=[$2], $f40=[CAST($2):DOUBLE], $f6=[*(CAST($2):DOUBLE, CAST($2):DOUBLE)])
+                HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(inv_date_sk=[$0], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3], inv_item_sk=[$1])
+                      HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($6, 1999), =($8, 5))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+                    HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+        HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[/(CAST($5):DOUBLE, $4)], cov=[CASE(=(/(CAST($5):DOUBLE, $4), 0), null, /(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null, -($4, 1))), 0.5), /(CAST($5):DOUBLE, $4)))])
+          HiveFilter(condition=[CASE(=(/(CAST($5):DOUBLE, $4), 0), false, >(/(POWER(/(-($2, /(*($3, $3), $4)), CASE(=($4, 1), null, -($4, 1))), 0.5), /(CAST($5):DOUBLE, $4)), 1))])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
+              HiveProject($f0=[$6], $f1=[$5], $f2=[$3], $f4=[$2], $f40=[CAST($2):DOUBLE], $f6=[*(CAST($2):DOUBLE, CAST($2):DOUBLE)])
+                HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(inv_date_sk=[$0], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3], inv_item_sk=[$1])
+                      HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[AND(=($6, 1999), =($8, 4))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+                    HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+
+PREHOOK: query: with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query4.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query4.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query4.q.out
new file mode 100644
index 0000000..ccec2f3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query4.q.out
@@ -0,0 +1,312 @@
+PREHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
+       ,'c' sale_type
+ from customer
+     ,catalog_sales
+     ,date_dim
+ where c_customer_sk = cs_bill_customer_sk
+   and cs_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.customer_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_c_firstyear
+     ,year_total t_c_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_c_secyear.customer_id
+   and t_s_firstyear.customer_id = t_c_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_secyear.customer_id
+   and t_s_firstyear.sale_type = 's'
+   and t_c_firstyear.sale_type = 'c'
+   and t_w_firstyear.sale_type = 'w'
+   and t_s_secyear.sale_type = 's'
+   and t_c_secyear.sale_type = 'c'
+   and t_w_secyear.sale_type = 'w'
+   and t_s_firstyear.dyear =  2001
+   and t_s_secyear.dyear = 2001+1
+   and t_c_firstyear.dyear =  2001
+   and t_c_secyear.dyear =  2001+1
+   and t_w_firstyear.dyear = 2001
+   and t_w_secyear.dyear = 2001+1
+   and t_s_firstyear.year_total > 0
+   and t_c_firstyear.year_total > 0
+   and t_w_firstyear.year_total > 0
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+ order by t_s_secyear.customer_preferred_cust_flag
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
+       ,'c' sale_type
+ from customer
+     ,catalog_sales
+     ,date_dim
+ where c_customer_sk = cs_bill_customer_sk
+   and cs_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.customer_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_c_firstyear
+     ,year_total t_c_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_c_secyear.customer_id
+   and t_s_firstyear.customer_id = t_c_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_secyear.customer_id
+   and t_s_firstyear.sale_type = 's'
+   and t_c_firstyear.sale_type = 'c'
+   and t_w_firstyear.sale_type = 'w'
+   and t_s_secyear.sale_type = 's'
+   and t_c_secyear.sale_type = 'c'
+   and t_w_secyear.sale_type = 'w'
+   and t_s_firstyear.dyear =  2001
+   and t_s_secyear.dyear = 2001+1
+   and t_c_firstyear.dyear =  2001
+   and t_c_secyear.dyear =  2001+1
+   and t_w_firstyear.dyear = 2001
+   and t_w_secyear.dyear = 2001+1
+   and t_s_firstyear.year_total > 0
+   and t_c_firstyear.year_total > 0
+   and t_w_firstyear.year_total > 0
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+ order by t_s_secyear.customer_preferred_cust_flag
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(customer_preferred_cust_flag=[$1])
+    HiveJoin(condition=[AND(=($0, $7), CASE($9, CASE($15, >(/($4, $14), /($2, $8)), >(null, /($2, $8))), CASE($15, >(/($4, $14), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject($f0=[$0], $f3=[$3], $f8=[$7])
+        HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+          HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], /=[/(+(-(-($17, $16), $14), $15), CAST(2):DECIMAL(10, 0))])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0])
+                HiveFilter(condition=[=($6, 2002)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveJoin(condition=[AND(=($4, $0), CASE($9, CASE($12, >(/($1, $11), /($3, $8)), >(null, /($3, $8))), CASE($12, >(/($1, $11), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject($f0=[$0], $f8=[$7])
+          HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+            HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], /=[/(+(-(-($25, $24), $22), $23), CAST(2):DECIMAL(10, 0))])
+                  HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0])
+                  HiveFilter(condition=[=($6, 2002)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f8=[$7])
+                HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+                  HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], /=[/(+(-(-($25, $24), $22), $23), CAST(2):DECIMAL(10, 0))])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[=($6, 2002)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
+                HiveFilter(condition=[>($7, 0)])
+                  HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+                    HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                      HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], /=[/(+(-(-($17, $16), $14), $15), CAST(2):DECIMAL(10, 0))])
+                          HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject(d_date_sk=[$0])
+                          HiveFilter(condition=[=($6, 2001)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
+              HiveFilter(condition=[>($7, 0)])
+                HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+                  HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], /=[/(+(-(-($25, $24), $22), $23), CAST(2):DECIMAL(10, 0))])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[=($6, 2001)])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(customer_id=[$0], year_total=[$7], CAST=[CAST(IS NOT NULL($7)):BOOLEAN])
+            HiveFilter(condition=[>($7, 0)])
+              HiveAggregate(group=[{1, 2, 3, 4, 5, 6, 7}], agg#0=[sum($10)])
+                HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], /=[/(+(-(-($25, $24), $22), $23), CAST(2):DECIMAL(10, 0))])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                    HiveProject(d_date_sk=[$0])
+                      HiveFilter(condition=[=($6, 2001)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out
new file mode 100644
index 0000000..5cce22a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query40.q.out
@@ -0,0 +1,89 @@
+PREHOOK: query: explain cbo
+select  
+   w_state
+  ,i_item_id
+  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
+  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
+ from
+   catalog_sales left outer join catalog_returns on
+       (cs_order_number = cr_order_number 
+        and cs_item_sk = cr_item_sk)
+  ,warehouse 
+  ,item
+  ,date_dim
+ where
+     i_current_price between 0.99 and 1.49
+ and i_item_sk          = cs_item_sk
+ and cs_warehouse_sk    = w_warehouse_sk 
+ and cs_sold_date_sk    = d_date_sk
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
+ group by
+    w_state,i_item_id
+ order by w_state,i_item_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   w_state
+  ,i_item_id
+  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
+  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
+ from
+   catalog_sales left outer join catalog_returns on
+       (cs_order_number = cr_order_number 
+        and cs_item_sk = cr_item_sk)
+  ,warehouse 
+  ,item
+  ,date_dim
+ where
+     i_current_price between 0.99 and 1.49
+ and i_item_sk          = cs_item_sk
+ and cs_warehouse_sk    = w_warehouse_sk 
+ and cs_sold_date_sk    = d_date_sk
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
+ group by
+    w_state,i_item_id
+ order by w_state,i_item_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+    HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)])
+      HiveProject($f0=[$1], $f1=[$14], $f2=[CASE($11, -($6, CASE(IS NOT NULL($9), $9, 0)), 0)], $f3=[CASE($12, -($6, CASE(IS NOT NULL($9), $9, 0)), 0)])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(w_warehouse_sk=[$0], w_state=[$10])
+            HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+          HiveJoin(condition=[=($11, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[AND(=($3, $6), =($2, $5))], joinType=[left], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_warehouse_sk=[$14], cs_item_sk=[$15], cs_order_number=[$17], cs_sales_price=[$21])
+                  HiveFilter(condition=[AND(IS NOT NULL($14), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_refunded_cash=[$23])
+                  HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+              HiveProject(d_date_sk=[$0], <=[<(CAST($2):DATE, 1998-04-08)], >==[>=(CAST($2):DATE, 1998-04-08)])
+                HiveFilter(condition=[BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-09 00:00:00, 1998-05-08 00:00:00)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(i_item_sk=[$0], i_item_id=[$1])
+              HiveFilter(condition=[BETWEEN(false, $5, 0.99, 1.49)])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+


[42/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out
new file mode 100644
index 0000000..e0480e4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query57.q.out
@@ -0,0 +1,171 @@
+PREHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_category=[$0], i_brand=[$1], d_year=[$2], d_moy=[$3], avg_monthly_sales=[$4], sum_sales=[$5], psum=[$6], nsum=[$7])
+  HiveSortLimit(sort0=[$8], sort1=[$2], dir0=[ASC], dir1=[ASC], fetch=[100])
+    HiveProject(i_category=[$10], i_brand=[$11], d_year=[$13], d_moy=[$14], avg_monthly_sales=[$16], sum_sales=[$15], psum=[$8], nsum=[$3], (- (tok_table_or_col sum_sales) (tok_table_or_col avg_monthly_sales))=[-($15, $16)])
+      HiveJoin(condition=[AND(AND(AND(=($10, $0), =($11, $1)), =($12, $2)), =($17, -($4, 1)))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col cc_name)=[$2], (tok_function sum (tok_table_or_col cs_sales_price))=[$3], rank_window_1=[$4])
+          HiveFilter(condition=[IS NOT NULL($4)])
+            HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col cc_name)=[$4], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+              HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], cc_name=[$4], $f5=[$5])
+                HiveAggregate(group=[{1, 2, 8, 9, 11}], agg#0=[sum($6)])
+                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($8))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_item_sk=[$15], cs_sales_price=[$21])
+                          HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0), IS NOT NULL($11))])
+                            HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                        HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                          HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                          HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+        HiveJoin(condition=[AND(AND(AND(=($5, $0), =($6, $1)), =($7, $2)), =($12, +($4, 1)))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col cc_name)=[$2], (tok_function sum (tok_table_or_col cs_sales_price))=[$3], rank_window_1=[$4])
+            HiveFilter(condition=[IS NOT NULL($4)])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col cc_name)=[$4], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], cc_name=[$4], $f5=[$5])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($8))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_item_sk=[$15], cs_sales_price=[$21])
+                            HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0), IS NOT NULL($11))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                            HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col cc_name)=[$2], (tok_table_or_col d_year)=[$3], (tok_table_or_col d_moy)=[$4], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], avg_window_0=[$6], rank_window_1=[$7])
+            HiveFilter(condition=[AND(=($3, 2000), >($6, 0), CASE(>($6, 0), >(/(ABS(-($5, $6)), $6), 0.1), null), IS NOT NULL($7))])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col cc_name)=[$4], (tok_table_or_col d_year)=[$2], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], avg_window_0=[avg($5) OVER (PARTITION BY $1, $0, $4, $2 ORDER BY $1 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $2 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], cc_name=[$4], $f5=[$5])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($8))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_item_sk=[$15], cs_sales_price=[$21])
+                            HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0), IS NOT NULL($11))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                            HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out
new file mode 100644
index 0000000..2504d78
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query58.q.out
@@ -0,0 +1,240 @@
+Warning: Shuffle Join MERGEJOIN[404][tables = [$hdt$_4, $hdt$_5]] in Stage 'Reducer 22' is a cross product
+PREHOOK: query: explain cbo
+with ss_items as
+ (select i_item_id item_id
+        ,sum(ss_ext_sales_price) ss_item_rev 
+ from store_sales
+     ,item
+     ,date_dim
+ where ss_item_sk = i_item_sk
+   and d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+   and ss_sold_date_sk   = d_date_sk
+ group by i_item_id),
+ cs_items as
+ (select i_item_id item_id
+        ,sum(cs_ext_sales_price) cs_item_rev
+  from catalog_sales
+      ,item
+      ,date_dim
+ where cs_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+  and  cs_sold_date_sk = d_date_sk
+ group by i_item_id),
+ ws_items as
+ (select i_item_id item_id
+        ,sum(ws_ext_sales_price) ws_item_rev
+  from web_sales
+      ,item
+      ,date_dim
+ where ws_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq =(select d_week_seq 
+                                     from date_dim
+                                     where d_date = '1998-02-19'))
+  and ws_sold_date_sk   = d_date_sk
+ group by i_item_id)
+  select  ss_items.item_id
+       ,ss_item_rev
+       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
+       ,cs_item_rev
+       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
+       ,ws_item_rev
+       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
+       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
+ from ss_items,cs_items,ws_items
+ where ss_items.item_id=cs_items.item_id
+   and ss_items.item_id=ws_items.item_id 
+   and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+ order by item_id
+         ,ss_item_rev
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ss_items as
+ (select i_item_id item_id
+        ,sum(ss_ext_sales_price) ss_item_rev 
+ from store_sales
+     ,item
+     ,date_dim
+ where ss_item_sk = i_item_sk
+   and d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+   and ss_sold_date_sk   = d_date_sk
+ group by i_item_id),
+ cs_items as
+ (select i_item_id item_id
+        ,sum(cs_ext_sales_price) cs_item_rev
+  from catalog_sales
+      ,item
+      ,date_dim
+ where cs_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+  and  cs_sold_date_sk = d_date_sk
+ group by i_item_id),
+ ws_items as
+ (select i_item_id item_id
+        ,sum(ws_ext_sales_price) ws_item_rev
+  from web_sales
+      ,item
+      ,date_dim
+ where ws_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq =(select d_week_seq 
+                                     from date_dim
+                                     where d_date = '1998-02-19'))
+  and ws_sold_date_sk   = d_date_sk
+ group by i_item_id)
+  select  ss_items.item_id
+       ,ss_item_rev
+       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
+       ,cs_item_rev
+       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
+       ,ws_item_rev
+       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
+       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
+ from ss_items,cs_items,ws_items
+ where ss_items.item_id=cs_items.item_id
+   and ss_items.item_id=ws_items.item_id 
+   and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+ order by item_id
+         ,ss_item_rev
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(item_id=[$0], ss_item_rev=[$3], ss_dev=[*(/(/($3, +(+($3, $1), $5)), CAST(3):DECIMAL(10, 0)), CAST(100):DECIMAL(10, 0))], cs_item_rev=[$1], cs_dev=[*(/(/($1, +(+($3, $1), $5)), CAST(3):DECIMAL(10, 0)), CAST(100):DECIMAL(10, 0))], ws_item_rev=[$5], ws_dev=[*(/(/($5, +(+($3, $1), $5)), CAST(3):DECIMAL(10, 0)), CAST(100):DECIMAL(10, 0))], average=[/(+(+($3, $1), $5), CAST(3):DECIMAL(10, 0))])
+    HiveJoin(condition=[AND(AND(AND(AND(=($0, $4), BETWEEN(false, $3, *(0.9, $5), *(1.1, $5))), BETWEEN(false, $1, *(0.9, $5), *(1.1, $5))), BETWEEN(false, $5, *(0.9, $3), *(1.1, $3))), BETWEEN(false, $5, *(0.9, $1), *(1.1, $1)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[AND(AND(=($2, $0), BETWEEN(false, $3, *(0.9, $1), *(1.1, $1))), BETWEEN(false, $1, *(0.9, $3), *(1.1, $3)))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_id=[$0], $f1=[$1])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                  HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cnt=[$0])
+                            HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                              HiveProject(cnt=[$0])
+                                HiveAggregate(group=[{}], cnt=[COUNT()])
+                                  HiveFilter(condition=[=($2, _UTF-16LE'1998-02-19')])
+                                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(d_week_seq=[$4])
+                            HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(i_item_id=[$0], $f1=[$1])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cnt=[$0])
+                            HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                              HiveProject(cnt=[$0])
+                                HiveAggregate(group=[{}], cnt=[COUNT()])
+                                  HiveFilter(condition=[=($2, _UTF-16LE'1998-02-19')])
+                                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(d_week_seq=[$4])
+                            HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(i_item_id=[$0], $f1=[$1])
+        HiveAggregate(group=[{4}], agg#0=[sum($2)])
+          HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_sales_price=[$23])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+            HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+              HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0], d_date=[$2])
+                  HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(d_date=[$0])
+                  HiveAggregate(group=[{0}])
+                    HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(d_date=[$2], d_week_seq=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cnt=[$0])
+                          HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                            HiveProject(cnt=[$0])
+                              HiveAggregate(group=[{}], cnt=[COUNT()])
+                                HiveFilter(condition=[=($2, _UTF-16LE'1998-02-19')])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(d_week_seq=[$4])
+                          HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out
new file mode 100644
index 0000000..bb92a1f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query59.q.out
@@ -0,0 +1,136 @@
+PREHOOK: query: explain cbo
+with wss as 
+ (select d_week_seq,
+        ss_store_sk,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from store_sales,date_dim
+ where d_date_sk = ss_sold_date_sk
+ group by d_week_seq,ss_store_sk
+ )
+  select  s_store_name1,s_store_id1,d_week_seq1
+       ,sun_sales1/sun_sales2,mon_sales1/mon_sales2
+       ,tue_sales1/tue_sales1,wed_sales1/wed_sales2,thu_sales1/thu_sales2
+       ,fri_sales1/fri_sales2,sat_sales1/sat_sales2
+ from
+ (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
+        ,s_store_id s_store_id1,sun_sales sun_sales1
+        ,mon_sales mon_sales1,tue_sales tue_sales1
+        ,wed_sales wed_sales1,thu_sales thu_sales1
+        ,fri_sales fri_sales1,sat_sales sat_sales1
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185 and 1185 + 11) y,
+ (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
+        ,s_store_id s_store_id2,sun_sales sun_sales2
+        ,mon_sales mon_sales2,tue_sales tue_sales2
+        ,wed_sales wed_sales2,thu_sales thu_sales2
+        ,fri_sales fri_sales2,sat_sales sat_sales2
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185+ 12 and 1185 + 23) x
+ where s_store_id1=s_store_id2
+   and d_week_seq1=d_week_seq2-52
+ order by s_store_name1,s_store_id1,d_week_seq1
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with wss as 
+ (select d_week_seq,
+        ss_store_sk,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from store_sales,date_dim
+ where d_date_sk = ss_sold_date_sk
+ group by d_week_seq,ss_store_sk
+ )
+  select  s_store_name1,s_store_id1,d_week_seq1
+       ,sun_sales1/sun_sales2,mon_sales1/mon_sales2
+       ,tue_sales1/tue_sales1,wed_sales1/wed_sales2,thu_sales1/thu_sales2
+       ,fri_sales1/fri_sales2,sat_sales1/sat_sales2
+ from
+ (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
+        ,s_store_id s_store_id1,sun_sales sun_sales1
+        ,mon_sales mon_sales1,tue_sales tue_sales1
+        ,wed_sales wed_sales1,thu_sales thu_sales1
+        ,fri_sales fri_sales1,sat_sales sat_sales1
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185 and 1185 + 11) y,
+ (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
+        ,s_store_id s_store_id2,sun_sales sun_sales2
+        ,mon_sales mon_sales2,tue_sales tue_sales2
+        ,wed_sales wed_sales2,thu_sales thu_sales2
+        ,fri_sales fri_sales2,sat_sales sat_sales2
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185+ 12 and 1185 + 23) x
+ where s_store_id1=s_store_id2
+   and d_week_seq1=d_week_seq2-52
+ order by s_store_name1,s_store_id1,d_week_seq1
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(s_store_name1=[$2], s_store_id1=[$1], d_week_seq1=[$3], _o__c3=[/($5, $16)], _o__c4=[/($6, $17)], _o__c5=[/($7, $7)], _o__c6=[/($8, $18)], _o__c7=[/($9, $19)], _o__c8=[/($10, $20)], _o__c9=[/($11, $21)])
+    HiveJoin(condition=[AND(=($1, $15), =($3, -($14, 52)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
+          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+            HiveTableScan(table=[[default, store]], table:alias=[store])
+        HiveJoin(condition=[=($10, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
+            HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
+              HiveProject($f0=[$4], $f1=[$1], $f2=[CASE(=($5, _UTF-16LE'Sunday'), $2, null)], $f3=[CASE(=($5, _UTF-16LE'Monday'), $2, null)], $f4=[CASE(=($5, _UTF-16LE'Tuesday'), $2, null)], $f5=[CASE(=($5, _UTF-16LE'Wednesday'), $2, null)], $f6=[CASE(=($5, _UTF-16LE'Thursday'), $2, null)], $f7=[CASE(=($5, _UTF-16LE'Friday'), $2, null)], $f8=[CASE(=($5, _UTF-16LE'Saturday'), $2, null)])
+                HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_week_seq=[$4], d_day_name=[$14])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(d_month_seq=[$3], d_week_seq=[$4])
+            HiveFilter(condition=[AND(BETWEEN(false, $3, 1185, 1196), IS NOT NULL($4))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[d])
+      HiveProject(d_week_seq2=[$2], s_store_id2=[$1], sun_sales2=[$4], mon_sales2=[$5], wed_sales2=[$6], thu_sales2=[$7], fri_sales2=[$8], sat_sales2=[$9])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(s_store_sk=[$0], s_store_id=[$1])
+            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveJoin(condition=[=($9, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
+              HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($5)], agg#3=[sum($6)], agg#4=[sum($7)], agg#5=[sum($8)])
+                HiveProject($f0=[$4], $f1=[$1], $f2=[CASE(=($5, _UTF-16LE'Sunday'), $2, null)], $f3=[CASE(=($5, _UTF-16LE'Monday'), $2, null)], $f4=[CASE(=($5, _UTF-16LE'Tuesday'), $2, null)], $f5=[CASE(=($5, _UTF-16LE'Wednesday'), $2, null)], $f6=[CASE(=($5, _UTF-16LE'Thursday'), $2, null)], $f7=[CASE(=($5, _UTF-16LE'Friday'), $2, null)], $f8=[CASE(=($5, _UTF-16LE'Saturday'), $2, null)])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_week_seq=[$4], d_day_name=[$14])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(d_month_seq=[$3], d_week_seq=[$4])
+              HiveFilter(condition=[AND(BETWEEN(false, $3, 1197, 1208), IS NOT NULL($4))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[d])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query6.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query6.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query6.q.out
new file mode 100644
index 0000000..02149e7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query6.q.out
@@ -0,0 +1,109 @@
+Warning: Map Join MAPJOIN[171][bigTable=?] in task 'Reducer 15' is a cross product
+PREHOOK: query: explain cbo
+select  a.ca_state state, count(*) cnt
+ from customer_address a
+     ,customer c
+     ,store_sales s
+     ,date_dim d
+     ,item i
+ where       a.ca_address_sk = c.c_current_addr_sk
+ 	and c.c_customer_sk = s.ss_customer_sk
+ 	and s.ss_sold_date_sk = d.d_date_sk
+ 	and s.ss_item_sk = i.i_item_sk
+ 	and d.d_month_seq = 
+ 	     (select distinct (d_month_seq)
+ 	      from date_dim
+               where d_year = 2000
+ 	        and d_moy = 2 )
+ 	and i.i_current_price > 1.2 * 
+             (select avg(j.i_current_price) 
+ 	     from item j 
+ 	     where j.i_category = i.i_category)
+ group by a.ca_state
+ having count(*) >= 10
+ order by cnt 
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  a.ca_state state, count(*) cnt
+ from customer_address a
+     ,customer c
+     ,store_sales s
+     ,date_dim d
+     ,item i
+ where       a.ca_address_sk = c.c_current_addr_sk
+ 	and c.c_customer_sk = s.ss_customer_sk
+ 	and s.ss_sold_date_sk = d.d_date_sk
+ 	and s.ss_item_sk = i.i_item_sk
+ 	and d.d_month_seq = 
+ 	     (select distinct (d_month_seq)
+ 	      from date_dim
+               where d_year = 2000
+ 	        and d_moy = 2 )
+ 	and i.i_current_price > 1.2 * 
+             (select avg(j.i_current_price) 
+ 	     from item j 
+ 	     where j.i_category = i.i_category)
+ group by a.ca_state
+ having count(*) >= 10
+ order by cnt 
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+  HiveProject(ca_state=[$0], $f1=[$1])
+    HiveFilter(condition=[>=($1, 10)])
+      HiveAggregate(group=[{9}], agg#0=[count()])
+        HiveJoin(condition=[=($1, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($6, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0), IS NOT NULL($2))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[s])
+              HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[d])
+                HiveProject(d_month_seq=[$0])
+                  HiveAggregate(group=[{3}])
+                    HiveFilter(condition=[AND(=($6, 2000), =($8, 2), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$1], ca_address_sk=[$2], ca_state=[$3])
+              HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                  HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, customer]], table:alias=[c])
+                HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[a])
+          HiveProject(i_item_sk=[$0], i_current_price=[$1], i_category=[$2], _o__c0=[$3], i_category0=[$4], cnt=[$5])
+            HiveJoin(condition=[AND(=($4, $2), >($1, *(1.2, CAST($3):DECIMAL(16, 6))))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_current_price=[$5], i_category=[$12])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12))])
+                  HiveTableScan(table=[[default, item]], table:alias=[i])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(_o__c0=[/($1, $2)], i_category=[$0])
+                  HiveAggregate(group=[{12}], agg#0=[sum($5)], agg#1=[count($5)])
+                    HiveFilter(condition=[IS NOT NULL($12)])
+                      HiveTableScan(table=[[default, item]], table:alias=[j])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject(d_month_seq=[$0])
+                          HiveAggregate(group=[{3}])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 2))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out
new file mode 100644
index 0000000..81dfec7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query60.q.out
@@ -0,0 +1,244 @@
+PREHOOK: query: explain cbo
+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_category in ('Children'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ 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 i_item_id
+      ,total_sales
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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_category in ('Children'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ 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 i_item_id
+      ,total_sales
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(i_item_id=[$0], $f1=[$1])
+        HiveUnion(all=[true])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Children'), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], ss_sold_date_sk=[$2], ss_item_sk=[$3], ss_addr_sk=[$4], ss_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-6):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(9):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 9), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Children'), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], cs_sold_date_sk=[$2], cs_bill_addr_sk=[$3], cs_item_sk=[$4], cs_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-6):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($15))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(9):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 9), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Children'), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], ws_sold_date_sk=[$2], ws_item_sk=[$3], ws_bill_addr_sk=[$4], ws_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-6):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(9):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 9), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out
new file mode 100644
index 0000000..c5356df
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query61.q.out
@@ -0,0 +1,164 @@
+Warning: Shuffle Join MERGEJOIN[266][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 5' is a cross product
+PREHOOK: query: explain cbo
+select  promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
+from
+  (select sum(ss_ext_sales_price) promotions
+   from  store_sales
+        ,store
+        ,promotion
+        ,date_dim
+        ,customer
+        ,customer_address 
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_promo_sk = p_promo_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk 
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) promotional_sales,
+  (select sum(ss_ext_sales_price) total
+   from  store_sales
+        ,store
+        ,date_dim
+        ,customer
+        ,customer_address
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) all_sales
+order by promotions, total
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
+from
+  (select sum(ss_ext_sales_price) promotions
+   from  store_sales
+        ,store
+        ,promotion
+        ,date_dim
+        ,customer
+        ,customer_address 
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_promo_sk = p_promo_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk 
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) promotional_sales,
+  (select sum(ss_ext_sales_price) total
+   from  store_sales
+        ,store
+        ,date_dim
+        ,customer
+        ,customer_address
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) all_sales
+order by promotions, total
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(promotions=[$0], total=[$1], _o__c2=[*(/(CAST($0):DECIMAL(15, 4), CAST($1):DECIMAL(15, 4)), CAST(100):DECIMAL(10, 0))])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject($f0=[$0])
+        HiveAggregate(group=[{}], agg#0=[sum($9)])
+          HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-7):DECIMAL(5, 2)])
+                HiveFilter(condition=[AND(=($11, -7), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_promo_sk=[$4], ss_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8], i_item_sk=[$9], i_category=[$10], s_store_sk=[$11], s_gmt_offset=[$12], p_promo_sk=[$13], p_channel_dmail=[$14], p_channel_email=[$15], p_channel_tv=[$16])
+              HiveJoin(condition=[=($4, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($3, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($8), IS NOT NULL($0), IS NOT NULL($3), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(11):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 11), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(i_item_sk=[$0], i_category=[CAST(_UTF-16LE'Electronics'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Electronics'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(s_store_sk=[$0], s_gmt_offset=[CAST(-7):DECIMAL(5, 2)])
+                    HiveFilter(condition=[AND(=($27, -7), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, store]], table:alias=[store])
+                HiveProject(p_promo_sk=[$0], p_channel_dmail=[$8], p_channel_email=[$9], p_channel_tv=[$11])
+                  HiveFilter(condition=[AND(OR(=($8, _UTF-16LE'Y'), =($9, _UTF-16LE'Y'), =($11, _UTF-16LE'Y')), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+      HiveProject($f0=[$0])
+        HiveAggregate(group=[{}], agg#0=[sum($8)])
+          HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-7):DECIMAL(5, 2)])
+                HiveFilter(condition=[AND(=($11, -7), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_store_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5], d_year=[$6], d_moy=[$7], i_item_sk=[$8], i_category=[$9], s_store_sk=[$10], s_gmt_offset=[$11])
+              HiveJoin(condition=[=($3, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ext_sales_price=[$15])
+                      HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0), IS NOT NULL($3), IS NOT NULL($2))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(11):INTEGER])
+                      HiveFilter(condition=[AND(=($6, 1999), =($8, 11), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(i_item_sk=[$0], i_category=[CAST(_UTF-16LE'Electronics'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                    HiveFilter(condition=[AND(=($12, _UTF-16LE'Electronics'), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(s_store_sk=[$0], s_gmt_offset=[CAST(-7):DECIMAL(5, 2)])
+                  HiveFilter(condition=[AND(=($27, -7), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out
new file mode 100644
index 0000000..a080989
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query63.q.out
@@ -0,0 +1,89 @@
+PREHOOK: query: explain cbo
+select  * 
+from (select i_manager_id
+             ,sum(ss_sales_price) sum_sales
+             ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
+      from item
+          ,store_sales
+          ,date_dim
+          ,store
+      where ss_item_sk = i_item_sk
+        and ss_sold_date_sk = d_date_sk
+        and ss_store_sk = s_store_sk
+        and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11)
+        and ((    i_category in ('Books','Children','Electronics')
+              and i_class in ('personal','portable','refernece','self-help')
+              and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		                  'exportiunivamalg #9','scholaramalgamalg #9'))
+           or(    i_category in ('Women','Music','Men')
+              and i_class in ('accessories','classical','fragrances','pants')
+              and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		                 'importoamalg #1')))
+group by i_manager_id, d_moy) tmp1
+where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+order by i_manager_id
+        ,avg_monthly_sales
+        ,sum_sales
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  * 
+from (select i_manager_id
+             ,sum(ss_sales_price) sum_sales
+             ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
+      from item
+          ,store_sales
+          ,date_dim
+          ,store
+      where ss_item_sk = i_item_sk
+        and ss_sold_date_sk = d_date_sk
+        and ss_store_sk = s_store_sk
+        and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11)
+        and ((    i_category in ('Books','Children','Electronics')
+              and i_class in ('personal','portable','refernece','self-help')
+              and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		                  'exportiunivamalg #9','scholaramalgamalg #9'))
+           or(    i_category in ('Women','Music','Men')
+              and i_class in ('accessories','classical','fragrances','pants')
+              and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		                 'importoamalg #1')))
+group by i_manager_id, d_moy) tmp1
+where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+order by i_manager_id
+        ,avg_monthly_sales
+        ,sum_sales
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$2], sort2=[$1], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject((tok_table_or_col i_manager_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$1], avg_window_0=[$2])
+    HiveFilter(condition=[CASE(>($2, 0), >(/(ABS(-($1, $2)), $2), 0.1), null)])
+      HiveProject((tok_table_or_col i_manager_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$2], avg_window_0=[avg($2) OVER (PARTITION BY $0 ORDER BY $0 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+        HiveProject(i_manager_id=[$0], d_moy=[$1], $f2=[$2])
+          HiveAggregate(group=[{9, 12}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(s_store_sk=[$0])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12], i_manager_id=[$20])
+                    HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'refernece', _UTF-16LE'self-help', _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9', _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'), IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics', _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), OR(AND(IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics'), IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'refernece', _UTF-16LE'self-help'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9')), AND(IN($12, _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), IN($10, 
 _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'))), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3], d_moy=[$8])
+                  HiveFilter(condition=[AND(IN($3, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[61/75] [abbrv] hive git commit: HIVE-20737: Local SparkContext is shared between user sessions and should be closed only when there is no active (Denys Kuzmenko reviewed by Antal Sinkovits, Sahil Takiar and Peter Vary)

Posted by se...@apache.org.
HIVE-20737: Local SparkContext is shared between user sessions and should be closed only when there is no active (Denys Kuzmenko reviewed by Antal Sinkovits, Sahil Takiar and Peter Vary)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/36015eab
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/36015eab
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/36015eab

Branch: refs/heads/master-tez092
Commit: 36015eab482b5fc5c55ac02f7fa3085d6d877b09
Parents: 1a1d6ca
Author: denys kuzmenko <dk...@cloudera.com>
Authored: Wed Oct 24 10:26:52 2018 +0200
Committer: Peter Vary <pv...@cloudera.com>
Committed: Wed Oct 24 10:26:52 2018 +0200

----------------------------------------------------------------------
 .../ql/exec/spark/LocalHiveSparkClient.java     |  38 ++---
 .../ql/exec/spark/session/SparkSessionImpl.java |  73 ++++-----
 .../ql/exec/spark/TestLocalHiveSparkClient.java | 149 +++++++++++++++++++
 3 files changed, 200 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/36015eab/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/LocalHiveSparkClient.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/LocalHiveSparkClient.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/LocalHiveSparkClient.java
index 72ff53e..6c6122a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/LocalHiveSparkClient.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/LocalHiveSparkClient.java
@@ -27,7 +27,6 @@ import java.util.Map;
 
 import org.apache.hadoop.hive.ql.exec.DagUtils;
 import org.apache.hive.spark.client.SparkClientUtilities;
-import org.apache.spark.util.CallSite;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.fs.FileSystem;
@@ -62,32 +61,34 @@ import com.google.common.base.Strings;
  * environment and execute spark work.
  */
 public class LocalHiveSparkClient implements HiveSparkClient {
+
   private static final long serialVersionUID = 1L;
 
-  private static final String MR_JAR_PROPERTY = "tmpjars";
-  protected static final transient Logger LOG = LoggerFactory
-      .getLogger(LocalHiveSparkClient.class);
+  private static final transient Logger LOG = LoggerFactory
+          .getLogger(LocalHiveSparkClient.class);
 
+  private static final String MR_JAR_PROPERTY = "tmpjars";
   private static final Splitter CSV_SPLITTER = Splitter.on(",").omitEmptyStrings();
 
   private static LocalHiveSparkClient client;
-
-  public static synchronized LocalHiveSparkClient getInstance(
-      SparkConf sparkConf, HiveConf hiveConf) throws FileNotFoundException, MalformedURLException {
-    if (client == null) {
-      client = new LocalHiveSparkClient(sparkConf, hiveConf);
-    }
-    return client;
-  }
+  private int activeSessions = 0;
 
   private final JavaSparkContext sc;
 
   private final List<String> localJars = new ArrayList<String>();
-
   private final List<String> localFiles = new ArrayList<String>();
 
   private final JobMetricsListener jobMetricsListener;
 
+  public static synchronized LocalHiveSparkClient getInstance(SparkConf sparkConf, HiveConf hiveConf)
+      throws FileNotFoundException, MalformedURLException {
+    if (client == null) {
+      client = new LocalHiveSparkClient(sparkConf, hiveConf);
+    }
+    ++client.activeSessions;
+    return client;
+  }
+
   private LocalHiveSparkClient(SparkConf sparkConf, HiveConf hiveConf)
       throws FileNotFoundException, MalformedURLException {
     String regJar = null;
@@ -239,10 +240,13 @@ public class LocalHiveSparkClient implements HiveSparkClient {
   @Override
   public void close() {
     synchronized (LocalHiveSparkClient.class) {
-      client = null;
-    }
-    if (sc != null) {
-      sc.stop();
+      if (--activeSessions == 0) {
+        client = null;
+        if (sc != null) {
+          LOG.debug("Shutting down the SparkContext");
+          sc.stop();
+        }
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/36015eab/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/session/SparkSessionImpl.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/session/SparkSessionImpl.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/session/SparkSessionImpl.java
index bb50129..1d251ed 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/session/SparkSessionImpl.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/spark/session/SparkSessionImpl.java
@@ -109,11 +109,6 @@ public class SparkSessionImpl implements SparkSession {
    */
   private final Set<String> activeJobs = Sets.newConcurrentHashSet();
 
-  /**
-   * True if at least a single query has been run by this session, false otherwise.
-   */
-  private volatile boolean queryCompleted;
-
   private ReadWriteLock closeLock = new ReentrantReadWriteLock();
 
   SparkSessionImpl(String sessionId) {
@@ -123,27 +118,26 @@ public class SparkSessionImpl implements SparkSession {
 
   @Override
   public void open(HiveConf conf) throws HiveException {
-    closeLock.readLock().lock();
+    closeLock.writeLock().lock();
+
     try {
-      LOG.info("Trying to open Hive on Spark session {}", sessionId);
-      this.conf = conf;
-      isOpen = true;
-      try {
-        hiveSparkClient = HiveSparkClientFactory.createHiveSparkClient(conf, sessionId,
-              SessionState.get().getSessionId());
-      } catch (Throwable e) {
-        // It's possible that user session is closed while creating Spark client.
-        HiveException he;
-        if (isOpen) {
-          he = getHiveException(e);
-        } else {
-          he = new HiveException(e, ErrorMsg.SPARK_CREATE_CLIENT_CLOSED_SESSION, sessionId);
+      if (!isOpen) {
+        LOG.info("Trying to open Hive on Spark session {}", sessionId);
+        this.conf = conf;
+
+        try {
+          hiveSparkClient = HiveSparkClientFactory.createHiveSparkClient(conf, sessionId,
+                  SessionState.get().getSessionId());
+          isOpen = true;
+        } catch (Throwable e) {
+          throw getHiveException(e);
         }
-        throw he;
+        LOG.info("Hive on Spark session {} successfully opened", sessionId);
+      } else {
+        LOG.info("Hive on Spark session {} is already opened", sessionId);
       }
-      LOG.info("Hive on Spark session {} successfully opened", sessionId);
     } finally {
-      closeLock.readLock().unlock();
+      closeLock.writeLock().unlock();
     }
   }
 
@@ -198,12 +192,7 @@ public class SparkSessionImpl implements SparkSession {
 
   @Override
   public boolean isOpen() {
-    closeLock.readLock().lock();
-    try {
-      return isOpen;
-    } finally {
-      closeLock.readLock().unlock();
-    }
+    return isOpen;
   }
 
   @Override
@@ -220,10 +209,10 @@ public class SparkSessionImpl implements SparkSession {
   public void close() {
     if (isOpen) {
       closeLock.writeLock().lock();
+
       try {
         if (isOpen) {
           LOG.info("Trying to close Hive on Spark session {}", sessionId);
-          isOpen = false;
           if (hiveSparkClient != null) {
             try {
               hiveSparkClient.close();
@@ -234,8 +223,9 @@ public class SparkSessionImpl implements SparkSession {
             }
           }
           hiveSparkClient = null;
-          queryCompleted = false;
           lastSparkJobCompletionTime = 0;
+
+          isOpen = false;
         }
       } finally {
         closeLock.writeLock().unlock();
@@ -348,10 +338,11 @@ public class SparkSessionImpl implements SparkSession {
    */
   @Override
   public boolean triggerTimeout(long sessionTimeout) {
-    if (hasTimedOut(queryCompleted, activeJobs, lastSparkJobCompletionTime, sessionTimeout)) {
+    if (hasTimedOut(activeJobs, lastSparkJobCompletionTime, sessionTimeout)) {
       closeLock.writeLock().lock();
+
       try {
-        if (hasTimedOut(queryCompleted, activeJobs, lastSparkJobCompletionTime, sessionTimeout)) {
+        if (hasTimedOut(activeJobs, lastSparkJobCompletionTime, sessionTimeout)) {
           LOG.warn("Closing Spark session " + getSessionId() + " because a Spark job has not " +
                   "been run in the past " + sessionTimeout / 1000 + " seconds");
           close();
@@ -366,28 +357,24 @@ public class SparkSessionImpl implements SparkSession {
 
   /**
    * Returns true if a session has timed out, false otherwise. The following conditions must be met
-   * in order to consider a session as timed out: (1) the session must have run at least one
-   * query, (2) there can be no actively running Spark jobs, and (3) the last completed Spark job
-   * must have been more than sessionTimeout seconds ago.
+   * in order to consider a session as timed out:
+   * (1) the session must have run at least one query (i.e. lastSparkJobCompletionTime > 0),
+   * (2) there can be no actively running Spark jobs, and
+   * (3) the last completed Spark job must have been more than sessionTimeout seconds ago.
    */
-  private static boolean hasTimedOut(boolean queryCompleted, Set<String> activeJobs,
+  private static boolean hasTimedOut(Set<String> activeJobs,
                                      long lastSparkJobCompletionTime, long sessionTimeout) {
-    return queryCompleted &&
-            activeJobs.isEmpty() &&
+    return activeJobs.isEmpty() &&
             lastSparkJobCompletionTime > 0 &&
             (System.currentTimeMillis() - lastSparkJobCompletionTime) > sessionTimeout;
   }
 
   /**
-   * When this session completes the execution of a query, set the {@link #queryCompleted} flag
-   * to true if it hasn't already been set, remove the query from the list of actively running jobs,
+   * When this session completes the execution of a query, remove the query from the list of actively running jobs,
    * and set the {@link #lastSparkJobCompletionTime} to the current timestamp.
    */
   @Override
   public void onQueryCompletion(String queryId) {
-    if (!queryCompleted) {
-      queryCompleted = true;
-    }
     activeJobs.remove(queryId);
     lastSparkJobCompletionTime = System.currentTimeMillis();
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/36015eab/ql/src/test/org/apache/hadoop/hive/ql/exec/spark/TestLocalHiveSparkClient.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/exec/spark/TestLocalHiveSparkClient.java b/ql/src/test/org/apache/hadoop/hive/ql/exec/spark/TestLocalHiveSparkClient.java
new file mode 100644
index 0000000..bbf3d9c
--- /dev/null
+++ b/ql/src/test/org/apache/hadoop/hive/ql/exec/spark/TestLocalHiveSparkClient.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec.spark;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.Driver;
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.exec.spark.session.SparkSession;
+import org.apache.hadoop.hive.ql.exec.spark.session.SparkSessionImpl;
+import org.apache.hadoop.hive.ql.exec.spark.session.SparkSessionManagerImpl;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.spark.SparkContext;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.nio.file.Paths;
+import java.util.List;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.junit.Assert.fail;
+
+/**
+ * With local spark context, all user sessions share the same spark context.
+ */
+public class TestLocalHiveSparkClient {
+
+  private final CyclicBarrier barrier = new CyclicBarrier(2);
+
+  @Test
+  public void testMultiSessionSparkContextReUse() throws MalformedURLException {
+    String confDir = "../data/conf/spark/local/hive-site.xml";
+    HiveConf.setHiveSiteLocation(new File(confDir).toURI().toURL());
+
+    ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
+
+    List<CompletableFuture<Void>> futures =
+        IntStream.range(0, barrier.getParties()).boxed()
+            .map(i -> CompletableFuture.supplyAsync(() -> execute(i), executor))
+            .collect(Collectors.toList());
+
+    futures.forEach(CompletableFuture::join);
+  }
+
+  private Void execute(Integer threadId) {
+    HiveConf conf = new HiveConf();
+
+    conf.setBoolVar(HiveConf.ConfVars.SPARK_OPTIMIZE_SHUFFLE_SERDE, false);
+    conf.set("spark.local.dir", Paths.get(System.getProperty("test.tmp.dir"),
+        "TestLocalHiveSparkClient-testMultiSessionSparkContextReuse-local-dir").toString());
+
+    SessionState.start(conf);
+    try{
+      runSparkTestSession(conf, threadId);
+    } catch (Exception ex){
+      fail(ex.getMessage());
+    }
+    return null;
+  }
+
+  private void runSparkTestSession(HiveConf conf, int threadId) throws Exception {
+    conf.setVar(HiveConf.ConfVars.SPARK_SESSION_TIMEOUT, "10s");
+    conf.setVar(HiveConf.ConfVars.SPARK_SESSION_TIMEOUT_PERIOD, "1s");
+
+    Driver driver = null;
+    try {
+      driver = new Driver(new QueryState.Builder()
+          .withGenerateNewQueryId(true)
+          .withHiveConf(conf).build(), null, null);
+
+      SparkSession sparkSession = SparkUtilities.getSparkSession(conf,
+          SparkSessionManagerImpl.getInstance());
+
+      Assert.assertEquals(0, driver.run("show tables").getResponseCode());
+      barrier.await();
+
+      SparkContext sparkContext = getSparkContext(sparkSession);
+      Assert.assertFalse(sparkContext.isStopped());
+
+      if(threadId == 1) {
+        barrier.await();
+        closeSparkSession(sparkSession);
+        Assert.assertTrue(sparkContext.isStopped());
+
+      } else {
+        closeSparkSession(sparkSession);
+        Assert.assertFalse(sparkContext.isStopped());
+        barrier.await();
+      }
+    } finally {
+      if (driver != null) {
+        driver.destroy();
+      }
+    }
+  }
+
+  private void closeSparkSession(SparkSession session) throws ReflectiveOperationException {
+    Assert.assertTrue(session.isOpen());
+    session.close();
+
+    Assert.assertFalse(session.isOpen());
+  }
+
+  private SparkContext getSparkContext(SparkSession sparkSession) throws ReflectiveOperationException {
+    HiveSparkClient sparkClient = getSparkClient(sparkSession);
+    Assert.assertNotNull(sparkClient);
+
+    return getSparkContext(sparkClient).sc();
+  }
+
+  private JavaSparkContext getSparkContext(HiveSparkClient sparkClient) throws ReflectiveOperationException {
+    Field sparkContextField = LocalHiveSparkClient.class.getDeclaredField("sc");
+    sparkContextField.setAccessible(true);
+
+    return (JavaSparkContext) sparkContextField.get(sparkClient);
+  }
+
+  private HiveSparkClient getSparkClient(SparkSession sparkSession) throws ReflectiveOperationException {
+    Field clientField = SparkSessionImpl.class.getDeclaredField("hiveSparkClient");
+    clientField.setAccessible(true);
+
+    return (HiveSparkClient) clientField.get(sparkSession);
+  }
+}


[32/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query51.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query51.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query51.q.out
new file mode 100644
index 0000000..3d81b6b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query51.q.out
@@ -0,0 +1,125 @@
+PREHOOK: query: explain cbo
+WITH web_v1 as (
+select
+  ws_item_sk item_sk, d_date,
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from web_sales
+    ,date_dim
+where ws_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ws_item_sk is not NULL
+group by ws_item_sk, d_date),
+store_v1 as (
+select
+  ss_item_sk item_sk, d_date,
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from store_sales
+    ,date_dim
+where ss_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ss_item_sk is not NULL
+group by ss_item_sk, d_date)
+ select  *
+from (select item_sk
+     ,d_date
+     ,web_sales
+     ,store_sales
+     ,max(web_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
+     ,max(store_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
+     from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
+                 ,case when web.d_date is not null then web.d_date else store.d_date end d_date
+                 ,web.cume_sales web_sales
+                 ,store.cume_sales store_sales
+           from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
+                                                          and web.d_date = store.d_date)
+          )x )y
+where web_cumulative > store_cumulative
+order by item_sk
+        ,d_date
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+WITH web_v1 as (
+select
+  ws_item_sk item_sk, d_date,
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from web_sales
+    ,date_dim
+where ws_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ws_item_sk is not NULL
+group by ws_item_sk, d_date),
+store_v1 as (
+select
+  ss_item_sk item_sk, d_date,
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from store_sales
+    ,date_dim
+where ss_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ss_item_sk is not NULL
+group by ss_item_sk, d_date)
+ select  *
+from (select item_sk
+     ,d_date
+     ,web_sales
+     ,store_sales
+     ,max(web_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
+     ,max(store_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
+     from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
+                 ,case when web.d_date is not null then web.d_date else store.d_date end d_date
+                 ,web.cume_sales web_sales
+                 ,store.cume_sales store_sales
+           from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
+                                                          and web.d_date = store.d_date)
+          )x )y
+where web_cumulative > store_cumulative
+order by item_sk
+        ,d_date
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(item_sk=[$0], d_date=[$1], web_sales=[$2], store_sales=[$3], max_window_0=[$4], max_window_1=[$5])
+    HiveFilter(condition=[>($4, $5)])
+      HiveProject(item_sk=[CASE(IS NOT NULL($3), $3, $0)], d_date=[CASE(IS NOT NULL($4), $4, $1)], web_sales=[$5], store_sales=[$2], max_window_0=[max($5) OVER (PARTITION BY CASE(IS NOT NULL($3), $3, $0) ORDER BY CASE(IS NOT NULL($4), $4, $1) NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)], max_window_1=[max($2) OVER (PARTITION BY CASE(IS NOT NULL($3), $3, $0) ORDER BY CASE(IS NOT NULL($4), $4, $1) NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)])
+        HiveJoin(condition=[AND(=($3, $0), =($4, $1))], joinType=[full], algorithm=[none], cost=[not available])
+          HiveProject((tok_table_or_col ss_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[$2])
+            HiveProject((tok_table_or_col ss_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[sum($2) OVER (PARTITION BY $0 ORDER BY $1 NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)], window_col_0=[$2])
+              HiveProject(ss_item_sk=[$0], d_date=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 4}], agg#0=[sum($2)])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_sales_price=[$13])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_date=[$2])
+                      HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject((tok_table_or_col ws_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[$2])
+            HiveProject((tok_table_or_col ws_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[sum($2) OVER (PARTITION BY $0 ORDER BY $1 NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)], window_col_0=[$2])
+              HiveProject(ws_item_sk=[$0], d_date=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 4}], agg#0=[sum($2)])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_sales_price=[$21])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_date=[$2])
+                      HiveFilter(condition=[BETWEEN(false, $3, 1212, 1223)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query52.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query52.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query52.q.out
new file mode 100644
index 0000000..ab2db4b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query52.q.out
@@ -0,0 +1,67 @@
+PREHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_brand_id brand_id
+ 	,item.i_brand brand
+ 	,sum(ss_ext_sales_price) ext_price
+ 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_manager_id = 1
+    and dt.d_moy=12
+    and dt.d_year=1998
+ group by dt.d_year
+ 	,item.i_brand
+ 	,item.i_brand_id
+ order by dt.d_year
+ 	,ext_price desc
+ 	,brand_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_brand_id brand_id
+ 	,item.i_brand brand
+ 	,sum(ss_ext_sales_price) ext_price
+ 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_manager_id = 1
+    and dt.d_moy=12
+    and dt.d_year=1998
+ group by dt.d_year
+ 	,item.i_brand
+ 	,item.i_brand_id
+ order by dt.d_year
+ 	,ext_price desc
+ 	,brand_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(d_year=[CAST(1998):INTEGER], brand_id=[$0], brand=[$1], ext_price=[$2])
+  HiveSortLimit(sort0=[$2], sort1=[$0], dir0=[DESC-nulls-last], dir1=[ASC], fetch=[100])
+    HiveProject(i_brand_id=[$0], i_brand=[$1], $f2=[$2])
+      HiveAggregate(group=[{5, 6}], agg#0=[sum($2)])
+        HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[AND(=($8, 12), =($6, 1998))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[dt])
+          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8])
+            HiveFilter(condition=[=($20, 1)])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query53.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query53.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query53.q.out
new file mode 100644
index 0000000..bac3f77
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query53.q.out
@@ -0,0 +1,83 @@
+PREHOOK: query: explain cbo
+select  * from 
+(select i_manufact_id,
+sum(ss_sales_price) sum_sales,
+avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+ss_sold_date_sk = d_date_sk and
+ss_store_sk = s_store_sk and
+d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
+((i_category in ('Books','Children','Electronics') and
+i_class in ('personal','portable','reference','self-help') and
+i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		'exportiunivamalg #9','scholaramalgamalg #9'))
+or(i_category in ('Women','Music','Men') and
+i_class in ('accessories','classical','fragrances','pants') and
+i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		'importoamalg #1')))
+group by i_manufact_id, d_qoy ) tmp1
+where case when avg_quarterly_sales > 0 
+	then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales 
+	else null end > 0.1
+order by avg_quarterly_sales,
+	 sum_sales,
+	 i_manufact_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  * from 
+(select i_manufact_id,
+sum(ss_sales_price) sum_sales,
+avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+ss_sold_date_sk = d_date_sk and
+ss_store_sk = s_store_sk and
+d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
+((i_category in ('Books','Children','Electronics') and
+i_class in ('personal','portable','reference','self-help') and
+i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		'exportiunivamalg #9','scholaramalgamalg #9'))
+or(i_category in ('Women','Music','Men') and
+i_class in ('accessories','classical','fragrances','pants') and
+i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		'importoamalg #1')))
+group by i_manufact_id, d_qoy ) tmp1
+where case when avg_quarterly_sales > 0 
+	then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales 
+	else null end > 0.1
+order by avg_quarterly_sales,
+	 sum_sales,
+	 i_manufact_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$2], sort1=[$1], sort2=[$0], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject((tok_table_or_col i_manufact_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$1], avg_window_0=[$2])
+    HiveFilter(condition=[CASE(>($2, 0), >(/(ABS(-($1, $2)), $2), 0.1), null)])
+      HiveProject((tok_table_or_col i_manufact_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$2], avg_window_0=[avg($2) OVER (PARTITION BY $0 ORDER BY $0 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+        HiveProject(i_manufact_id=[$0], d_qoy=[$1], $f2=[$2])
+          HiveAggregate(group=[{4, 6}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_sales_price=[$13])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
+                  HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'reference', _UTF-16LE'self-help', _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9', _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'), IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics', _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), OR(AND(IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics'), IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'reference', _UTF-16LE'self-help'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9')), AND(IN($12, _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), IN($10, _U
 TF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'))))])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_qoy=[$10])
+                HiveFilter(condition=[IN($3, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223)])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query54.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query54.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query54.q.out
new file mode 100644
index 0000000..1cf3ce4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query54.q.out
@@ -0,0 +1,212 @@
+Warning: Shuffle Join MERGEJOIN[270][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[271][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[269][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 32' is a cross product
+Warning: Shuffle Join MERGEJOIN[272][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 6' is a cross product
+PREHOOK: query: explain cbo
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(segment=[$0], num_customers=[$1], segment_base=[*($0, 50)])
+    HiveAggregate(group=[{0}], agg#0=[count()])
+      HiveProject(segment=[CAST(/($1, CAST(50):DECIMAL(10, 0))):INTEGER])
+        HiveAggregate(group=[{0}], agg#0=[sum($1)])
+          HiveFilter(condition=[BETWEEN(false, $2, $3, $4)])
+            HiveProject(c_customer_sk=[$0], ss_ext_sales_price=[$4], d_month_seq=[$11], _o__c0=[$13], $f0=[$14])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f0=[$10], $f1=[$11], ss_sold_date_sk=[$0], ss_customer_sk=[$1], ss_ext_sales_price=[$2], ca_address_sk=[$5], ca_county=[$6], ca_state=[$7], s_county=[$8], s_state=[$9], d_date_sk=[$3], d_month_seq=[$4], cnt=[$12], $f00=[$13])
+                  HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($10, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_ext_sales_price=[$15])
+                            HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(ca_address_sk=[$0], ca_county=[$1], ca_state=[$2], s_county=[$3], s_state=[$4], c_customer_sk=[$5], c_current_addr_sk=[$6])
+                          HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[AND(=($1, $3), =($2, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(ca_address_sk=[$0], ca_county=[$7], ca_state=[$8])
+                                HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($8))])
+                                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                              HiveProject(s_county=[$23], s_state=[$24])
+                                HiveFilter(condition=[AND(IS NOT NULL($23), IS NOT NULL($24))])
+                                  HiveTableScan(table=[[default, store]], table:alias=[store])
+                            HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$1])
+                              HiveAggregate(group=[{0, 1}])
+                                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                                    HiveFilter(condition=[IS NOT NULL($4)])
+                                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                  HiveJoin(condition=[=($2, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2])
+                                        HiveUnion(all=[true])
+                                          HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15])
+                                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                          HiveProject(sold_date_sk=[$0], customer_sk=[$4], item_sk=[$3])
+                                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0])
+                                        HiveFilter(condition=[AND(=($8, 3), =($6, 1999))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                    HiveProject(i_item_sk=[$0])
+                                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Jewelry'), =($10, _UTF-16LE'consignment'))])
+                                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveProject(cnt=[$0])
+                        HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                          HiveProject(cnt=[$0])
+                            HiveAggregate(group=[{}], cnt=[COUNT()])
+                              HiveProject($f0=[$0])
+                                HiveAggregate(group=[{0}])
+                                  HiveProject($f0=[+($3, 1)])
+                                    HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject($f0=[$0])
+                      HiveAggregate(group=[{0}])
+                        HiveProject($f0=[+($3, 1)])
+                          HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveJoin(condition=[true], joinType=[right], algorithm=[none], cost=[not available])
+                  HiveProject($f0=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveProject($f0=[+($3, 3)])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(cnt=[$0])
+                    HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                      HiveProject(cnt=[$0])
+                        HiveAggregate(group=[{}], cnt=[COUNT()])
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{0}])
+                              HiveProject($f0=[+($3, 3)])
+                                HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query55.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query55.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query55.q.out
new file mode 100644
index 0000000..6af451c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query55.q.out
@@ -0,0 +1,51 @@
+PREHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+ 	and ss_item_sk = i_item_sk
+ 	and i_manager_id=36
+ 	and d_moy=12
+ 	and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+ 	and ss_item_sk = i_item_sk
+ 	and i_manager_id=36
+ 	and d_moy=12
+ 	and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(brand_id=[$0], brand=[$1], ext_price=[$2])
+  HiveSortLimit(sort0=[$2], sort1=[$3], dir0=[DESC-nulls-last], dir1=[ASC], fetch=[100])
+    HiveProject(brand_id=[$0], brand=[$1], ext_price=[$2], (tok_table_or_col i_brand_id)=[$0])
+      HiveAggregate(group=[{5, 6}], agg#0=[sum($2)])
+        HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[AND(=($8, 12), =($6, 2001))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8])
+            HiveFilter(condition=[=($20, 36)])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query56.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query56.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query56.q.out
new file mode 100644
index 0000000..a13e599
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query56.q.out
@@ -0,0 +1,221 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(i_item_id=[$0], $f1=[$1])
+        HiveUnion(all=[true])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace')])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_addr_sk=[$3], ss_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -8)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 2000), =($8, 1))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace')])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], cs_sold_date_sk=[$1], cs_bill_addr_sk=[$2], cs_item_sk=[$3], cs_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -8)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 2000), =($8, 1))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($7)])
+              HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace')])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ws_sold_date_sk=[$1], ws_item_sk=[$2], ws_bill_addr_sk=[$3], ws_ext_sales_price=[$4], d_date_sk=[$5])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0])
+                      HiveFilter(condition=[=($11, -8)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0])
+                        HiveFilter(condition=[AND(=($6, 2000), =($8, 1))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query57.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query57.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query57.q.out
new file mode 100644
index 0000000..440a4e9
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query57.q.out
@@ -0,0 +1,171 @@
+PREHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_category=[$0], i_brand=[$1], d_year=[$2], d_moy=[$3], avg_monthly_sales=[$4], sum_sales=[$5], psum=[$6], nsum=[$7])
+  HiveSortLimit(sort0=[$8], sort1=[$2], dir0=[ASC], dir1=[ASC], fetch=[100])
+    HiveProject(i_category=[$10], i_brand=[$11], d_year=[$13], d_moy=[$14], avg_monthly_sales=[$16], sum_sales=[$15], psum=[$8], nsum=[$3], (- (tok_table_or_col sum_sales) (tok_table_or_col avg_monthly_sales))=[-($15, $16)])
+      HiveJoin(condition=[AND(AND(AND(=($10, $0), =($11, $1)), =($12, $2)), =($17, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col cc_name)=[$2], (tok_function sum (tok_table_or_col cs_sales_price))=[$3], -=[-($4, 1)])
+          HiveFilter(condition=[IS NOT NULL($4)])
+            HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col cc_name)=[$4], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+              HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], cc_name=[$4], $f5=[$5])
+                HiveAggregate(group=[{1, 2, 8, 9, 11}], agg#0=[sum($6)])
+                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                      HiveFilter(condition=[AND(IS NOT NULL($12), IS NOT NULL($8))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_item_sk=[$15], cs_sales_price=[$21])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($11))])
+                            HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                        HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                          HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+                        HiveFilter(condition=[IS NOT NULL($6)])
+                          HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+        HiveJoin(condition=[AND(AND(AND(=($5, $0), =($6, $1)), =($7, $2)), =($12, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col cc_name)=[$2], (tok_function sum (tok_table_or_col cs_sales_price))=[$3], +=[+($4, 1)])
+            HiveFilter(condition=[IS NOT NULL($4)])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col cc_name)=[$4], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], cc_name=[$4], $f5=[$5])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                        HiveFilter(condition=[AND(IS NOT NULL($12), IS NOT NULL($8))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_item_sk=[$15], cs_sales_price=[$21])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($11))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+                          HiveFilter(condition=[IS NOT NULL($6)])
+                            HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col cc_name)=[$2], (tok_table_or_col d_year)=[$3], (tok_table_or_col d_moy)=[$4], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], avg_window_0=[$6], rank_window_1=[$7])
+            HiveFilter(condition=[AND(=($3, 2000), >($6, 0), CASE(>($6, 0), >(/(ABS(-($5, $6)), $6), 0.1), null), IS NOT NULL($7))])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col cc_name)=[$4], (tok_table_or_col d_year)=[$2], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col cs_sales_price))=[$5], avg_window_0=[avg($5) OVER (PARTITION BY $1, $0, $4, $2 ORDER BY $1 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $2 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], cc_name=[$4], $f5=[$5])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                        HiveFilter(condition=[AND(IS NOT NULL($12), IS NOT NULL($8))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_call_center_sk=[$11], cs_item_sk=[$15], cs_sales_price=[$21])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($11))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(cc_call_center_sk=[$0], cc_name=[$6])
+                          HiveFilter(condition=[IS NOT NULL($6)])
+                            HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query58.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query58.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query58.q.out
new file mode 100644
index 0000000..df67f6f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query58.q.out
@@ -0,0 +1,237 @@
+Warning: Shuffle Join MERGEJOIN[401][tables = [$hdt$_4, $hdt$_5]] in Stage 'Reducer 22' is a cross product
+PREHOOK: query: explain cbo
+with ss_items as
+ (select i_item_id item_id
+        ,sum(ss_ext_sales_price) ss_item_rev 
+ from store_sales
+     ,item
+     ,date_dim
+ where ss_item_sk = i_item_sk
+   and d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+   and ss_sold_date_sk   = d_date_sk
+ group by i_item_id),
+ cs_items as
+ (select i_item_id item_id
+        ,sum(cs_ext_sales_price) cs_item_rev
+  from catalog_sales
+      ,item
+      ,date_dim
+ where cs_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+  and  cs_sold_date_sk = d_date_sk
+ group by i_item_id),
+ ws_items as
+ (select i_item_id item_id
+        ,sum(ws_ext_sales_price) ws_item_rev
+  from web_sales
+      ,item
+      ,date_dim
+ where ws_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq =(select d_week_seq 
+                                     from date_dim
+                                     where d_date = '1998-02-19'))
+  and ws_sold_date_sk   = d_date_sk
+ group by i_item_id)
+  select  ss_items.item_id
+       ,ss_item_rev
+       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
+       ,cs_item_rev
+       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
+       ,ws_item_rev
+       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
+       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
+ from ss_items,cs_items,ws_items
+ where ss_items.item_id=cs_items.item_id
+   and ss_items.item_id=ws_items.item_id 
+   and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+ order by item_id
+         ,ss_item_rev
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ss_items as
+ (select i_item_id item_id
+        ,sum(ss_ext_sales_price) ss_item_rev 
+ from store_sales
+     ,item
+     ,date_dim
+ where ss_item_sk = i_item_sk
+   and d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+   and ss_sold_date_sk   = d_date_sk
+ group by i_item_id),
+ cs_items as
+ (select i_item_id item_id
+        ,sum(cs_ext_sales_price) cs_item_rev
+  from catalog_sales
+      ,item
+      ,date_dim
+ where cs_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+  and  cs_sold_date_sk = d_date_sk
+ group by i_item_id),
+ ws_items as
+ (select i_item_id item_id
+        ,sum(ws_ext_sales_price) ws_item_rev
+  from web_sales
+      ,item
+      ,date_dim
+ where ws_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq =(select d_week_seq 
+                                     from date_dim
+                                     where d_date = '1998-02-19'))
+  and ws_sold_date_sk   = d_date_sk
+ group by i_item_id)
+  select  ss_items.item_id
+       ,ss_item_rev
+       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
+       ,cs_item_rev
+       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
+       ,ws_item_rev
+       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
+       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
+ from ss_items,cs_items,ws_items
+ where ss_items.item_id=cs_items.item_id
+   and ss_items.item_id=ws_items.item_id 
+   and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+ order by item_id
+         ,ss_item_rev
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(item_id=[$0], ss_item_rev=[$5], ss_dev=[*(/(/($5, +(+($5, $1), $9)), CAST(3):DECIMAL(10, 0)), CAST(100):DECIMAL(10, 0))], cs_item_rev=[$1], cs_dev=[*(/(/($1, +(+($5, $1), $9)), CAST(3):DECIMAL(10, 0)), CAST(100):DECIMAL(10, 0))], ws_item_rev=[$9], ws_dev=[*(/(/($9, +(+($5, $1), $9)), CAST(3):DECIMAL(10, 0)), CAST(100):DECIMAL(10, 0))], average=[/(+(+($5, $1), $9), CAST(3):DECIMAL(10, 0))])
+    HiveJoin(condition=[AND(AND(AND(AND(=($0, $8), BETWEEN(false, $5, $10, $11)), BETWEEN(false, $1, $10, $11)), BETWEEN(false, $9, $6, $7)), BETWEEN(false, $9, $2, $3))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[AND(AND(=($4, $0), BETWEEN(false, $5, $2, $3)), BETWEEN(false, $1, $6, $7))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(item_id=[$0], cs_item_rev=[$1], *=[*(0.9, $1)], *3=[*(1.1, $1)])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[IS NOT NULL($2)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cnt=[$0])
+                            HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                              HiveProject(cnt=[$0])
+                                HiveAggregate(group=[{}], cnt=[COUNT()])
+                                  HiveFilter(condition=[=($2, _UTF-16LE'1998-02-19')])
+                                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(d_week_seq=[$4])
+                            HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(item_id=[$0], ss_item_rev=[$1], *=[*(0.9, $1)], *3=[*(1.1, $1)])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[IS NOT NULL($2)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cnt=[$0])
+                            HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                              HiveProject(cnt=[$0])
+                                HiveAggregate(group=[{}], cnt=[COUNT()])
+                                  HiveFilter(condition=[=($2, _UTF-16LE'1998-02-19')])
+                                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject(d_week_seq=[$4])
+                            HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(item_id=[$0], ws_item_rev=[$1], *=[*(0.9, $1)], *3=[*(1.1, $1)])
+        HiveAggregate(group=[{4}], agg#0=[sum($2)])
+          HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_sales_price=[$23])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+            HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+              HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0], d_date=[$2])
+                  HiveFilter(condition=[IS NOT NULL($2)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(d_date=[$0])
+                  HiveAggregate(group=[{0}])
+                    HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(d_date=[$2], d_week_seq=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cnt=[$0])
+                          HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                            HiveProject(cnt=[$0])
+                              HiveAggregate(group=[{}], cnt=[COUNT()])
+                                HiveFilter(condition=[=($2, _UTF-16LE'1998-02-19')])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(d_week_seq=[$4])
+                          HiveFilter(condition=[AND(=($2, _UTF-16LE'1998-02-19'), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out
new file mode 100644
index 0000000..989bd78
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query59.q.out
@@ -0,0 +1,134 @@
+PREHOOK: query: explain cbo
+with wss as 
+ (select d_week_seq,
+        ss_store_sk,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from store_sales,date_dim
+ where d_date_sk = ss_sold_date_sk
+ group by d_week_seq,ss_store_sk
+ )
+  select  s_store_name1,s_store_id1,d_week_seq1
+       ,sun_sales1/sun_sales2,mon_sales1/mon_sales2
+       ,tue_sales1/tue_sales1,wed_sales1/wed_sales2,thu_sales1/thu_sales2
+       ,fri_sales1/fri_sales2,sat_sales1/sat_sales2
+ from
+ (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
+        ,s_store_id s_store_id1,sun_sales sun_sales1
+        ,mon_sales mon_sales1,tue_sales tue_sales1
+        ,wed_sales wed_sales1,thu_sales thu_sales1
+        ,fri_sales fri_sales1,sat_sales sat_sales1
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185 and 1185 + 11) y,
+ (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
+        ,s_store_id s_store_id2,sun_sales sun_sales2
+        ,mon_sales mon_sales2,tue_sales tue_sales2
+        ,wed_sales wed_sales2,thu_sales thu_sales2
+        ,fri_sales fri_sales2,sat_sales sat_sales2
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185+ 12 and 1185 + 23) x
+ where s_store_id1=s_store_id2
+   and d_week_seq1=d_week_seq2-52
+ order by s_store_name1,s_store_id1,d_week_seq1
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with wss as 
+ (select d_week_seq,
+        ss_store_sk,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from store_sales,date_dim
+ where d_date_sk = ss_sold_date_sk
+ group by d_week_seq,ss_store_sk
+ )
+  select  s_store_name1,s_store_id1,d_week_seq1
+       ,sun_sales1/sun_sales2,mon_sales1/mon_sales2
+       ,tue_sales1/tue_sales1,wed_sales1/wed_sales2,thu_sales1/thu_sales2
+       ,fri_sales1/fri_sales2,sat_sales1/sat_sales2
+ from
+ (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
+        ,s_store_id s_store_id1,sun_sales sun_sales1
+        ,mon_sales mon_sales1,tue_sales tue_sales1
+        ,wed_sales wed_sales1,thu_sales thu_sales1
+        ,fri_sales fri_sales1,sat_sales sat_sales1
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185 and 1185 + 11) y,
+ (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
+        ,s_store_id s_store_id2,sun_sales sun_sales2
+        ,mon_sales mon_sales2,tue_sales tue_sales2
+        ,wed_sales wed_sales2,thu_sales thu_sales2
+        ,fri_sales fri_sales2,sat_sales sat_sales2
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185+ 12 and 1185 + 23) x
+ where s_store_id1=s_store_id2
+   and d_week_seq1=d_week_seq2-52
+ order by s_store_name1,s_store_id1,d_week_seq1
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(s_store_name1=[$2], s_store_id1=[$1], d_week_seq1=[$3], _o__c3=[/($5, $14)], _o__c4=[/($6, $15)], _o__c5=[/($7, $7)], _o__c6=[/($8, $16)], _o__c7=[/($9, $17)], _o__c8=[/($10, $18)], _o__c9=[/($11, $19)])
+    HiveJoin(condition=[AND(=($1, $13), =($3, $20))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
+          HiveTableScan(table=[[default, store]], table:alias=[store])
+        HiveJoin(condition=[=($9, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
+            HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
+              HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null)], $f3=[CASE($6, $2, null)], $f4=[CASE($7, $2, null)], $f5=[CASE($8, $2, null)], $f6=[CASE($9, $2, null)], $f7=[CASE($10, $2, null)], $f8=[CASE($11, $2, null)])
+                HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_week_seq=[$4], ==[=($14, _UTF-16LE'Sunday')], =3=[=($14, _UTF-16LE'Monday')], =4=[=($14, _UTF-16LE'Tuesday')], =5=[=($14, _UTF-16LE'Wednesday')], =6=[=($14, _UTF-16LE'Thursday')], =7=[=($14, _UTF-16LE'Friday')], =8=[=($14, _UTF-16LE'Saturday')])
+                    HiveFilter(condition=[IS NOT NULL($4)])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(d_week_seq=[$4])
+            HiveFilter(condition=[AND(BETWEEN(false, $3, 1185, 1196), IS NOT NULL($4))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[d])
+      HiveProject(s_store_id2=[$1], sun_sales2=[$4], mon_sales2=[$5], wed_sales2=[$6], thu_sales2=[$7], fri_sales2=[$8], sat_sales2=[$9], -=[-($2, 52)])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(s_store_sk=[$0], s_store_id=[$1])
+            HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7])
+              HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($5)], agg#3=[sum($6)], agg#4=[sum($7)], agg#5=[sum($8)])
+                HiveProject($f0=[$4], $f1=[$1], $f2=[CASE($5, $2, null)], $f3=[CASE($6, $2, null)], $f4=[CASE($7, $2, null)], $f5=[CASE($8, $2, null)], $f6=[CASE($9, $2, null)], $f7=[CASE($10, $2, null)], $f8=[CASE($11, $2, null)])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_week_seq=[$4], ==[=($14, _UTF-16LE'Sunday')], =3=[=($14, _UTF-16LE'Monday')], =4=[=($14, _UTF-16LE'Tuesday')], =5=[=($14, _UTF-16LE'Wednesday')], =6=[=($14, _UTF-16LE'Thursday')], =7=[=($14, _UTF-16LE'Friday')], =8=[=($14, _UTF-16LE'Saturday')])
+                      HiveFilter(condition=[IS NOT NULL($4)])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(d_week_seq=[$4])
+              HiveFilter(condition=[AND(BETWEEN(false, $3, 1197, 1208), IS NOT NULL($4))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[d])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out
new file mode 100644
index 0000000..ef53060
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out
@@ -0,0 +1,108 @@
+Warning: Map Join MAPJOIN[172][bigTable=?] in task 'Reducer 15' is a cross product
+PREHOOK: query: explain cbo
+select  a.ca_state state, count(*) cnt
+ from customer_address a
+     ,customer c
+     ,store_sales s
+     ,date_dim d
+     ,item i
+ where       a.ca_address_sk = c.c_current_addr_sk
+ 	and c.c_customer_sk = s.ss_customer_sk
+ 	and s.ss_sold_date_sk = d.d_date_sk
+ 	and s.ss_item_sk = i.i_item_sk
+ 	and d.d_month_seq = 
+ 	     (select distinct (d_month_seq)
+ 	      from date_dim
+               where d_year = 2000
+ 	        and d_moy = 2 )
+ 	and i.i_current_price > 1.2 * 
+             (select avg(j.i_current_price) 
+ 	     from item j 
+ 	     where j.i_category = i.i_category)
+ group by a.ca_state
+ having count(*) >= 10
+ order by cnt 
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  a.ca_state state, count(*) cnt
+ from customer_address a
+     ,customer c
+     ,store_sales s
+     ,date_dim d
+     ,item i
+ where       a.ca_address_sk = c.c_current_addr_sk
+ 	and c.c_customer_sk = s.ss_customer_sk
+ 	and s.ss_sold_date_sk = d.d_date_sk
+ 	and s.ss_item_sk = i.i_item_sk
+ 	and d.d_month_seq = 
+ 	     (select distinct (d_month_seq)
+ 	      from date_dim
+               where d_year = 2000
+ 	        and d_moy = 2 )
+ 	and i.i_current_price > 1.2 * 
+             (select avg(j.i_current_price) 
+ 	     from item j 
+ 	     where j.i_category = i.i_category)
+ group by a.ca_state
+ having count(*) >= 10
+ order by cnt 
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+  HiveProject(ca_state=[$0], $f1=[$1])
+    HiveFilter(condition=[>=($1, 10)])
+      HiveAggregate(group=[{9}], agg#0=[count()])
+        HiveJoin(condition=[=($1, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($6, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3])
+                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[s])
+              HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                  HiveFilter(condition=[IS NOT NULL($3)])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[d])
+                HiveProject(d_month_seq=[$0])
+                  HiveAggregate(group=[{3}])
+                    HiveFilter(condition=[AND(=($6, 2000), =($8, 2), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$1], ca_address_sk=[$2], ca_state=[$3])
+              HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                  HiveFilter(condition=[IS NOT NULL($4)])
+                    HiveTableScan(table=[[default, customer]], table:alias=[c])
+                HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[a])
+          HiveProject(i_item_sk=[$0], i_current_price=[$1], i_category=[$2], i_category0=[$3], *=[$4], cnt=[$5])
+            HiveJoin(condition=[AND(=($3, $2), >($1, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_current_price=[$5], i_category=[$12])
+                HiveFilter(condition=[IS NOT NULL($12)])
+                  HiveTableScan(table=[[default, item]], table:alias=[i])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(i_category=[$0], *=[*(1.2, CAST(/($1, $2)):DECIMAL(16, 6))])
+                  HiveAggregate(group=[{12}], agg#0=[sum($5)], agg#1=[count($5)])
+                    HiveFilter(condition=[IS NOT NULL($12)])
+                      HiveTableScan(table=[[default, item]], table:alias=[j])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject(d_month_seq=[$0])
+                          HiveAggregate(group=[{3}])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 2))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[63/75] [abbrv] hive git commit: HIVE-20788: Extended SJ reduction may backtrack columns incorrectly when creating filters (Jesus Camacho Rodriguez, reviewed by Deepak Jaiswal)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query24.q.out b/ql/src/test/results/clientpositive/perf/tez/query24.q.out
index 902358a..43ece85 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query24.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query24.q.out
@@ -1,4 +1,4 @@
-Warning: Shuffle Join MERGEJOIN[290][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[301][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
 PREHOOK: query: explain
 with ssales as
 (select c_last_name
@@ -23,7 +23,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -79,7 +80,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -114,234 +116,242 @@ POSTHOOK: Output: hdfs://### HDFS PATH ###
 Plan optimized by CBO.
 
 Vertex dependency in root stage
-Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
-Map 24 <- Reducer 20 (BROADCAST_EDGE)
-Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
-Reducer 11 <- Map 9 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
-Reducer 12 <- Map 22 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
-Reducer 13 <- Map 23 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
-Reducer 14 <- Reducer 13 (SIMPLE_EDGE)
-Reducer 15 <- Reducer 14 (CUSTOM_SIMPLE_EDGE)
-Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
-Reducer 18 <- Map 16 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
-Reducer 19 <- Map 21 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
-Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
-Reducer 20 <- Map 16 (CUSTOM_SIMPLE_EDGE)
-Reducer 3 <- Map 16 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
-Reducer 4 <- Map 21 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
-Reducer 5 <- Map 22 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
-Reducer 6 <- Map 23 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
-Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
-Reducer 8 <- Reducer 15 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Map 1 <- Reducer 16 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE)
+Map 24 <- Reducer 19 (BROADCAST_EDGE), Reducer 20 (BROADCAST_EDGE)
+Reducer 10 <- Map 23 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 15 <- Map 22 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 24 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 19 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 15 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 23 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 12 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Map 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 7 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
     limit:-1
     Stage-1
-      Reducer 8
-      File Output Operator [FS_91]
-        Select Operator [SEL_90] (rows=78393744 width=380)
+      Reducer 6
+      File Output Operator [FS_94]
+        Select Operator [SEL_93] (rows=1313165 width=380)
           Output:["_col0","_col1","_col2","_col3"]
-          Filter Operator [FIL_89] (rows=78393744 width=492)
+          Filter Operator [FIL_92] (rows=1313165 width=492)
             predicate:(_col3 > _col4)
-            Merge Join Operator [MERGEJOIN_290] (rows=235181232 width=492)
+            Merge Join Operator [MERGEJOIN_301] (rows=3939496 width=492)
               Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4"]
-            <-Reducer 15 [CUSTOM_SIMPLE_EDGE] vectorized
-              PARTITION_ONLY_SHUFFLE [RS_345]
-                Select Operator [SEL_344] (rows=1 width=112)
+            <-Reducer 12 [CUSTOM_SIMPLE_EDGE] vectorized
+              PARTITION_ONLY_SHUFFLE [RS_351]
+                Select Operator [SEL_350] (rows=1 width=112)
                   Output:["_col0"]
-                  Group By Operator [GBY_343] (rows=1 width=120)
+                  Group By Operator [GBY_349] (rows=1 width=120)
                     Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"]
-                  <-Reducer 14 [CUSTOM_SIMPLE_EDGE] vectorized
-                    PARTITION_ONLY_SHUFFLE [RS_342]
-                      Group By Operator [GBY_341] (rows=1 width=120)
+                  <-Reducer 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                    PARTITION_ONLY_SHUFFLE [RS_348]
+                      Group By Operator [GBY_347] (rows=1 width=120)
                         Output:["_col0","_col1"],aggregations:["sum(_col10)","count(_col10)"]
-                        Select Operator [SEL_340] (rows=2121289008973 width=932)
+                        Select Operator [SEL_346] (rows=576061174 width=932)
                           Output:["_col10"]
-                          Group By Operator [GBY_339] (rows=2121289008973 width=932)
+                          Group By Operator [GBY_345] (rows=576061174 width=932)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8, KEY._col9
-                          <-Reducer 13 [SIMPLE_EDGE]
-                            SHUFFLE [RS_78]
+                          <-Reducer 10 [SIMPLE_EDGE]
+                            SHUFFLE [RS_81]
                               PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9
-                              Group By Operator [GBY_77] (rows=2121289008973 width=932)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col4)"],keys:_col11, _col12, _col6, _col8, _col15, _col16, _col17, _col18, _col19, _col22
-                                Merge Join Operator [MERGEJOIN_289] (rows=2121289008973 width=932)
-                                  Conds:RS_73._col9, _col13=RS_328._col1, upper(_col2)(Inner),Output:["_col4","_col6","_col8","_col11","_col12","_col15","_col16","_col17","_col18","_col19","_col22"]
+                              Group By Operator [GBY_80] (rows=576061174 width=932)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col18)"],keys:_col11, _col12, _col1, _col5, _col7, _col20, _col21, _col22, _col23, _col24
+                                Merge Join Operator [MERGEJOIN_300] (rows=589731269 width=928)
+                                  Conds:RS_76._col14, _col17=RS_332._col0, _col1(Inner),Output:["_col1","_col5","_col7","_col11","_col12","_col18","_col20","_col21","_col22","_col23","_col24"]
                                 <-Map 23 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_328]
-                                    PartitionCols:_col1, upper(_col2)
-                                    Select Operator [SEL_326] (rows=40000000 width=272)
-                                      Output:["_col0","_col1","_col2"]
-                                      Filter Operator [FIL_325] (rows=40000000 width=272)
-                                        predicate:(ca_zip is not null and upper(ca_country) is not null)
-                                        TableScan [TS_15] (rows=40000000 width=272)
-                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_state","ca_zip","ca_country"]
-                                <-Reducer 12 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_73]
-                                    PartitionCols:_col9, _col13
-                                    Merge Join Operator [MERGEJOIN_288] (rows=537799796 width=1023)
-                                      Conds:RS_70._col0, _col3=RS_324._col0, _col1(Inner),Output:["_col4","_col6","_col8","_col9","_col11","_col12","_col13","_col15","_col16","_col17","_col18","_col19"]
-                                    <-Map 22 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_324]
-                                        PartitionCols:_col0, _col1
-                                        Select Operator [SEL_322] (rows=57591150 width=8)
-                                          Output:["_col0","_col1"]
-                                          Filter Operator [FIL_321] (rows=57591150 width=8)
-                                            predicate:(sr_item_sk is not null and sr_ticket_number is not null)
-                                            TableScan [TS_12] (rows=57591150 width=8)
-                                              default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number"]
-                                    <-Reducer 11 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_70]
-                                        PartitionCols:_col0, _col3
-                                        Merge Join Operator [MERGEJOIN_287] (rows=385681992 width=1029)
-                                          Conds:RS_67._col0=RS_297._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col8","_col9","_col11","_col12","_col13","_col15","_col16","_col17","_col18","_col19"]
-                                        <-Map 9 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_297]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_294] (rows=462000 width=384)
-                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                              Filter Operator [FIL_292] (rows=462000 width=384)
-                                                predicate:i_item_sk is not null
-                                                TableScan [TS_3] (rows=462000 width=384)
-                                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_size","i_color","i_units","i_manager_id"]
-                                        <-Reducer 19 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_67]
-                                            PartitionCols:_col0
-                                            Merge Join Operator [MERGEJOIN_286] (rows=385681992 width=648)
-                                              Conds:RS_64._col1=RS_320._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col8","_col9","_col11","_col12","_col13"]
-                                            <-Map 21 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_320]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_318] (rows=80000000 width=276)
-                                                  Output:["_col0","_col1","_col2","_col3"]
-                                                  Filter Operator [FIL_317] (rows=80000000 width=276)
-                                                    predicate:(c_birth_country is not null and c_customer_sk is not null)
-                                                    TableScan [TS_9] (rows=80000000 width=276)
-                                                      default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_first_name","c_last_name","c_birth_country"]
-                                            <-Reducer 18 [SIMPLE_EDGE]
-                                              SHUFFLE [RS_64]
-                                                PartitionCols:_col1
-                                                Merge Join Operator [MERGEJOIN_285] (rows=385681992 width=379)
-                                                  Conds:RS_338._col2=RS_306._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col6","_col8","_col9"]
-                                                <-Map 16 [SIMPLE_EDGE] vectorized
-                                                  SHUFFLE [RS_306]
-                                                    PartitionCols:_col0
-                                                    Select Operator [SEL_303] (rows=155 width=271)
-                                                      Output:["_col0","_col1","_col3","_col4"]
-                                                      Filter Operator [FIL_302] (rows=155 width=271)
-                                                        predicate:((s_market_id = 7) and s_store_sk is not null and s_zip is not null)
-                                                        TableScan [TS_6] (rows=1704 width=270)
-                                                          default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_market_id","s_state","s_zip"]
-                                                <-Map 24 [SIMPLE_EDGE] vectorized
-                                                  SHUFFLE [RS_338]
-                                                    PartitionCols:_col2
-                                                    Select Operator [SEL_337] (rows=525333486 width=122)
-                                                      Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                      Filter Operator [FIL_336] (rows=525333486 width=122)
-                                                        predicate:((ss_store_sk BETWEEN DynamicValue(RS_62_store_s_store_sk_min) AND DynamicValue(RS_62_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_62_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_item_sk is not null and ss_store_sk is not null and ss_ticket_number is not null)
-                                                        TableScan [TS_43] (rows=575995635 width=122)
-                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
-                                                        <-Reducer 20 [BROADCAST_EDGE] vectorized
-                                                          BROADCAST [RS_335]
-                                                            Group By Operator [GBY_334] (rows=1 width=12)
-                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                            <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                              SHUFFLE [RS_311]
-                                                                Group By Operator [GBY_309] (rows=1 width=12)
-                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                  Select Operator [SEL_307] (rows=155 width=4)
-                                                                    Output:["_col0"]
-                                                                     Please refer to the previous Select Operator [SEL_303]
-            <-Reducer 7 [CUSTOM_SIMPLE_EDGE] vectorized
-              PARTITION_ONLY_SHUFFLE [RS_333]
-                Select Operator [SEL_332] (rows=235181232 width=380)
+                                  SHUFFLE [RS_332]
+                                    PartitionCols:_col0, _col1
+                                    Select Operator [SEL_330] (rows=57591150 width=8)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_329] (rows=57591150 width=8)
+                                        predicate:(sr_item_sk is not null and sr_ticket_number is not null)
+                                        TableScan [TS_23] (rows=57591150 width=8)
+                                          default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number"]
+                                <-Reducer 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_76]
+                                    PartitionCols:_col14, _col17
+                                    Merge Join Operator [MERGEJOIN_299] (rows=576061174 width=936)
+                                      Conds:RS_73._col14=RS_308._col0(Inner),Output:["_col1","_col5","_col7","_col11","_col12","_col14","_col17","_col18","_col20","_col21","_col22","_col23","_col24"]
+                                    <-Map 7 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_308]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_305] (rows=462000 width=384)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                          Filter Operator [FIL_303] (rows=462000 width=384)
+                                            predicate:i_item_sk is not null
+                                            TableScan [TS_3] (rows=462000 width=384)
+                                              default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_size","i_color","i_units","i_manager_id"]
+                                    <-Reducer 18 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_73]
+                                        PartitionCols:_col14
+                                        Merge Join Operator [MERGEJOIN_298] (rows=576061174 width=555)
+                                          Conds:RS_70._col9, _col4=RS_344._col1, _col2(Inner),Output:["_col1","_col5","_col7","_col11","_col12","_col14","_col17","_col18"]
+                                        <-Reducer 15 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_70]
+                                            PartitionCols:_col9, _col4
+                                            Filter Operator [FIL_21] (rows=7276996 width=637)
+                                              predicate:(_col13 <> upper(_col3))
+                                              Merge Join Operator [MERGEJOIN_293] (rows=7276996 width=637)
+                                                Conds:RS_18._col0=RS_321._col1(Inner),Output:["_col1","_col3","_col4","_col5","_col7","_col9","_col11","_col12","_col13"]
+                                              <-Map 22 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_321]
+                                                  PartitionCols:_col1
+                                                  Select Operator [SEL_320] (rows=80000000 width=280)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                    Filter Operator [FIL_319] (rows=80000000 width=280)
+                                                      predicate:(c_current_addr_sk is not null and c_customer_sk is not null)
+                                                      TableScan [TS_12] (rows=80000000 width=280)
+                                                        default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk","c_first_name","c_last_name","c_birth_country"]
+                                              <-Reducer 14 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_18]
+                                                  PartitionCols:_col0
+                                                  Merge Join Operator [MERGEJOIN_292] (rows=611379 width=365)
+                                                    Conds:RS_315._col2=RS_318._col4(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col7"]
+                                                  <-Map 13 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_315]
+                                                      PartitionCols:_col2
+                                                      Select Operator [SEL_314] (rows=40000000 width=276)
+                                                        Output:["_col0","_col1","_col2","_col3"]
+                                                        Filter Operator [FIL_313] (rows=40000000 width=276)
+                                                          predicate:(ca_address_sk is not null and ca_zip is not null)
+                                                          TableScan [TS_6] (rows=40000000 width=276)
+                                                            default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state","ca_zip","ca_country"]
+                                                  <-Map 21 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_318]
+                                                      PartitionCols:_col4
+                                                      Select Operator [SEL_317] (rows=155 width=271)
+                                                        Output:["_col0","_col1","_col3","_col4"]
+                                                        Filter Operator [FIL_316] (rows=155 width=271)
+                                                          predicate:((s_market_id = 7) and s_store_sk is not null and s_zip is not null)
+                                                          TableScan [TS_9] (rows=1704 width=270)
+                                                            default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_market_id","s_state","s_zip"]
+                                        <-Map 24 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_344]
+                                            PartitionCols:_col1, _col2
+                                            Select Operator [SEL_343] (rows=525333486 width=122)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                              Filter Operator [FIL_342] (rows=525333486 width=122)
+                                                predicate:((ss_customer_sk BETWEEN DynamicValue(RS_70_customer_c_customer_sk_min) AND DynamicValue(RS_70_customer_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_70_customer_c_customer_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_70_store_s_store_sk_min) AND DynamicValue(RS_70_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_70_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_item_sk is not null and ss_store_sk is not null and ss_ticket_number is not null)
+                                                TableScan [TS_54] (rows=575995635 width=122)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
+                                                <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_339]
+                                                    Group By Operator [GBY_338] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=6636187)"]
+                                                    <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_250]
+                                                        Group By Operator [GBY_249] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=6636187)"]
+                                                          Select Operator [SEL_248] (rows=7276996 width=8)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Filter Operator [FIL_21]
+                                                <-Reducer 20 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_341]
+                                                    Group By Operator [GBY_340] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_255]
+                                                        Group By Operator [GBY_254] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_253] (rows=7276996 width=8)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Filter Operator [FIL_21]
+            <-Reducer 5 [CUSTOM_SIMPLE_EDGE] vectorized
+              PARTITION_ONLY_SHUFFLE [RS_337]
+                Select Operator [SEL_336] (rows=3939496 width=380)
                   Output:["_col0","_col1","_col2","_col3"]
-                  Group By Operator [GBY_331] (rows=235181232 width=380)
-                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col9)"],keys:_col1, _col2, _col7
-                    Select Operator [SEL_330] (rows=365777643230 width=843)
-                      Output:["_col1","_col2","_col7","_col9"]
-                      Group By Operator [GBY_329] (rows=365777643230 width=843)
+                  Group By Operator [GBY_335] (rows=3939496 width=380)
+                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col9)"],keys:_col4, _col5, _col7
+                    Select Operator [SEL_334] (rows=84010488 width=843)
+                      Output:["_col4","_col5","_col7","_col9"]
+                      Group By Operator [GBY_333] (rows=84010488 width=843)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8
-                      <-Reducer 6 [SIMPLE_EDGE]
-                        SHUFFLE [RS_35]
+                      <-Reducer 4 [SIMPLE_EDGE]
+                        SHUFFLE [RS_37]
                           PartitionCols:_col0, _col1, _col2
-                          Group By Operator [GBY_34] (rows=365777643230 width=843)
-                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(_col4)"],keys:_col17, _col18, _col12, _col22, _col6, _col7, _col9, _col10, _col14
-                            Merge Join Operator [MERGEJOIN_284] (rows=365777643230 width=843)
-                              Conds:RS_30._col15, _col19=RS_327._col1, upper(_col2)(Inner),Output:["_col4","_col6","_col7","_col9","_col10","_col12","_col14","_col17","_col18","_col22"]
+                          Group By Operator [GBY_36] (rows=84010488 width=843)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(_col4)"],keys:_col13, _col14, _col21, _col6, _col7, _col9, _col10, _col17, _col23
+                            Merge Join Operator [MERGEJOIN_295] (rows=138508741 width=824)
+                              Conds:RS_32._col0, _col3=RS_331._col0, _col1(Inner),Output:["_col4","_col6","_col7","_col9","_col10","_col13","_col14","_col17","_col21","_col23"]
                             <-Map 23 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_327]
-                                PartitionCols:_col1, upper(_col2)
-                                 Please refer to the previous Select Operator [SEL_326]
-                            <-Reducer 5 [SIMPLE_EDGE]
-                              SHUFFLE [RS_30]
-                                PartitionCols:_col15, _col19
-                                Merge Join Operator [MERGEJOIN_283] (rows=92733777 width=910)
-                                  Conds:RS_27._col0, _col3=RS_323._col0, _col1(Inner),Output:["_col4","_col6","_col7","_col9","_col10","_col12","_col14","_col15","_col17","_col18","_col19"]
-                                <-Map 22 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_323]
-                                    PartitionCols:_col0, _col1
-                                     Please refer to the previous Select Operator [SEL_322]
-                                <-Reducer 4 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_27]
-                                    PartitionCols:_col0, _col3
-                                    Merge Join Operator [MERGEJOIN_282] (rows=56246341 width=899)
-                                      Conds:RS_24._col1=RS_319._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col9","_col10","_col12","_col14","_col15","_col17","_col18","_col19"]
-                                    <-Map 21 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_319]
+                              SHUFFLE [RS_331]
+                                PartitionCols:_col0, _col1
+                                 Please refer to the previous Select Operator [SEL_330]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_32]
+                                PartitionCols:_col0, _col3
+                                Merge Join Operator [MERGEJOIN_294] (rows=84010488 width=820)
+                                  Conds:RS_29._col1, _col2=RS_30._col0, _col9(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col9","_col10","_col13","_col14","_col17","_col21","_col23"]
+                                <-Reducer 15 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_30]
+                                    PartitionCols:_col0, _col9
+                                    Select Operator [SEL_22] (rows=7276996 width=637)
+                                      Output:["_col0","_col2","_col3","_col6","_col9","_col10","_col12"]
+                                       Please refer to the previous Filter Operator [FIL_21]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_29]
+                                    PartitionCols:_col1, _col2
+                                    Merge Join Operator [MERGEJOIN_291] (rows=76612563 width=382)
+                                      Conds:RS_328._col0=RS_306._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col6","_col7","_col9","_col10"]
+                                    <-Map 7 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_306]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_304] (rows=7000 width=385)
+                                          Output:["_col0","_col1","_col2","_col4","_col5"]
+                                          Filter Operator [FIL_302] (rows=7000 width=384)
+                                            predicate:((i_color = 'orchid') and i_item_sk is not null)
+                                             Please refer to the previous TableScan [TS_3]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_328]
                                         PartitionCols:_col0
-                                         Please refer to the previous Select Operator [SEL_318]
-                                    <-Reducer 3 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_24]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_281] (rows=56246341 width=630)
-                                          Conds:RS_21._col2=RS_304._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col6","_col7","_col9","_col10","_col12","_col14","_col15"]
-                                        <-Map 16 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_304]
-                                            PartitionCols:_col0
-                                             Please refer to the previous Select Operator [SEL_303]
-                                        <-Reducer 2 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_21]
-                                            PartitionCols:_col2
-                                            Merge Join Operator [MERGEJOIN_280] (rows=76612563 width=382)
-                                              Conds:RS_316._col0=RS_295._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col6","_col7","_col9","_col10"]
-                                            <-Map 9 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_295]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_293] (rows=7000 width=385)
-                                                  Output:["_col0","_col1","_col2","_col4","_col5"]
-                                                  Filter Operator [FIL_291] (rows=7000 width=384)
-                                                    predicate:((i_color = 'orchid') and i_item_sk is not null)
-                                                     Please refer to the previous TableScan [TS_3]
-                                            <-Map 1 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_316]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_315] (rows=525333486 width=122)
-                                                  Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                  Filter Operator [FIL_314] (rows=525333486 width=122)
-                                                    predicate:((ss_item_sk BETWEEN DynamicValue(RS_19_item_i_item_sk_min) AND DynamicValue(RS_19_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_19_item_i_item_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_22_store_s_store_sk_min) AND DynamicValue(RS_22_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_22_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_item_sk is not null and ss_store_sk is not null and ss_ticket_number is not null)
-                                                    TableScan [TS_0] (rows=575995635 width=122)
-                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
-                                                    <-Reducer 10 [BROADCAST_EDGE] vectorized
-                                                      BROADCAST [RS_301]
-                                                        Group By Operator [GBY_300] (rows=1 width=12)
-                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                        <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                          SHUFFLE [RS_299]
-                                                            Group By Operator [GBY_298] (rows=1 width=12)
-                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                              Select Operator [SEL_296] (rows=7000 width=4)
-                                                                Output:["_col0"]
-                                                                 Please refer to the previous Select Operator [SEL_293]
-                                                    <-Reducer 17 [BROADCAST_EDGE] vectorized
-                                                      BROADCAST [RS_313]
-                                                        Group By Operator [GBY_312] (rows=1 width=12)
-                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                        <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                          SHUFFLE [RS_310]
-                                                            Group By Operator [GBY_308] (rows=1 width=12)
-                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                              Select Operator [SEL_305] (rows=155 width=4)
-                                                                Output:["_col0"]
-                                                                 Please refer to the previous Select Operator [SEL_303]
+                                        Select Operator [SEL_327] (rows=525333486 width=122)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                          Filter Operator [FIL_326] (rows=525333486 width=122)
+                                            predicate:((ss_customer_sk BETWEEN DynamicValue(RS_30_customer_c_customer_sk_min) AND DynamicValue(RS_30_customer_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_30_customer_c_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_27_item_i_item_sk_min) AND DynamicValue(RS_27_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_27_item_i_item_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_30_store_s_store_sk_min) AND DynamicValue(RS_30_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_30_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_item_sk is not null and ss_store_sk is not null and ss_ticket_number is not null)
+                                            TableScan [TS_0] (rows=575995635 width=122)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
+                                            <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_323]
+                                                Group By Operator [GBY_322] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=6636187)"]
+                                                <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                  SHUFFLE [RS_152]
+                                                    Group By Operator [GBY_151] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=6636187)"]
+                                                      Select Operator [SEL_150] (rows=7276996 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_22]
+                                            <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_325]
+                                                Group By Operator [GBY_324] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                  SHUFFLE [RS_157]
+                                                    Group By Operator [GBY_156] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_155] (rows=7276996 width=8)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_22]
+                                            <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_312]
+                                                Group By Operator [GBY_311] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_310]
+                                                    Group By Operator [GBY_309] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_307] (rows=7000 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_304]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/query59.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query59.q.out b/ql/src/test/results/clientpositive/perf/tez/query59.q.out
index 76b4a5e..2ac474a 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query59.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query59.q.out
@@ -110,51 +110,51 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_210]
-        Limit [LIM_209] (rows=100 width=976)
+      File Output Operator [FS_208]
+        Limit [LIM_207] (rows=100 width=976)
           Number of rows:100
-          Select Operator [SEL_208] (rows=1012347 width=976)
+          Select Operator [SEL_206] (rows=1012347 width=976)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
           <-Reducer 6 [SIMPLE_EDGE]
             SHUFFLE [RS_59]
               Select Operator [SEL_58] (rows=1012347 width=976)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
-                Merge Join Operator [MERGEJOIN_185] (rows=1012347 width=1648)
+                Merge Join Operator [MERGEJOIN_183] (rows=1012347 width=1648)
                   Conds:RS_55._col12, _col0=RS_56._col1, (_col0 - 52)(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col12","_col13","_col16","_col17","_col18","_col19","_col20","_col21"]
                 <-Reducer 10 [SIMPLE_EDGE]
                   SHUFFLE [RS_56]
                     PartitionCols:_col1, (_col0 - 52)
                     Select Operator [SEL_48] (rows=28847 width=776)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
-                      Merge Join Operator [MERGEJOIN_184] (rows=28847 width=776)
-                        Conds:RS_45._col1=RS_207._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col11"]
+                      Merge Join Operator [MERGEJOIN_182] (rows=28847 width=776)
+                        Conds:RS_45._col1=RS_205._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col11"]
                       <-Map 14 [SIMPLE_EDGE] vectorized
-                        SHUFFLE [RS_207]
+                        SHUFFLE [RS_205]
                           PartitionCols:_col0
-                          Select Operator [SEL_206] (rows=1704 width=104)
+                          Select Operator [SEL_204] (rows=1704 width=104)
                             Output:["_col0","_col1"]
-                            Filter Operator [FIL_205] (rows=1704 width=104)
+                            Filter Operator [FIL_203] (rows=1704 width=104)
                               predicate:(s_store_id is not null and s_store_sk is not null)
                               TableScan [TS_39] (rows=1704 width=104)
                                 default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id"]
                       <-Reducer 9 [SIMPLE_EDGE]
                         SHUFFLE [RS_45]
                           PartitionCols:_col1
-                          Merge Join Operator [MERGEJOIN_183] (rows=28847 width=676)
-                            Conds:RS_204._col0=RS_199._col1(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                          Merge Join Operator [MERGEJOIN_181] (rows=28847 width=676)
+                            Conds:RS_202._col0=RS_197._col1(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
                           <-Map 12 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_199]
+                            SHUFFLE [RS_197]
                               PartitionCols:_col1
-                              Select Operator [SEL_197] (rows=317 width=8)
+                              Select Operator [SEL_195] (rows=317 width=8)
                                 Output:["_col1"]
-                                Filter Operator [FIL_195] (rows=317 width=8)
+                                Filter Operator [FIL_193] (rows=317 width=8)
                                   predicate:(d_month_seq BETWEEN 1197 AND 1208 and d_week_seq is not null)
                                   TableScan [TS_15] (rows=73049 width=8)
                                     default@date_dim,d,Tbl:COMPLETE,Col:COMPLETE,Output:["d_month_seq","d_week_seq"]
                           <-Reducer 8 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_204]
+                            SHUFFLE [RS_202]
                               PartitionCols:_col0
-                              Group By Operator [GBY_203] (rows=1196832 width=679)
+                              Group By Operator [GBY_201] (rows=1196832 width=679)
                                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)"],keys:KEY._col0, KEY._col1
                               <-Reducer 2 [SIMPLE_EDGE]
                                 SHUFFLE [RS_33]
@@ -163,57 +163,57 @@ Stage-0
                                     Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)","sum(_col3)","sum(_col5)","sum(_col6)","sum(_col7)","sum(_col8)"],keys:_col0, _col1
                                     Select Operator [SEL_30] (rows=525329897 width=205)
                                       Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7","_col8"]
-                                      Merge Join Operator [MERGEJOIN_179] (rows=525329897 width=205)
-                                        Conds:RS_188._col0=RS_191._col0(Inner),Output:["_col1","_col2","_col4","_col5"]
+                                      Merge Join Operator [MERGEJOIN_177] (rows=525329897 width=205)
+                                        Conds:RS_186._col0=RS_189._col0(Inner),Output:["_col1","_col2","_col4","_col5"]
                                       <-Map 1 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_188]
+                                        SHUFFLE [RS_186]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_187] (rows=525329897 width=114)
+                                          Select Operator [SEL_185] (rows=525329897 width=114)
                                             Output:["_col0","_col1","_col2"]
-                                            Filter Operator [FIL_186] (rows=525329897 width=114)
+                                            Filter Operator [FIL_184] (rows=525329897 width=114)
                                               predicate:(ss_sold_date_sk is not null and ss_store_sk is not null)
                                               TableScan [TS_0] (rows=575995635 width=114)
                                                 default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_store_sk","ss_sales_price"]
                                       <-Map 11 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_191]
+                                        SHUFFLE [RS_189]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_190] (rows=73049 width=99)
+                                          Select Operator [SEL_188] (rows=73049 width=99)
                                             Output:["_col0","_col1","_col2"]
-                                            Filter Operator [FIL_189] (rows=73049 width=99)
+                                            Filter Operator [FIL_187] (rows=73049 width=99)
                                               predicate:(d_date_sk is not null and d_week_seq is not null)
                                               TableScan [TS_3] (rows=73049 width=99)
                                                 default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_week_seq","d_day_name"]
                 <-Reducer 5 [SIMPLE_EDGE]
                   SHUFFLE [RS_55]
                     PartitionCols:_col12, _col0
-                    Merge Join Operator [MERGEJOIN_181] (rows=28847 width=976)
-                      Conds:RS_52._col1=RS_202._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col12","_col13"]
+                    Merge Join Operator [MERGEJOIN_179] (rows=28847 width=976)
+                      Conds:RS_52._col1=RS_200._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col12","_col13"]
                     <-Map 13 [SIMPLE_EDGE] vectorized
-                      SHUFFLE [RS_202]
+                      SHUFFLE [RS_200]
                         PartitionCols:_col0
-                        Select Operator [SEL_201] (rows=1704 width=192)
+                        Select Operator [SEL_199] (rows=1704 width=192)
                           Output:["_col0","_col1","_col2"]
-                          Filter Operator [FIL_200] (rows=1704 width=192)
+                          Filter Operator [FIL_198] (rows=1704 width=192)
                             predicate:(s_store_id is not null and s_store_sk is not null)
                             TableScan [TS_18] (rows=1704 width=192)
                               default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id","s_store_name"]
                     <-Reducer 4 [SIMPLE_EDGE]
                       SHUFFLE [RS_52]
                         PartitionCols:_col1
-                        Merge Join Operator [MERGEJOIN_180] (rows=28847 width=788)
-                          Conds:RS_193._col0=RS_198._col1(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                        Merge Join Operator [MERGEJOIN_178] (rows=28847 width=788)
+                          Conds:RS_191._col0=RS_196._col1(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
                         <-Map 12 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_198]
+                          SHUFFLE [RS_196]
                             PartitionCols:_col1
-                            Select Operator [SEL_196] (rows=317 width=8)
+                            Select Operator [SEL_194] (rows=317 width=8)
                               Output:["_col1"]
-                              Filter Operator [FIL_194] (rows=317 width=8)
+                              Filter Operator [FIL_192] (rows=317 width=8)
                                 predicate:(d_month_seq BETWEEN 1185 AND 1196 and d_week_seq is not null)
                                  Please refer to the previous TableScan [TS_15]
                         <-Reducer 3 [SIMPLE_EDGE] vectorized
-                          SHUFFLE [RS_193]
+                          SHUFFLE [RS_191]
                             PartitionCols:_col0
-                            Group By Operator [GBY_192] (rows=1196832 width=791)
+                            Group By Operator [GBY_190] (rows=1196832 width=791)
                               Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)"],keys:KEY._col0, KEY._col1
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_12]
@@ -222,5 +222,5 @@ Stage-0
                                   Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)","sum(_col5)","sum(_col6)","sum(_col7)","sum(_col8)"],keys:_col0, _col1
                                   Select Operator [SEL_9] (rows=525329897 width=205)
                                     Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
-                                     Please refer to the previous Merge Join Operator [MERGEJOIN_179]
+                                     Please refer to the previous Merge Join Operator [MERGEJOIN_177]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/query95.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query95.q.out b/ql/src/test/results/clientpositive/perf/tez/query95.q.out
index a88c534..49e8e86 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query95.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query95.q.out
@@ -104,123 +104,123 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 9 vectorized
-      File Output Operator [FS_296]
-        Limit [LIM_295] (rows=1 width=240)
+      File Output Operator [FS_302]
+        Limit [LIM_301] (rows=1 width=240)
           Number of rows:100
-          Select Operator [SEL_294] (rows=1 width=240)
+          Select Operator [SEL_300] (rows=1 width=240)
             Output:["_col0","_col1","_col2"]
           <-Reducer 8 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_293]
-              Select Operator [SEL_292] (rows=1 width=240)
+            SHUFFLE [RS_299]
+              Select Operator [SEL_298] (rows=1 width=240)
                 Output:["_col1","_col2","_col3"]
-                Group By Operator [GBY_291] (rows=1 width=232)
+                Group By Operator [GBY_297] (rows=1 width=232)
                   Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"]
                 <-Reducer 7 [CUSTOM_SIMPLE_EDGE] vectorized
-                  PARTITION_ONLY_SHUFFLE [RS_290]
-                    Group By Operator [GBY_289] (rows=1 width=232)
+                  PARTITION_ONLY_SHUFFLE [RS_296]
+                    Group By Operator [GBY_295] (rows=1 width=232)
                       Output:["_col0","_col1","_col2"],aggregations:["count(_col0)","sum(_col1)","sum(_col2)"]
-                      Group By Operator [GBY_288] (rows=2511437 width=228)
+                      Group By Operator [GBY_294] (rows=2511437 width=228)
                         Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
                       <-Reducer 6 [SIMPLE_EDGE]
                         SHUFFLE [RS_115]
                           PartitionCols:_col0
                           Group By Operator [GBY_114] (rows=2511437 width=228)
                             Output:["_col0","_col2","_col3"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col3
-                            Merge Join Operator [MERGEJOIN_235] (rows=5022875 width=227)
-                              Conds:RS_61._col3=RS_287._col0(Inner),Output:["_col3","_col4","_col5"]
+                            Merge Join Operator [MERGEJOIN_241] (rows=5022875 width=227)
+                              Conds:RS_61._col3=RS_293._col0(Inner),Output:["_col3","_col4","_col5"]
                             <-Reducer 5 [ONE_TO_ONE_EDGE]
                               FORWARD [RS_61]
                                 PartitionCols:_col3
-                                Merge Join Operator [MERGEJOIN_234] (rows=5022875 width=227)
-                                  Conds:RS_58._col3=RS_273._col0(Inner),Output:["_col3","_col4","_col5"]
+                                Merge Join Operator [MERGEJOIN_240] (rows=5022875 width=227)
+                                  Conds:RS_58._col3=RS_279._col0(Inner),Output:["_col3","_col4","_col5"]
                                 <-Reducer 4 [SIMPLE_EDGE]
                                   SHUFFLE [RS_58]
                                     PartitionCols:_col3
-                                    Merge Join Operator [MERGEJOIN_230] (rows=5022875 width=227)
-                                      Conds:RS_55._col2=RS_254._col0(Inner),Output:["_col3","_col4","_col5"]
+                                    Merge Join Operator [MERGEJOIN_236] (rows=5022875 width=227)
+                                      Conds:RS_55._col2=RS_260._col0(Inner),Output:["_col3","_col4","_col5"]
                                     <-Map 16 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_254]
+                                      SHUFFLE [RS_260]
                                         PartitionCols:_col0
-                                        Select Operator [SEL_253] (rows=12 width=91)
+                                        Select Operator [SEL_259] (rows=12 width=91)
                                           Output:["_col0"]
-                                          Filter Operator [FIL_252] (rows=12 width=92)
+                                          Filter Operator [FIL_258] (rows=12 width=92)
                                             predicate:((web_company_name = 'pri') and web_site_sk is not null)
                                             TableScan [TS_9] (rows=84 width=92)
                                               default@web_site,web_site,Tbl:COMPLETE,Col:COMPLETE,Output:["web_site_sk","web_company_name"]
                                     <-Reducer 3 [SIMPLE_EDGE]
                                       SHUFFLE [RS_55]
                                         PartitionCols:_col2
-                                        Merge Join Operator [MERGEJOIN_229] (rows=15673790 width=231)
-                                          Conds:RS_52._col1=RS_246._col0(Inner),Output:["_col2","_col3","_col4","_col5"]
+                                        Merge Join Operator [MERGEJOIN_235] (rows=15673790 width=231)
+                                          Conds:RS_52._col1=RS_252._col0(Inner),Output:["_col2","_col3","_col4","_col5"]
                                         <-Map 14 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_246]
+                                          SHUFFLE [RS_252]
                                             PartitionCols:_col0
-                                            Select Operator [SEL_245] (rows=784314 width=90)
+                                            Select Operator [SEL_251] (rows=784314 width=90)
                                               Output:["_col0"]
-                                              Filter Operator [FIL_244] (rows=784314 width=90)
+                                              Filter Operator [FIL_250] (rows=784314 width=90)
                                                 predicate:((ca_state = 'TX') and ca_address_sk is not null)
                                                 TableScan [TS_6] (rows=40000000 width=90)
                                                   default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
                                         <-Reducer 2 [SIMPLE_EDGE]
                                           SHUFFLE [RS_52]
                                             PartitionCols:_col1
-                                            Merge Join Operator [MERGEJOIN_228] (rows=15987241 width=235)
-                                              Conds:RS_262._col0=RS_238._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                            Merge Join Operator [MERGEJOIN_234] (rows=15987241 width=235)
+                                              Conds:RS_268._col0=RS_244._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
                                             <-Map 12 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_238]
+                                              SHUFFLE [RS_244]
                                                 PartitionCols:_col0
-                                                Select Operator [SEL_237] (rows=8116 width=98)
+                                                Select Operator [SEL_243] (rows=8116 width=98)
                                                   Output:["_col0"]
-                                                  Filter Operator [FIL_236] (rows=8116 width=98)
+                                                  Filter Operator [FIL_242] (rows=8116 width=98)
                                                     predicate:(CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1999-05-01 00:00:00' AND TIMESTAMP'1999-06-30 00:00:00' and d_date_sk is not null)
                                                     TableScan [TS_3] (rows=73049 width=98)
                                                       default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
                                             <-Map 1 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_262]
+                                              SHUFFLE [RS_268]
                                                 PartitionCols:_col0
-                                                Select Operator [SEL_261] (rows=143895019 width=239)
+                                                Select Operator [SEL_267] (rows=143895019 width=239)
                                                   Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                                  Filter Operator [FIL_260] (rows=143895019 width=239)
+                                                  Filter Operator [FIL_266] (rows=143895019 width=239)
                                                     predicate:((ws_ship_addr_sk BETWEEN DynamicValue(RS_53_customer_address_ca_address_sk_min) AND DynamicValue(RS_53_customer_address_ca_address_sk_max) and in_bloom_filter(ws_ship_addr_sk, DynamicValue(RS_53_customer_address_ca_address_sk_bloom_filter))) and (ws_ship_date_sk BETWEEN DynamicValue(RS_50_date_dim_d_date_sk_min) AND DynamicValue(RS_50_date_dim_d_date_sk_max) and in_bloom_filter(ws_ship_date_sk, DynamicValue(RS_50_date_dim_d_date_sk_bloom_filter))) and (ws_web_site_sk BETWEEN DynamicValue(RS_56_web_site_web_site_sk_min) AND DynamicValue(RS_56_web_site_web_site_sk_max) and in_bloom_filter(ws_web_site_sk, DynamicValue(RS_56_web_site_web_site_sk_bloom_filter))) and ws_order_number is not null and ws_ship_addr_sk is not null and ws_ship_date_sk is not null and ws_web_site_sk is not null)
                                                     TableScan [TS_0] (rows=144002668 width=239)
                                                       default@web_sales,ws1,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_ship_date_sk","ws_ship_addr_sk","ws_web_site_sk","ws_order_number","ws_ext_ship_cost","ws_net_profit"]
                                                     <-Reducer 13 [BROADCAST_EDGE] vectorized
-                                                      BROADCAST [RS_243]
-                                                        Group By Operator [GBY_242] (rows=1 width=12)
+                                                      BROADCAST [RS_249]
+                                                        Group By Operator [GBY_248] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                         <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                          SHUFFLE [RS_241]
-                                                            Group By Operator [GBY_240] (rows=1 width=12)
+                                                          SHUFFLE [RS_247]
+                                                            Group By Operator [GBY_246] (rows=1 width=12)
                                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                              Select Operator [SEL_239] (rows=8116 width=4)
+                                                              Select Operator [SEL_245] (rows=8116 width=4)
                                                                 Output:["_col0"]
-                                                                 Please refer to the previous Select Operator [SEL_237]
+                                                                 Please refer to the previous Select Operator [SEL_243]
                                                     <-Reducer 15 [BROADCAST_EDGE] vectorized
-                                                      BROADCAST [RS_251]
-                                                        Group By Operator [GBY_250] (rows=1 width=12)
+                                                      BROADCAST [RS_257]
+                                                        Group By Operator [GBY_256] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                         <-Map 14 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                          SHUFFLE [RS_249]
-                                                            Group By Operator [GBY_248] (rows=1 width=12)
+                                                          SHUFFLE [RS_255]
+                                                            Group By Operator [GBY_254] (rows=1 width=12)
                                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                              Select Operator [SEL_247] (rows=784314 width=4)
+                                                              Select Operator [SEL_253] (rows=784314 width=4)
                                                                 Output:["_col0"]
-                                                                 Please refer to the previous Select Operator [SEL_245]
+                                                                 Please refer to the previous Select Operator [SEL_251]
                                                     <-Reducer 17 [BROADCAST_EDGE] vectorized
-                                                      BROADCAST [RS_259]
-                                                        Group By Operator [GBY_258] (rows=1 width=12)
+                                                      BROADCAST [RS_265]
+                                                        Group By Operator [GBY_264] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                         <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                          SHUFFLE [RS_257]
-                                                            Group By Operator [GBY_256] (rows=1 width=12)
+                                                          SHUFFLE [RS_263]
+                                                            Group By Operator [GBY_262] (rows=1 width=12)
                                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                              Select Operator [SEL_255] (rows=12 width=4)
+                                                              Select Operator [SEL_261] (rows=12 width=4)
                                                                 Output:["_col0"]
-                                                                 Please refer to the previous Select Operator [SEL_253]
+                                                                 Please refer to the previous Select Operator [SEL_259]
                                 <-Reducer 20 [ONE_TO_ONE_EDGE] vectorized
-                                  FORWARD [RS_273]
+                                  FORWARD [RS_279]
                                     PartitionCols:_col0
-                                    Group By Operator [GBY_272] (rows=14686712 width=4)
+                                    Group By Operator [GBY_278] (rows=14686712 width=4)
                                       Output:["_col0"],keys:KEY._col0
                                     <-Reducer 19 [SIMPLE_EDGE]
                                       SHUFFLE [RS_24]
@@ -231,58 +231,58 @@ Stage-0
                                             Output:["_col1"]
                                             Filter Operator [FIL_21] (rows=1411940834 width=11)
                                               predicate:(_col0 <> _col2)
-                                              Merge Join Operator [MERGEJOIN_231] (rows=1411940834 width=11)
-                                                Conds:RS_268._col1=RS_271._col1(Inner),Output:["_col0","_col1","_col2"]
+                                              Merge Join Operator [MERGEJOIN_237] (rows=1411940834 width=11)
+                                                Conds:RS_274._col1=RS_277._col1(Inner),Output:["_col0","_col1","_col2"]
                                               <-Map 18 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_268]
+                                                SHUFFLE [RS_274]
                                                   PartitionCols:_col1
-                                                  Select Operator [SEL_267] (rows=144002668 width=7)
+                                                  Select Operator [SEL_273] (rows=144002668 width=7)
                                                     Output:["_col0","_col1"]
-                                                    Filter Operator [FIL_266] (rows=144002668 width=7)
+                                                    Filter Operator [FIL_272] (rows=144002668 width=7)
                                                       predicate:((ws_order_number BETWEEN DynamicValue(RS_58_ws1_ws_order_number_min) AND DynamicValue(RS_58_ws1_ws_order_number_max) and in_bloom_filter(ws_order_number, DynamicValue(RS_58_ws1_ws_order_number_bloom_filter))) and ws_order_number is not null)
                                                       TableScan [TS_12] (rows=144002668 width=7)
                                                         default@web_sales,ws1,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_warehouse_sk","ws_order_number"]
                                                       <-Reducer 11 [BROADCAST_EDGE] vectorized
-                                                        BROADCAST [RS_264]
-                                                          Group By Operator [GBY_263] (rows=1 width=12)
+                                                        BROADCAST [RS_270]
+                                                          Group By Operator [GBY_269] (rows=1 width=12)
                                                             Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                           <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
-                                                            SHUFFLE [RS_183]
-                                                              Group By Operator [GBY_182] (rows=1 width=12)
+                                                            SHUFFLE [RS_193]
+                                                              Group By Operator [GBY_192] (rows=1 width=12)
                                                                 Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                Select Operator [SEL_181] (rows=5022875 width=8)
+                                                                Select Operator [SEL_191] (rows=5022875 width=8)
                                                                   Output:["_col0"]
-                                                                   Please refer to the previous Merge Join Operator [MERGEJOIN_230]
+                                                                   Please refer to the previous Merge Join Operator [MERGEJOIN_236]
                                               <-Map 21 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_271]
+                                                SHUFFLE [RS_277]
                                                   PartitionCols:_col1
-                                                  Select Operator [SEL_270] (rows=144002668 width=7)
+                                                  Select Operator [SEL_276] (rows=144002668 width=7)
                                                     Output:["_col0","_col1"]
-                                                    Filter Operator [FIL_269] (rows=144002668 width=7)
+                                                    Filter Operator [FIL_275] (rows=144002668 width=7)
                                                       predicate:((ws_order_number BETWEEN DynamicValue(RS_58_ws1_ws_order_number_min) AND DynamicValue(RS_58_ws1_ws_order_number_max) and in_bloom_filter(ws_order_number, DynamicValue(RS_58_ws1_ws_order_number_bloom_filter))) and ws_order_number is not null)
                                                       TableScan [TS_15] (rows=144002668 width=7)
                                                         default@web_sales,ws2,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_warehouse_sk","ws_order_number"]
                                                       <-Reducer 11 [BROADCAST_EDGE] vectorized
-                                                        BROADCAST [RS_265]
-                                                           Please refer to the previous Group By Operator [GBY_263]
+                                                        BROADCAST [RS_271]
+                                                           Please refer to the previous Group By Operator [GBY_269]
                             <-Reducer 25 [ONE_TO_ONE_EDGE] vectorized
-                              FORWARD [RS_287]
+                              FORWARD [RS_293]
                                 PartitionCols:_col0
-                                Group By Operator [GBY_286] (rows=8007986 width=4)
+                                Group By Operator [GBY_292] (rows=8007986 width=4)
                                   Output:["_col0"],keys:KEY._col0
                                 <-Reducer 24 [SIMPLE_EDGE]
                                   SHUFFLE [RS_46]
                                     PartitionCols:_col0
                                     Group By Operator [GBY_45] (rows=14398467 width=4)
                                       Output:["_col0"],keys:_col14
-                                      Merge Join Operator [MERGEJOIN_233] (rows=1384229738 width=4)
-                                        Conds:RS_41._col0=RS_285._col13(Inner),Output:["_col14"]
+                                      Merge Join Operator [MERGEJOIN_239] (rows=1384229738 width=4)
+                                        Conds:RS_41._col0=RS_291._col13(Inner),Output:["_col14"]
                                       <-Map 27 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_285]
+                                        SHUFFLE [RS_291]
                                           PartitionCols:_col13
-                                          Select Operator [SEL_284] (rows=14398467 width=272)
+                                          Select Operator [SEL_290] (rows=14398467 width=272)
                                             Output:["_col13"]
-                                            Filter Operator [FIL_283] (rows=14398467 width=4)
+                                            Filter Operator [FIL_289] (rows=14398467 width=4)
                                               predicate:wr_order_number is not null
                                               TableScan [TS_38] (rows=14398467 width=4)
                                                 default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_order_number"]
@@ -293,38 +293,38 @@ Stage-0
                                             Output:["_col0"]
                                             Filter Operator [FIL_36] (rows=1411940834 width=11)
                                               predicate:(_col0 <> _col2)
-                                              Merge Join Operator [MERGEJOIN_232] (rows=1411940834 width=11)
-                                                Conds:RS_279._col1=RS_282._col1(Inner),Output:["_col0","_col1","_col2"]
+                                              Merge Join Operator [MERGEJOIN_238] (rows=1411940834 width=11)
+                                                Conds:RS_285._col1=RS_288._col1(Inner),Output:["_col0","_col1","_col2"]
                                               <-Map 22 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_279]
+                                                SHUFFLE [RS_285]
                                                   PartitionCols:_col1
-                                                  Select Operator [SEL_278] (rows=144002668 width=7)
+                                                  Select Operator [SEL_284] (rows=144002668 width=7)
                                                     Output:["_col0","_col1"]
-                                                    Filter Operator [FIL_277] (rows=144002668 width=7)
+                                                    Filter Operator [FIL_283] (rows=144002668 width=7)
                                                       predicate:((ws_order_number BETWEEN DynamicValue(RS_61_ws1_ws_order_number_min) AND DynamicValue(RS_61_ws1_ws_order_number_max) and in_bloom_filter(ws_order_number, DynamicValue(RS_61_ws1_ws_order_number_bloom_filter))) and ws_order_number is not null)
                                                       TableScan [TS_27] (rows=144002668 width=7)
                                                         default@web_sales,ws1,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_warehouse_sk","ws_order_number"]
                                                       <-Reducer 10 [BROADCAST_EDGE] vectorized
-                                                        BROADCAST [RS_275]
-                                                          Group By Operator [GBY_274] (rows=1 width=12)
+                                                        BROADCAST [RS_281]
+                                                          Group By Operator [GBY_280] (rows=1 width=12)
                                                             Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                           <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
-                                                            FORWARD [RS_202]
-                                                              Group By Operator [GBY_201] (rows=1 width=12)
+                                                            FORWARD [RS_212]
+                                                              Group By Operator [GBY_211] (rows=1 width=12)
                                                                 Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                Select Operator [SEL_200] (rows=5022875 width=8)
+                                                                Select Operator [SEL_210] (rows=5022875 width=8)
                                                                   Output:["_col0"]
-                                                                   Please refer to the previous Merge Join Operator [MERGEJOIN_234]
+                                                                   Please refer to the previous Merge Join Operator [MERGEJOIN_240]
                                               <-Map 26 [SIMPLE_EDGE] vectorized
-                                                SHUFFLE [RS_282]
+                                                SHUFFLE [RS_288]
                                                   PartitionCols:_col1
-                                                  Select Operator [SEL_281] (rows=144002668 width=7)
+                                                  Select Operator [SEL_287] (rows=144002668 width=7)
                                                     Output:["_col0","_col1"]
-                                                    Filter Operator [FIL_280] (rows=144002668 width=7)
+                                                    Filter Operator [FIL_286] (rows=144002668 width=7)
                                                       predicate:((ws_order_number BETWEEN DynamicValue(RS_61_ws1_ws_order_number_min) AND DynamicValue(RS_61_ws1_ws_order_number_max) and in_bloom_filter(ws_order_number, DynamicValue(RS_61_ws1_ws_order_number_bloom_filter))) and ws_order_number is not null)
                                                       TableScan [TS_30] (rows=144002668 width=7)
                                                         default@web_sales,ws2,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_warehouse_sk","ws_order_number"]
                                                       <-Reducer 10 [BROADCAST_EDGE] vectorized
-                                                        BROADCAST [RS_276]
-                                                           Please refer to the previous Group By Operator [GBY_274]
+                                                        BROADCAST [RS_282]
+                                                           Please refer to the previous Group By Operator [GBY_280]
 


[65/75] [abbrv] hive git commit: HIVE-20788: Extended SJ reduction may backtrack columns incorrectly when creating filters (Jesus Camacho Rodriguez, reviewed by Deepak Jaiswal)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out
index cb94e4f..5ba912a 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out
@@ -203,57 +203,57 @@ Stage-0
     limit:100
     Stage-1
       Reducer 7 vectorized
-      File Output Operator [FS_375]
-        Limit [LIM_374] (rows=100 width=212)
+      File Output Operator [FS_371]
+        Limit [LIM_370] (rows=100 width=212)
           Number of rows:100
-          Select Operator [SEL_373] (rows=1717 width=212)
+          Select Operator [SEL_369] (rows=1717 width=212)
             Output:["_col0","_col1"]
           <-Reducer 6 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_372]
-              Group By Operator [GBY_371] (rows=1717 width=212)
+            SHUFFLE [RS_368]
+              Group By Operator [GBY_367] (rows=1717 width=212)
                 Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
               <-Union 5 [SIMPLE_EDGE]
                 <-Reducer 10 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_388]
+                  Reduce Output Operator [RS_384]
                     PartitionCols:_col0
-                    Group By Operator [GBY_387] (rows=1717 width=212)
+                    Group By Operator [GBY_383] (rows=1717 width=212)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Top N Key Operator [TNK_386] (rows=5151 width=212)
+                      Top N Key Operator [TNK_382] (rows=5151 width=212)
                         keys:_col0,sort order:+,top n:100
-                        Group By Operator [GBY_385] (rows=1717 width=212)
+                        Group By Operator [GBY_381] (rows=1717 width=212)
                           Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                         <-Reducer 9 [SIMPLE_EDGE]
                           SHUFFLE [RS_69]
                             PartitionCols:_col0
                             Group By Operator [GBY_68] (rows=1717 width=212)
                               Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                              Merge Join Operator [MERGEJOIN_305] (rows=746132 width=100)
+                              Merge Join Operator [MERGEJOIN_301] (rows=746132 width=100)
                                 Conds:RS_64._col0=RS_65._col3(Inner),Output:["_col1","_col7"]
                               <-Reducer 2 [SIMPLE_EDGE]
                                 SHUFFLE [RS_64]
                                   PartitionCols:_col0
-                                  Merge Join Operator [MERGEJOIN_295] (rows=34340 width=104)
-                                    Conds:RS_323._col1=RS_329._col0(Inner),Output:["_col0","_col1"]
+                                  Merge Join Operator [MERGEJOIN_291] (rows=34340 width=104)
+                                    Conds:RS_319._col1=RS_325._col0(Inner),Output:["_col0","_col1"]
                                   <-Map 1 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_323]
+                                    SHUFFLE [RS_319]
                                       PartitionCols:_col1
-                                      Select Operator [SEL_322] (rows=462000 width=104)
+                                      Select Operator [SEL_318] (rows=462000 width=104)
                                         Output:["_col0","_col1"]
                                         TableScan [TS_0] (rows=462000 width=104)
                                           default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
                                   <-Reducer 16 [ONE_TO_ONE_EDGE] vectorized
-                                    FORWARD [RS_329]
+                                    FORWARD [RS_325]
                                       PartitionCols:_col0
-                                      Group By Operator [GBY_328] (rows=23100 width=100)
+                                      Group By Operator [GBY_324] (rows=23100 width=100)
                                         Output:["_col0"],keys:KEY._col0
                                       <-Map 15 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_327]
+                                        SHUFFLE [RS_323]
                                           PartitionCols:_col0
-                                          Group By Operator [GBY_326] (rows=23100 width=100)
+                                          Group By Operator [GBY_322] (rows=23100 width=100)
                                             Output:["_col0"],keys:i_item_id
-                                            Select Operator [SEL_325] (rows=46200 width=190)
+                                            Select Operator [SEL_321] (rows=46200 width=190)
                                               Output:["i_item_id"]
-                                              Filter Operator [FIL_324] (rows=46200 width=190)
+                                              Filter Operator [FIL_320] (rows=46200 width=190)
                                                 predicate:(i_category = 'Children')
                                                 TableScan [TS_2] (rows=462000 width=190)
                                                   default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_id","i_category"]
@@ -262,235 +262,235 @@ Stage-0
                                   PartitionCols:_col3
                                   Select Operator [SEL_60] (rows=1550375 width=13)
                                     Output:["_col3","_col4"]
-                                    Merge Join Operator [MERGEJOIN_300] (rows=1550375 width=13)
-                                      Conds:RS_57._col1=RS_350._col0(Inner),Output:["_col2","_col3"]
+                                    Merge Join Operator [MERGEJOIN_296] (rows=1550375 width=13)
+                                      Conds:RS_57._col1=RS_346._col0(Inner),Output:["_col2","_col3"]
                                     <-Map 28 [SIMPLE_EDGE] vectorized
-                                      PARTITION_ONLY_SHUFFLE [RS_350]
+                                      PARTITION_ONLY_SHUFFLE [RS_346]
                                         PartitionCols:_col0
-                                        Select Operator [SEL_347] (rows=8000000 width=4)
+                                        Select Operator [SEL_343] (rows=8000000 width=4)
                                           Output:["_col0"]
-                                          Filter Operator [FIL_346] (rows=8000000 width=112)
+                                          Filter Operator [FIL_342] (rows=8000000 width=112)
                                             predicate:(ca_gmt_offset = -6)
                                             TableScan [TS_15] (rows=40000000 width=112)
                                               default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_gmt_offset"]
                                     <-Reducer 22 [SIMPLE_EDGE]
                                       SHUFFLE [RS_57]
                                         PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_299] (rows=7751872 width=98)
-                                          Conds:RS_384._col0=RS_334._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        Merge Join Operator [MERGEJOIN_295] (rows=7751872 width=98)
+                                          Conds:RS_380._col0=RS_330._col0(Inner),Output:["_col1","_col2","_col3"]
                                         <-Map 20 [SIMPLE_EDGE] vectorized
-                                          PARTITION_ONLY_SHUFFLE [RS_334]
+                                          PARTITION_ONLY_SHUFFLE [RS_330]
                                             PartitionCols:_col0
-                                            Select Operator [SEL_331] (rows=50 width=4)
+                                            Select Operator [SEL_327] (rows=50 width=4)
                                               Output:["_col0"]
-                                              Filter Operator [FIL_330] (rows=50 width=12)
+                                              Filter Operator [FIL_326] (rows=50 width=12)
                                                 predicate:((d_moy = 9) and (d_year = 1999))
                                                 TableScan [TS_12] (rows=73049 width=12)
                                                   default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
                                         <-Map 32 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_384]
+                                          SHUFFLE [RS_380]
                                             PartitionCols:_col0
-                                            Select Operator [SEL_383] (rows=285117733 width=123)
+                                            Select Operator [SEL_379] (rows=285117733 width=123)
                                               Output:["_col0","_col1","_col2","_col3"]
-                                              Filter Operator [FIL_382] (rows=285117733 width=123)
+                                              Filter Operator [FIL_378] (rows=285117733 width=123)
                                                 predicate:((cs_bill_addr_sk BETWEEN DynamicValue(RS_58_customer_address_ca_address_sk_min) AND DynamicValue(RS_58_customer_address_ca_address_sk_max) and in_bloom_filter(cs_bill_addr_sk, DynamicValue(RS_58_customer_address_ca_address_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_64_item_i_item_sk_min) AND DynamicValue(RS_64_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_64_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_55_date_dim_d_date_sk_min) AND DynamicValue(RS_55_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_55_date_dim_d_date_sk_bloom_filter))) and cs_bill_addr_sk is not null and cs_sold_date_sk is not null)
                                                 TableScan [TS_45] (rows=287989836 width=123)
                                                   default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_addr_sk","cs_item_sk","cs_ext_sales_price"]
                                                 <-Reducer 11 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_381]
-                                                    Group By Operator [GBY_380] (rows=1 width=12)
+                                                  BROADCAST [RS_377]
+                                                    Group By Operator [GBY_376] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
-                                                      SHUFFLE [RS_240]
-                                                        Group By Operator [GBY_239] (rows=1 width=12)
+                                                      SHUFFLE [RS_238]
+                                                        Group By Operator [GBY_237] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_238] (rows=34340 width=4)
+                                                          Select Operator [SEL_236] (rows=34340 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_291]
                                                 <-Reducer 24 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_377]
-                                                    Group By Operator [GBY_376] (rows=1 width=12)
+                                                  BROADCAST [RS_373]
+                                                    Group By Operator [GBY_372] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_342]
-                                                        Group By Operator [GBY_339] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_338]
+                                                        Group By Operator [GBY_335] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_335] (rows=50 width=4)
+                                                          Select Operator [SEL_331] (rows=50 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_331]
+                                                             Please refer to the previous Select Operator [SEL_327]
                                                 <-Reducer 30 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_379]
-                                                    Group By Operator [GBY_378] (rows=1 width=12)
+                                                  BROADCAST [RS_375]
+                                                    Group By Operator [GBY_374] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                     <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_358]
-                                                        Group By Operator [GBY_355] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_354]
+                                                        Group By Operator [GBY_351] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                          Select Operator [SEL_351] (rows=8000000 width=4)
+                                                          Select Operator [SEL_347] (rows=8000000 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_347]
+                                                             Please refer to the previous Select Operator [SEL_343]
                 <-Reducer 13 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_401]
+                  Reduce Output Operator [RS_397]
                     PartitionCols:_col0
-                    Group By Operator [GBY_400] (rows=1717 width=212)
+                    Group By Operator [GBY_396] (rows=1717 width=212)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Top N Key Operator [TNK_399] (rows=5151 width=212)
+                      Top N Key Operator [TNK_395] (rows=5151 width=212)
                         keys:_col0,sort order:+,top n:100
-                        Group By Operator [GBY_398] (rows=1717 width=212)
+                        Group By Operator [GBY_394] (rows=1717 width=212)
                           Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                         <-Reducer 12 [SIMPLE_EDGE]
                           SHUFFLE [RS_106]
                             PartitionCols:_col0
                             Group By Operator [GBY_105] (rows=1717 width=212)
                               Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                              Merge Join Operator [MERGEJOIN_306] (rows=379339 width=201)
+                              Merge Join Operator [MERGEJOIN_302] (rows=379339 width=201)
                                 Conds:RS_101._col0=RS_102._col2(Inner),Output:["_col1","_col7"]
                               <-Reducer 2 [SIMPLE_EDGE]
                                 SHUFFLE [RS_101]
                                   PartitionCols:_col0
-                                   Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                                   Please refer to the previous Merge Join Operator [MERGEJOIN_291]
                               <-Reducer 26 [SIMPLE_EDGE]
                                 SHUFFLE [RS_102]
                                   PartitionCols:_col2
                                   Select Operator [SEL_97] (rows=788222 width=110)
                                     Output:["_col2","_col4"]
-                                    Merge Join Operator [MERGEJOIN_303] (rows=788222 width=110)
-                                      Conds:RS_94._col2=RS_352._col0(Inner),Output:["_col1","_col3"]
+                                    Merge Join Operator [MERGEJOIN_299] (rows=788222 width=110)
+                                      Conds:RS_94._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
                                     <-Map 28 [SIMPLE_EDGE] vectorized
-                                      PARTITION_ONLY_SHUFFLE [RS_352]
+                                      PARTITION_ONLY_SHUFFLE [RS_348]
                                         PartitionCols:_col0
-                                         Please refer to the previous Select Operator [SEL_347]
+                                         Please refer to the previous Select Operator [SEL_343]
                                     <-Reducer 25 [SIMPLE_EDGE]
                                       SHUFFLE [RS_94]
                                         PartitionCols:_col2
-                                        Merge Join Operator [MERGEJOIN_302] (rows=3941109 width=118)
-                                          Conds:RS_397._col0=RS_336._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        Merge Join Operator [MERGEJOIN_298] (rows=3941109 width=118)
+                                          Conds:RS_393._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
                                         <-Map 20 [SIMPLE_EDGE] vectorized
-                                          PARTITION_ONLY_SHUFFLE [RS_336]
+                                          PARTITION_ONLY_SHUFFLE [RS_332]
                                             PartitionCols:_col0
-                                             Please refer to the previous Select Operator [SEL_331]
+                                             Please refer to the previous Select Operator [SEL_327]
                                         <-Map 33 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_397]
+                                          SHUFFLE [RS_393]
                                             PartitionCols:_col0
-                                            Select Operator [SEL_396] (rows=143931246 width=123)
+                                            Select Operator [SEL_392] (rows=143931246 width=123)
                                               Output:["_col0","_col1","_col2","_col3"]
-                                              Filter Operator [FIL_395] (rows=143931246 width=123)
+                                              Filter Operator [FIL_391] (rows=143931246 width=123)
                                                 predicate:((ws_bill_addr_sk BETWEEN DynamicValue(RS_95_customer_address_ca_address_sk_min) AND DynamicValue(RS_95_customer_address_ca_address_sk_max) and in_bloom_filter(ws_bill_addr_sk, DynamicValue(RS_95_customer_address_ca_address_sk_bloom_filter))) and (ws_item_sk BETWEEN DynamicValue(RS_101_item_i_item_sk_min) AND DynamicValue(RS_101_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_101_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_92_date_dim_d_date_sk_min) AND DynamicValue(RS_92_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_92_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
                                                 TableScan [TS_82] (rows=144002668 width=123)
                                                   default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_addr_sk","ws_ext_sales_price"]
                                                 <-Reducer 14 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_394]
-                                                    Group By Operator [GBY_393] (rows=1 width=12)
+                                                  BROADCAST [RS_390]
+                                                    Group By Operator [GBY_389] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
-                                                      SHUFFLE [RS_286]
-                                                        Group By Operator [GBY_285] (rows=1 width=12)
+                                                      SHUFFLE [RS_278]
+                                                        Group By Operator [GBY_277] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_284] (rows=34340 width=4)
+                                                          Select Operator [SEL_276] (rows=34340 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_291]
                                                 <-Reducer 27 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_390]
-                                                    Group By Operator [GBY_389] (rows=1 width=12)
+                                                  BROADCAST [RS_386]
+                                                    Group By Operator [GBY_385] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_343]
-                                                        Group By Operator [GBY_340] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_339]
+                                                        Group By Operator [GBY_336] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_337] (rows=50 width=4)
+                                                          Select Operator [SEL_333] (rows=50 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_331]
+                                                             Please refer to the previous Select Operator [SEL_327]
                                                 <-Reducer 31 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_392]
-                                                    Group By Operator [GBY_391] (rows=1 width=12)
+                                                  BROADCAST [RS_388]
+                                                    Group By Operator [GBY_387] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                     <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_359]
-                                                        Group By Operator [GBY_356] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_355]
+                                                        Group By Operator [GBY_352] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                          Select Operator [SEL_353] (rows=8000000 width=4)
+                                                          Select Operator [SEL_349] (rows=8000000 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_347]
+                                                             Please refer to the previous Select Operator [SEL_343]
                 <-Reducer 4 [CONTAINS] vectorized
-                  Reduce Output Operator [RS_370]
+                  Reduce Output Operator [RS_366]
                     PartitionCols:_col0
-                    Group By Operator [GBY_369] (rows=1717 width=212)
+                    Group By Operator [GBY_365] (rows=1717 width=212)
                       Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
-                      Top N Key Operator [TNK_368] (rows=5151 width=212)
+                      Top N Key Operator [TNK_364] (rows=5151 width=212)
                         keys:_col0,sort order:+,top n:100
-                        Group By Operator [GBY_367] (rows=1717 width=212)
+                        Group By Operator [GBY_363] (rows=1717 width=212)
                           Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
                         <-Reducer 3 [SIMPLE_EDGE]
                           SHUFFLE [RS_33]
                             PartitionCols:_col0
                             Group By Operator [GBY_32] (rows=1717 width=212)
                               Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
-                              Merge Join Operator [MERGEJOIN_304] (rows=1384530 width=100)
+                              Merge Join Operator [MERGEJOIN_300] (rows=1384530 width=100)
                                 Conds:RS_28._col0=RS_29._col2(Inner),Output:["_col1","_col7"]
                               <-Reducer 2 [SIMPLE_EDGE]
                                 SHUFFLE [RS_28]
                                   PartitionCols:_col0
-                                   Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                                   Please refer to the previous Merge Join Operator [MERGEJOIN_291]
                               <-Reducer 19 [SIMPLE_EDGE]
                                 SHUFFLE [RS_29]
                                   PartitionCols:_col2
                                   Select Operator [SEL_24] (rows=2876890 width=4)
                                     Output:["_col2","_col4"]
-                                    Merge Join Operator [MERGEJOIN_297] (rows=2876890 width=4)
-                                      Conds:RS_21._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
+                                    Merge Join Operator [MERGEJOIN_293] (rows=2876890 width=4)
+                                      Conds:RS_21._col2=RS_344._col0(Inner),Output:["_col1","_col3"]
                                     <-Map 28 [SIMPLE_EDGE] vectorized
-                                      PARTITION_ONLY_SHUFFLE [RS_348]
+                                      PARTITION_ONLY_SHUFFLE [RS_344]
                                         PartitionCols:_col0
-                                         Please refer to the previous Select Operator [SEL_347]
+                                         Please refer to the previous Select Operator [SEL_343]
                                     <-Reducer 18 [SIMPLE_EDGE]
                                       SHUFFLE [RS_21]
                                         PartitionCols:_col2
-                                        Merge Join Operator [MERGEJOIN_296] (rows=14384447 width=4)
-                                          Conds:RS_366._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        Merge Join Operator [MERGEJOIN_292] (rows=14384447 width=4)
+                                          Conds:RS_362._col0=RS_328._col0(Inner),Output:["_col1","_col2","_col3"]
                                         <-Map 20 [SIMPLE_EDGE] vectorized
-                                          PARTITION_ONLY_SHUFFLE [RS_332]
+                                          PARTITION_ONLY_SHUFFLE [RS_328]
                                             PartitionCols:_col0
-                                             Please refer to the previous Select Operator [SEL_331]
+                                             Please refer to the previous Select Operator [SEL_327]
                                         <-Map 17 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_366]
+                                          SHUFFLE [RS_362]
                                             PartitionCols:_col0
-                                            Select Operator [SEL_365] (rows=525327191 width=118)
+                                            Select Operator [SEL_361] (rows=525327191 width=118)
                                               Output:["_col0","_col1","_col2","_col3"]
-                                              Filter Operator [FIL_364] (rows=525327191 width=118)
+                                              Filter Operator [FIL_360] (rows=525327191 width=118)
                                                 predicate:((ss_addr_sk BETWEEN DynamicValue(RS_22_customer_address_ca_address_sk_min) AND DynamicValue(RS_22_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_22_customer_address_ca_address_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_28_item_i_item_sk_min) AND DynamicValue(RS_28_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_28_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_19_date_dim_d_date_sk_min) AND DynamicValue(RS_19_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_19_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
                                                 TableScan [TS_9] (rows=575995635 width=118)
                                                   default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
                                                 <-Reducer 21 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_345]
-                                                    Group By Operator [GBY_344] (rows=1 width=12)
+                                                  BROADCAST [RS_341]
+                                                    Group By Operator [GBY_340] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_341]
-                                                        Group By Operator [GBY_338] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_337]
+                                                        Group By Operator [GBY_334] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_333] (rows=50 width=4)
+                                                          Select Operator [SEL_329] (rows=50 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_331]
+                                                             Please refer to the previous Select Operator [SEL_327]
                                                 <-Reducer 29 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_361]
-                                                    Group By Operator [GBY_360] (rows=1 width=12)
+                                                  BROADCAST [RS_357]
+                                                    Group By Operator [GBY_356] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
                                                     <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                      PARTITION_ONLY_SHUFFLE [RS_357]
-                                                        Group By Operator [GBY_354] (rows=1 width=12)
+                                                      PARTITION_ONLY_SHUFFLE [RS_353]
+                                                        Group By Operator [GBY_350] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
-                                                          Select Operator [SEL_349] (rows=8000000 width=4)
+                                                          Select Operator [SEL_345] (rows=8000000 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Select Operator [SEL_347]
+                                                             Please refer to the previous Select Operator [SEL_343]
                                                 <-Reducer 8 [BROADCAST_EDGE] vectorized
-                                                  BROADCAST [RS_363]
-                                                    Group By Operator [GBY_362] (rows=1 width=12)
+                                                  BROADCAST [RS_359]
+                                                    Group By Operator [GBY_358] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                     <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
-                                                      SHUFFLE [RS_204]
-                                                        Group By Operator [GBY_203] (rows=1 width=12)
+                                                      SHUFFLE [RS_198]
+                                                        Group By Operator [GBY_197] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                          Select Operator [SEL_202] (rows=34340 width=4)
+                                                          Select Operator [SEL_196] (rows=34340 width=4)
                                                             Output:["_col0"]
-                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_291]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/query95.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query95.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query95.q.out
index c286c74..fd709f9 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query95.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query95.q.out
@@ -98,37 +98,37 @@ Stage-0
     limit:-1
     Stage-1
       Reducer 9 vectorized
-      File Output Operator [FS_265]
-        Limit [LIM_264] (rows=1 width=240)
+      File Output Operator [FS_273]
+        Limit [LIM_272] (rows=1 width=240)
           Number of rows:100
-          Select Operator [SEL_263] (rows=1 width=240)
+          Select Operator [SEL_271] (rows=1 width=240)
             Output:["_col0","_col1","_col2"]
           <-Reducer 8 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_262]
-              Select Operator [SEL_261] (rows=1 width=240)
+            SHUFFLE [RS_270]
+              Select Operator [SEL_269] (rows=1 width=240)
                 Output:["_col1","_col2","_col3"]
-                Group By Operator [GBY_260] (rows=1 width=232)
+                Group By Operator [GBY_268] (rows=1 width=232)
                   Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"]
                 <-Reducer 7 [CUSTOM_SIMPLE_EDGE] vectorized
-                  PARTITION_ONLY_SHUFFLE [RS_259]
-                    Group By Operator [GBY_258] (rows=1 width=232)
+                  PARTITION_ONLY_SHUFFLE [RS_267]
+                    Group By Operator [GBY_266] (rows=1 width=232)
                       Output:["_col0","_col1","_col2"],aggregations:["count(_col0)","sum(_col1)","sum(_col2)"]
-                      Group By Operator [GBY_257] (rows=143895019 width=228)
+                      Group By Operator [GBY_265] (rows=143895019 width=228)
                         Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
                       <-Reducer 6 [SIMPLE_EDGE]
                         SHUFFLE [RS_101]
                           PartitionCols:_col0
                           Group By Operator [GBY_100] (rows=143895019 width=228)
                             Output:["_col0","_col2","_col3"],aggregations:["sum(_col4)","sum(_col5)"],keys:_col3
-                            Merge Join Operator [MERGEJOIN_219] (rows=83469759007 width=227)
+                            Merge Join Operator [MERGEJOIN_227] (rows=83469759007 width=227)
                               Conds:RS_47._col3=RS_48._col0(Inner),Output:["_col3","_col4","_col5"]
                             <-Reducer 19 [ONE_TO_ONE_EDGE]
                               FORWARD [RS_48]
                                 PartitionCols:_col0
                                 Select Operator [SEL_34] (rows=1384229738 width=4)
                                   Output:["_col0"]
-                                  Merge Join Operator [MERGEJOIN_213] (rows=1384229738 width=4)
-                                    Conds:RS_31._col0=RS_256.wr_order_number(Inner),Output:["_col14"]
+                                  Merge Join Operator [MERGEJOIN_221] (rows=1384229738 width=4)
+                                    Conds:RS_31._col0=RS_264.wr_order_number(Inner),Output:["_col14"]
                                   <-Reducer 18 [ONE_TO_ONE_EDGE]
                                     FORWARD [RS_31]
                                       PartitionCols:_col0
@@ -136,129 +136,129 @@ Stage-0
                                         Output:["_col0"]
                                         Filter Operator [FIL_28] (rows=1411940834 width=11)
                                           predicate:(_col0 <> _col2)
-                                          Merge Join Operator [MERGEJOIN_212] (rows=1411940834 width=11)
-                                            Conds:RS_252._col1=RS_255._col1(Inner),Output:["_col0","_col1","_col2"]
+                                          Merge Join Operator [MERGEJOIN_220] (rows=1411940834 width=11)
+                                            Conds:RS_260._col1=RS_263._col1(Inner),Output:["_col0","_col1","_col2"]
                                           <-Map 17 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_252]
+                                            SHUFFLE [RS_260]
                                               PartitionCols:_col1
-                                              Select Operator [SEL_251] (rows=144002668 width=7)
+                                              Select Operator [SEL_259] (rows=144002668 width=7)
                                                 Output:["_col0","_col1"]
-                                                Filter Operator [FIL_250] (rows=144002668 width=7)
+                                                Filter Operator [FIL_258] (rows=144002668 width=7)
                                                   predicate:(in_bloom_filter(ws_order_number, DynamicValue(RS_44_ws1_ws_order_number_bloom_filter)) and ws_order_number BETWEEN DynamicValue(RS_44_ws1_ws_order_number_min) AND DynamicValue(RS_44_ws1_ws_order_number_max))
                                                   TableScan [TS_21] (rows=144002668 width=7)
                                                     default@web_sales,ws1,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_warehouse_sk","ws_order_number"]
                                                   <-Reducer 10 [BROADCAST_EDGE] vectorized
-                                                    BROADCAST [RS_248]
-                                                      Group By Operator [GBY_247] (rows=1 width=12)
+                                                    BROADCAST [RS_256]
+                                                      Group By Operator [GBY_255] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                       <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
-                                                        SHUFFLE [RS_163]
-                                                          Group By Operator [GBY_162] (rows=1 width=12)
+                                                        SHUFFLE [RS_179]
+                                                          Group By Operator [GBY_178] (rows=1 width=12)
                                                             Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                            Select Operator [SEL_161] (rows=5022875 width=8)
+                                                            Select Operator [SEL_177] (rows=5022875 width=8)
                                                               Output:["_col0"]
-                                                              Merge Join Operator [MERGEJOIN_216] (rows=5022875 width=227)
-                                                                Conds:RS_41._col2=RS_238._col0(Inner),Output:["_col3","_col4","_col5"]
+                                                              Merge Join Operator [MERGEJOIN_224] (rows=5022875 width=227)
+                                                                Conds:RS_41._col2=RS_246._col0(Inner),Output:["_col3","_col4","_col5"]
                                                               <-Map 15 [SIMPLE_EDGE] vectorized
-                                                                SHUFFLE [RS_238]
+                                                                SHUFFLE [RS_246]
                                                                   PartitionCols:_col0
-                                                                  Select Operator [SEL_237] (rows=12 width=4)
+                                                                  Select Operator [SEL_245] (rows=12 width=4)
                                                                     Output:["_col0"]
-                                                                    Filter Operator [FIL_236] (rows=12 width=92)
+                                                                    Filter Operator [FIL_244] (rows=12 width=92)
                                                                       predicate:(web_company_name = 'pri')
                                                                       TableScan [TS_9] (rows=84 width=92)
                                                                         default@web_site,web_site,Tbl:COMPLETE,Col:COMPLETE,Output:["web_site_sk","web_company_name"]
                                                               <-Reducer 3 [SIMPLE_EDGE]
                                                                 SHUFFLE [RS_41]
                                                                   PartitionCols:_col2
-                                                                  Merge Join Operator [MERGEJOIN_215] (rows=15673790 width=231)
-                                                                    Conds:RS_38._col1=RS_230._col0(Inner),Output:["_col2","_col3","_col4","_col5"]
+                                                                  Merge Join Operator [MERGEJOIN_223] (rows=15673790 width=231)
+                                                                    Conds:RS_38._col1=RS_238._col0(Inner),Output:["_col2","_col3","_col4","_col5"]
                                                                   <-Map 13 [SIMPLE_EDGE] vectorized
-                                                                    SHUFFLE [RS_230]
+                                                                    SHUFFLE [RS_238]
                                                                       PartitionCols:_col0
-                                                                      Select Operator [SEL_229] (rows=784314 width=4)
+                                                                      Select Operator [SEL_237] (rows=784314 width=4)
                                                                         Output:["_col0"]
-                                                                        Filter Operator [FIL_228] (rows=784314 width=90)
+                                                                        Filter Operator [FIL_236] (rows=784314 width=90)
                                                                           predicate:(ca_state = 'TX')
                                                                           TableScan [TS_6] (rows=40000000 width=90)
                                                                             default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
                                                                   <-Reducer 2 [SIMPLE_EDGE]
                                                                     SHUFFLE [RS_38]
                                                                       PartitionCols:_col1
-                                                                      Merge Join Operator [MERGEJOIN_214] (rows=15987241 width=235)
-                                                                        Conds:RS_246._col0=RS_222._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                                                      Merge Join Operator [MERGEJOIN_222] (rows=15987241 width=235)
+                                                                        Conds:RS_254._col0=RS_230._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
                                                                       <-Map 11 [SIMPLE_EDGE] vectorized
-                                                                        SHUFFLE [RS_222]
+                                                                        SHUFFLE [RS_230]
                                                                           PartitionCols:_col0
-                                                                          Select Operator [SEL_221] (rows=8116 width=98)
+                                                                          Select Operator [SEL_229] (rows=8116 width=98)
                                                                             Output:["_col0"]
-                                                                            Filter Operator [FIL_220] (rows=8116 width=98)
+                                                                            Filter Operator [FIL_228] (rows=8116 width=98)
                                                                               predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1999-05-01 00:00:00' AND TIMESTAMP'1999-06-30 00:00:00'
                                                                               TableScan [TS_3] (rows=73049 width=98)
                                                                                 default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
                                                                       <-Map 1 [SIMPLE_EDGE] vectorized
-                                                                        SHUFFLE [RS_246]
+                                                                        SHUFFLE [RS_254]
                                                                           PartitionCols:_col0
-                                                                          Select Operator [SEL_245] (rows=143895019 width=239)
+                                                                          Select Operator [SEL_253] (rows=143895019 width=239)
                                                                             Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                                                            Filter Operator [FIL_244] (rows=143895019 width=239)
+                                                                            Filter Operator [FIL_252] (rows=143895019 width=239)
                                                                               predicate:((ws_ship_addr_sk BETWEEN DynamicValue(RS_39_customer_address_ca_address_sk_min) AND DynamicValue(RS_39_customer_address_ca_address_sk_max) and in_bloom_filter(ws_ship_addr_sk, DynamicValue(RS_39_customer_address_ca_address_sk_bloom_filter))) and (ws_ship_date_sk BETWEEN DynamicValue(RS_36_date_dim_d_date_sk_min) AND DynamicValue(RS_36_date_dim_d_date_sk_max) and in_bloom_filter(ws_ship_date_sk, DynamicValue(RS_36_date_dim_d_date_sk_bloom_filter))) and (ws_web_site_sk BETWEEN DynamicValue(RS_42_web_site_web_site_sk_min) AND DynamicValue(RS_42_web_site_web_site_sk_max) and in_bloom_filter(ws_web_site_sk, DynamicValue(RS_42_web_site_web_site_sk_bloom_filter))) and ws_ship_addr_sk is not null and ws_ship_date_sk is not null and ws_web_site_sk is not null)
                                                                               TableScan [TS_0] (rows=144002668 width=239)
                                                                                 default@web_sales,ws1,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_ship_date_sk","ws_ship_addr_sk","ws_web_site_sk","ws_order_number","ws_ext_ship_cost","ws_net_profit"]
                                                                               <-Reducer 12 [BROADCAST_EDGE] vectorized
-                                                                                BROADCAST [RS_227]
-                                                                                  Group By Operator [GBY_226] (rows=1 width=12)
-                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                                                  <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                                                    SHUFFLE [RS_225]
-                                                                                      Group By Operator [GBY_224] (rows=1 width=12)
-                                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                                        Select Operator [SEL_223] (rows=8116 width=4)
-                                                                                          Output:["_col0"]
-                                                                                           Please refer to the previous Select Operator [SEL_221]
-                                                                              <-Reducer 14 [BROADCAST_EDGE] vectorized
                                                                                 BROADCAST [RS_235]
                                                                                   Group By Operator [GBY_234] (rows=1 width=12)
                                                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                                                  <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                  <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
                                                                                     SHUFFLE [RS_233]
                                                                                       Group By Operator [GBY_232] (rows=1 width=12)
                                                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                                        Select Operator [SEL_231] (rows=784314 width=4)
+                                                                                        Select Operator [SEL_231] (rows=8116 width=4)
                                                                                           Output:["_col0"]
                                                                                            Please refer to the previous Select Operator [SEL_229]
-                                                                              <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                                              <-Reducer 14 [BROADCAST_EDGE] vectorized
                                                                                 BROADCAST [RS_243]
                                                                                   Group By Operator [GBY_242] (rows=1 width=12)
                                                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                                                  <-Map 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                  <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
                                                                                     SHUFFLE [RS_241]
                                                                                       Group By Operator [GBY_240] (rows=1 width=12)
                                                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                                        Select Operator [SEL_239] (rows=12 width=4)
+                                                                                        Select Operator [SEL_239] (rows=784314 width=4)
                                                                                           Output:["_col0"]
                                                                                            Please refer to the previous Select Operator [SEL_237]
+                                                                              <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                                                BROADCAST [RS_251]
+                                                                                  Group By Operator [GBY_250] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                                  <-Map 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                    SHUFFLE [RS_249]
+                                                                                      Group By Operator [GBY_248] (rows=1 width=12)
+                                                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                        Select Operator [SEL_247] (rows=12 width=4)
+                                                                                          Output:["_col0"]
+                                                                                           Please refer to the previous Select Operator [SEL_245]
                                           <-Map 20 [SIMPLE_EDGE] vectorized
-                                            SHUFFLE [RS_255]
+                                            SHUFFLE [RS_263]
                                               PartitionCols:_col1
-                                              Select Operator [SEL_254] (rows=144002668 width=7)
+                                              Select Operator [SEL_262] (rows=144002668 width=7)
                                                 Output:["_col0","_col1"]
-                                                Filter Operator [FIL_253] (rows=144002668 width=7)
+                                                Filter Operator [FIL_261] (rows=144002668 width=7)
                                                   predicate:(in_bloom_filter(ws_order_number, DynamicValue(RS_44_ws1_ws_order_number_bloom_filter)) and ws_order_number BETWEEN DynamicValue(RS_44_ws1_ws_order_number_min) AND DynamicValue(RS_44_ws1_ws_order_number_max))
                                                   TableScan [TS_23] (rows=144002668 width=7)
                                                     default@web_sales,ws2,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_warehouse_sk","ws_order_number"]
                                                   <-Reducer 10 [BROADCAST_EDGE] vectorized
-                                                    BROADCAST [RS_249]
-                                                       Please refer to the previous Group By Operator [GBY_247]
+                                                    BROADCAST [RS_257]
+                                                       Please refer to the previous Group By Operator [GBY_255]
                                   <-Map 21 [SIMPLE_EDGE] vectorized
-                                    SHUFFLE [RS_256]
+                                    SHUFFLE [RS_264]
                                       PartitionCols:wr_order_number
                                       TableScan [TS_30] (rows=14398467 width=4)
                                         default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_order_number"]
                             <-Reducer 5 [ONE_TO_ONE_EDGE]
                               FORWARD [RS_47]
                                 PartitionCols:_col3
-                                Merge Join Operator [MERGEJOIN_218] (rows=482885639 width=227)
+                                Merge Join Operator [MERGEJOIN_226] (rows=482885639 width=227)
                                   Conds:RS_44._col3=RS_45._col0(Inner),Output:["_col3","_col4","_col5"]
                                 <-Reducer 18 [ONE_TO_ONE_EDGE]
                                   FORWARD [RS_45]
@@ -267,5 +267,5 @@ Stage-0
                                 <-Reducer 4 [SIMPLE_EDGE]
                                   SHUFFLE [RS_44]
                                     PartitionCols:_col3
-                                     Please refer to the previous Merge Join Operator [MERGEJOIN_216]
+                                     Please refer to the previous Merge Join Operator [MERGEJOIN_224]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/query18.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/query18.q.out b/ql/src/test/results/clientpositive/perf/tez/query18.q.out
index 1fa1b9e..58fb7a7 100644
--- a/ql/src/test/results/clientpositive/perf/tez/query18.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/query18.q.out
@@ -99,16 +99,16 @@ Stage-0
     limit:100
     Stage-1
       Reducer 6 vectorized
-      File Output Operator [FS_184]
-        Limit [LIM_183] (rows=100 width=1165)
+      File Output Operator [FS_182]
+        Limit [LIM_181] (rows=100 width=1165)
           Number of rows:100
-          Select Operator [SEL_182] (rows=10969055 width=1165)
+          Select Operator [SEL_180] (rows=10969055 width=1165)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
           <-Reducer 5 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_181]
-              Select Operator [SEL_180] (rows=10969055 width=1165)
+            SHUFFLE [RS_179]
+              Select Operator [SEL_178] (rows=10969055 width=1165)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
-                Group By Operator [GBY_179] (rows=10969055 width=1229)
+                Group By Operator [GBY_177] (rows=10969055 width=1229)
                   Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","sum(VALUE._col6)","count(VALUE._col7)","sum(VALUE._col8)","count(VALUE._col9)","sum(VALUE._col10)","count(VALUE._col11)","sum(VALUE._col12)","count(VALUE._col13)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
                 <-Reducer 4 [SIMPLE_EDGE]
                   SHUFFLE [RS_43]
@@ -117,42 +117,42 @@ Stage-0
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"],aggregations:["sum(_col4)","count(_col4)","sum(_col5)","count(_col5)","sum(_col6)","count(_col6)","sum(_col7)","count(_col7)","sum(_col8)","count(_col8)","sum(_col9)","count(_col9)","sum(_col10)","count(_col10)"],keys:_col0, _col1, _col2, _col3, 0L
                       Select Operator [SEL_40] (rows=2193811 width=618)
                         Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
-                        Merge Join Operator [MERGEJOIN_145] (rows=2193811 width=618)
+                        Merge Join Operator [MERGEJOIN_143] (rows=2193811 width=618)
                           Conds:RS_37._col0=RS_38._col3(Inner),Output:["_col4","_col6","_col7","_col8","_col11","_col16","_col17","_col18","_col19","_col20","_col26"]
                         <-Reducer 3 [SIMPLE_EDGE]
                           PARTITION_ONLY_SHUFFLE [RS_37]
                             PartitionCols:_col0
-                            Merge Join Operator [MERGEJOIN_141] (rows=4959744 width=287)
-                              Conds:RS_34._col1=RS_154._col0(Inner),Output:["_col0","_col4","_col6","_col7","_col8"]
+                            Merge Join Operator [MERGEJOIN_139] (rows=4959744 width=287)
+                              Conds:RS_34._col1=RS_152._col0(Inner),Output:["_col0","_col4","_col6","_col7","_col8"]
                             <-Map 9 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_154]
+                              SHUFFLE [RS_152]
                                 PartitionCols:_col0
-                                Select Operator [SEL_153] (rows=1861800 width=4)
+                                Select Operator [SEL_151] (rows=1861800 width=4)
                                   Output:["_col0"]
-                                  Filter Operator [FIL_152] (rows=1861800 width=4)
+                                  Filter Operator [FIL_150] (rows=1861800 width=4)
                                     predicate:cd_demo_sk is not null
                                     TableScan [TS_6] (rows=1861800 width=4)
                                       default@customer_demographics,cd2,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk"]
                             <-Reducer 2 [SIMPLE_EDGE]
                               SHUFFLE [RS_34]
                                 PartitionCols:_col1
-                                Merge Join Operator [MERGEJOIN_140] (rows=4890586 width=290)
-                                  Conds:RS_148._col2=RS_151._col0(Inner),Output:["_col0","_col1","_col4","_col6","_col7","_col8"]
+                                Merge Join Operator [MERGEJOIN_138] (rows=4890586 width=290)
+                                  Conds:RS_146._col2=RS_149._col0(Inner),Output:["_col0","_col1","_col4","_col6","_col7","_col8"]
                                 <-Map 1 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_148]
+                                  SHUFFLE [RS_146]
                                     PartitionCols:_col2
-                                    Select Operator [SEL_147] (rows=35631408 width=19)
+                                    Select Operator [SEL_145] (rows=35631408 width=19)
                                       Output:["_col0","_col1","_col2","_col4"]
-                                      Filter Operator [FIL_146] (rows=35631408 width=19)
+                                      Filter Operator [FIL_144] (rows=35631408 width=19)
                                         predicate:((c_birth_month) IN (9, 5, 12, 4, 1, 10) and c_current_addr_sk is not null and c_current_cdemo_sk is not null and c_customer_sk is not null)
                                         TableScan [TS_0] (rows=80000000 width=19)
                                           default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk","c_birth_month","c_birth_year"]
                                 <-Map 8 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_151]
+                                  SHUFFLE [RS_149]
                                     PartitionCols:_col0
-                                    Select Operator [SEL_150] (rows=5490196 width=285)
+                                    Select Operator [SEL_148] (rows=5490196 width=285)
                                       Output:["_col0","_col1","_col2","_col3"]
-                                      Filter Operator [FIL_149] (rows=5490196 width=285)
+                                      Filter Operator [FIL_147] (rows=5490196 width=285)
                                         predicate:((ca_state) IN ('ND', 'WI', 'AL', 'NC', 'OK', 'MS', 'TN') and ca_address_sk is not null)
                                         TableScan [TS_3] (rows=40000000 width=285)
                                           default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_county","ca_state","ca_country"]
@@ -161,85 +161,85 @@ Stage-0
                             PartitionCols:_col3
                             Select Operator [SEL_30] (rows=15983481 width=529)
                               Output:["_col1","_col3","_col6","_col7","_col8","_col9","_col10","_col16"]
-                              Merge Join Operator [MERGEJOIN_144] (rows=15983481 width=529)
-                                Conds:RS_27._col3=RS_178._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col8","_col14","_col16"]
+                              Merge Join Operator [MERGEJOIN_142] (rows=15983481 width=529)
+                                Conds:RS_27._col3=RS_176._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col8","_col14","_col16"]
                               <-Map 18 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_178]
+                                SHUFFLE [RS_176]
                                   PartitionCols:_col0
-                                  Select Operator [SEL_177] (rows=462000 width=104)
+                                  Select Operator [SEL_175] (rows=462000 width=104)
                                     Output:["_col0","_col1"]
-                                    Filter Operator [FIL_176] (rows=462000 width=104)
+                                    Filter Operator [FIL_174] (rows=462000 width=104)
                                       predicate:i_item_sk is not null
                                       TableScan [TS_18] (rows=462000 width=104)
                                         default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
                               <-Reducer 12 [SIMPLE_EDGE]
                                 SHUFFLE [RS_27]
                                   PartitionCols:_col3
-                                  Merge Join Operator [MERGEJOIN_143] (rows=15983481 width=433)
-                                    Conds:RS_24._col2=RS_165._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col14"]
+                                  Merge Join Operator [MERGEJOIN_141] (rows=15983481 width=433)
+                                    Conds:RS_24._col2=RS_163._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col14"]
                                   <-Map 16 [SIMPLE_EDGE] vectorized
-                                    PARTITION_ONLY_SHUFFLE [RS_165]
+                                    PARTITION_ONLY_SHUFFLE [RS_163]
                                       PartitionCols:_col0
-                                      Select Operator [SEL_164] (rows=103433 width=184)
+                                      Select Operator [SEL_162] (rows=103433 width=184)
                                         Output:["_col0","_col3"]
-                                        Filter Operator [FIL_163] (rows=103433 width=187)
+                                        Filter Operator [FIL_161] (rows=103433 width=187)
                                           predicate:((cd_education_status = 'College') and (cd_gender = 'M') and cd_demo_sk is not null)
                                           TableScan [TS_15] (rows=1861800 width=187)
                                             default@customer_demographics,cd1,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_education_status","cd_dep_count"]
                                   <-Reducer 11 [SIMPLE_EDGE]
                                     SHUFFLE [RS_24]
                                       PartitionCols:_col2
-                                      Merge Join Operator [MERGEJOIN_142] (rows=100578970 width=459)
-                                        Conds:RS_175._col0=RS_157._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                      Merge Join Operator [MERGEJOIN_140] (rows=100578970 width=459)
+                                        Conds:RS_173._col0=RS_155._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
                                       <-Map 14 [SIMPLE_EDGE] vectorized
-                                        PARTITION_ONLY_SHUFFLE [RS_157]
+                                        PARTITION_ONLY_SHUFFLE [RS_155]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_156] (rows=652 width=8)
+                                          Select Operator [SEL_154] (rows=652 width=8)
                                             Output:["_col0"]
-                                            Filter Operator [FIL_155] (rows=652 width=8)
+                                            Filter Operator [FIL_153] (rows=652 width=8)
                                               predicate:((d_year = 2001) and d_date_sk is not null)
                                               TableScan [TS_12] (rows=73049 width=8)
                                                 default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
                                       <-Map 10 [SIMPLE_EDGE] vectorized
-                                        SHUFFLE [RS_175]
+                                        SHUFFLE [RS_173]
                                           PartitionCols:_col0
-                                          Select Operator [SEL_174] (rows=283692098 width=466)
+                                          Select Operator [SEL_172] (rows=283692098 width=466)
                                             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
-                                            Filter Operator [FIL_173] (rows=283692098 width=466)
+                                            Filter Operator [FIL_171] (rows=283692098 width=466)
                                               predicate:((cs_bill_cdemo_sk BETWEEN DynamicValue(RS_25_cd1_cd_demo_sk_min) AND DynamicValue(RS_25_cd1_cd_demo_sk_max) and in_bloom_filter(cs_bill_cdemo_sk, DynamicValue(RS_25_cd1_cd_demo_sk_bloom_filter))) and (cs_bill_customer_sk BETWEEN DynamicValue(RS_37_customer_c_customer_sk_min) AND DynamicValue(RS_37_customer_c_customer_sk_max) and in_bloom_filter(cs_bill_customer_sk, DynamicValue(RS_37_customer_c_customer_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_22_date_dim_d_date_sk_min) AND DynamicValue(RS_22_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_22_date_dim_d_date_sk_bloom_filter))) and cs_bill_cdemo_sk is not null and cs_bill_customer_sk is not null and cs_item_sk is not null and cs_sold_date_sk is not null)
                                               TableScan [TS_9] (rows=287989836 width=466)
                                                 default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_bill_cdemo_sk","cs_item_sk","cs_quantity","cs_list_price","cs_sales_price","cs_coupon_amt","cs_net_profit"]
                                               <-Reducer 15 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_162]
-                                                  Group By Operator [GBY_161] (rows=1 width=12)
+                                                BROADCAST [RS_160]
+                                                  Group By Operator [GBY_159] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 14 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_160]
-                                                      Group By Operator [GBY_159] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_158]
+                                                      Group By Operator [GBY_157] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_158] (rows=652 width=4)
+                                                        Select Operator [SEL_156] (rows=652 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_156]
+                                                           Please refer to the previous Select Operator [SEL_154]
                                               <-Reducer 17 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_170]
-                                                  Group By Operator [GBY_169] (rows=1 width=12)
+                                                BROADCAST [RS_168]
+                                                  Group By Operator [GBY_167] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                   <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                    PARTITION_ONLY_SHUFFLE [RS_168]
-                                                      Group By Operator [GBY_167] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_166]
+                                                      Group By Operator [GBY_165] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                        Select Operator [SEL_166] (rows=103433 width=4)
+                                                        Select Operator [SEL_164] (rows=103433 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Select Operator [SEL_164]
+                                                           Please refer to the previous Select Operator [SEL_162]
                                               <-Reducer 7 [BROADCAST_EDGE] vectorized
-                                                BROADCAST [RS_172]
-                                                  Group By Operator [GBY_171] (rows=1 width=12)
+                                                BROADCAST [RS_170]
+                                                  Group By Operator [GBY_169] (rows=1 width=12)
                                                     Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=4890586)"]
                                                   <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
-                                                    PARTITION_ONLY_SHUFFLE [RS_126]
-                                                      Group By Operator [GBY_125] (rows=1 width=12)
+                                                    PARTITION_ONLY_SHUFFLE [RS_120]
+                                                      Group By Operator [GBY_119] (rows=1 width=12)
                                                         Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=4890586)"]
-                                                        Select Operator [SEL_124] (rows=4959744 width=4)
+                                                        Select Operator [SEL_118] (rows=4959744 width=4)
                                                           Output:["_col0"]
-                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_141]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_139]
 


[22/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out
new file mode 100644
index 0000000..7fbbc05
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out
@@ -0,0 +1,343 @@
+Warning: Shuffle Join MERGEJOIN[287][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain
+with ssales as
+(select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,ca_state
+      ,s_state
+      ,i_color
+      ,i_current_price
+      ,i_manager_id
+      ,i_units
+      ,i_size
+      ,sum(ss_sales_price) netpaid
+from store_sales
+    ,store_returns
+    ,store
+    ,item
+    ,customer
+    ,customer_address
+where ss_ticket_number = sr_ticket_number
+  and ss_item_sk = sr_item_sk
+  and ss_customer_sk = c_customer_sk
+  and ss_item_sk = i_item_sk
+  and ss_store_sk = s_store_sk
+  and c_birth_country = upper(ca_country)
+  and s_zip = ca_zip
+and s_market_id=7
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+        ,ca_state
+        ,s_state
+        ,i_color
+        ,i_current_price
+        ,i_manager_id
+        ,i_units
+        ,i_size)
+select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,sum(netpaid) paid
+from ssales
+where i_color = 'orchid'
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+having sum(netpaid) > (select 0.05*avg(netpaid)
+                                 from ssales)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with ssales as
+(select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,ca_state
+      ,s_state
+      ,i_color
+      ,i_current_price
+      ,i_manager_id
+      ,i_units
+      ,i_size
+      ,sum(ss_sales_price) netpaid
+from store_sales
+    ,store_returns
+    ,store
+    ,item
+    ,customer
+    ,customer_address
+where ss_ticket_number = sr_ticket_number
+  and ss_item_sk = sr_item_sk
+  and ss_customer_sk = c_customer_sk
+  and ss_item_sk = i_item_sk
+  and ss_store_sk = s_store_sk
+  and c_birth_country = upper(ca_country)
+  and s_zip = ca_zip
+and s_market_id=7
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+        ,ca_state
+        ,s_state
+        ,i_color
+        ,i_current_price
+        ,i_manager_id
+        ,i_units
+        ,i_size)
+select c_last_name
+      ,c_first_name
+      ,s_store_name
+      ,sum(netpaid) paid
+from ssales
+where i_color = 'orchid'
+group by c_last_name
+        ,c_first_name
+        ,s_store_name
+having sum(netpaid) > (select 0.05*avg(netpaid)
+                                 from ssales)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Map 24 <- Reducer 20 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Map 9 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
+Reducer 12 <- Map 22 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Map 23 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (SIMPLE_EDGE)
+Reducer 15 <- Reducer 14 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 16 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 19 <- Map 21 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 20 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 16 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 21 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 22 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Map 23 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 15 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 8
+      File Output Operator [FS_88]
+        Select Operator [SEL_87] (rows=78393744 width=380)
+          Output:["_col0","_col1","_col2","_col3"]
+          Filter Operator [FIL_86] (rows=78393744 width=492)
+            predicate:(_col3 > _col4)
+            Merge Join Operator [MERGEJOIN_287] (rows=235181232 width=492)
+              Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4"]
+            <-Reducer 15 [CUSTOM_SIMPLE_EDGE] vectorized
+              PARTITION_ONLY_SHUFFLE [RS_340]
+                Select Operator [SEL_339] (rows=1 width=112)
+                  Output:["_col0"]
+                  Group By Operator [GBY_338] (rows=1 width=120)
+                    Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"]
+                  <-Reducer 14 [CUSTOM_SIMPLE_EDGE] vectorized
+                    PARTITION_ONLY_SHUFFLE [RS_337]
+                      Group By Operator [GBY_336] (rows=1 width=120)
+                        Output:["_col0","_col1"],aggregations:["sum(_col10)","count(_col10)"]
+                        Select Operator [SEL_335] (rows=2121289008973 width=932)
+                          Output:["_col10"]
+                          Group By Operator [GBY_334] (rows=2121289008973 width=932)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8, KEY._col9
+                          <-Reducer 13 [SIMPLE_EDGE]
+                            SHUFFLE [RS_75]
+                              PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9
+                              Group By Operator [GBY_74] (rows=2121289008973 width=932)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col4)"],keys:_col10, _col11, _col6, _col7, _col14, _col15, _col16, _col17, _col18, _col21
+                                Merge Join Operator [MERGEJOIN_286] (rows=2121289008973 width=932)
+                                  Conds:RS_70._col12, _col8=RS_323._col2, _col1(Inner),Output:["_col4","_col6","_col7","_col10","_col11","_col14","_col15","_col16","_col17","_col18","_col21"]
+                                <-Map 23 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_323]
+                                    PartitionCols:_col2, _col1
+                                    Select Operator [SEL_321] (rows=40000000 width=359)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_320] (rows=40000000 width=272)
+                                        predicate:(ca_zip is not null and upper(ca_country) is not null)
+                                        TableScan [TS_14] (rows=40000000 width=272)
+                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_state","ca_zip","ca_country"]
+                                <-Reducer 12 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_70]
+                                    PartitionCols:_col12, _col8
+                                    Merge Join Operator [MERGEJOIN_285] (rows=537799796 width=1023)
+                                      Conds:RS_67._col0, _col3=RS_319._col0, _col1(Inner),Output:["_col4","_col6","_col7","_col8","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col18"]
+                                    <-Map 22 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_319]
+                                        PartitionCols:_col0, _col1
+                                        Select Operator [SEL_317] (rows=57591150 width=8)
+                                          Output:["_col0","_col1"]
+                                          TableScan [TS_12] (rows=57591150 width=8)
+                                            default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number"]
+                                    <-Reducer 11 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_67]
+                                        PartitionCols:_col0, _col3
+                                        Merge Join Operator [MERGEJOIN_284] (rows=385681992 width=1029)
+                                          Conds:RS_64._col0=RS_291._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col8","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col18"]
+                                        <-Map 9 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_291]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_289] (rows=462000 width=384)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              TableScan [TS_3] (rows=462000 width=384)
+                                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_size","i_color","i_units","i_manager_id"]
+                                        <-Reducer 19 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_64]
+                                            PartitionCols:_col0
+                                            Merge Join Operator [MERGEJOIN_283] (rows=385681992 width=648)
+                                              Conds:RS_61._col1=RS_316._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col8","_col10","_col11","_col12"]
+                                            <-Map 21 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_316]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_314] (rows=80000000 width=276)
+                                                  Output:["_col0","_col1","_col2","_col3"]
+                                                  Filter Operator [FIL_313] (rows=80000000 width=276)
+                                                    predicate:c_birth_country is not null
+                                                    TableScan [TS_9] (rows=80000000 width=276)
+                                                      default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_first_name","c_last_name","c_birth_country"]
+                                            <-Reducer 18 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_61]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_282] (rows=385681992 width=379)
+                                                  Conds:RS_333._col2=RS_302._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col6","_col7","_col8"]
+                                                <-Map 16 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_302]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_299] (rows=155 width=267)
+                                                      Output:["_col0","_col1","_col2","_col3"]
+                                                      Filter Operator [FIL_298] (rows=155 width=271)
+                                                        predicate:((s_market_id = 7) and s_zip is not null)
+                                                        TableScan [TS_6] (rows=1704 width=270)
+                                                          default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_market_id","s_state","s_zip"]
+                                                <-Map 24 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_333]
+                                                    PartitionCols:_col2
+                                                    Select Operator [SEL_332] (rows=525333486 width=122)
+                                                      Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                      Filter Operator [FIL_331] (rows=525333486 width=122)
+                                                        predicate:((ss_store_sk BETWEEN DynamicValue(RS_59_store_s_store_sk_min) AND DynamicValue(RS_59_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_59_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_store_sk is not null)
+                                                        TableScan [TS_42] (rows=575995635 width=122)
+                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
+                                                        <-Reducer 20 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_330]
+                                                            Group By Operator [GBY_329] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_307]
+                                                                Group By Operator [GBY_305] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_303] (rows=155 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_299]
+            <-Reducer 7 [CUSTOM_SIMPLE_EDGE] vectorized
+              PARTITION_ONLY_SHUFFLE [RS_328]
+                Select Operator [SEL_327] (rows=235181232 width=380)
+                  Output:["_col0","_col1","_col2","_col3"]
+                  Group By Operator [GBY_326] (rows=235181232 width=380)
+                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col9)"],keys:_col1, _col2, _col7
+                    Select Operator [SEL_325] (rows=365777643230 width=843)
+                      Output:["_col1","_col2","_col7","_col9"]
+                      Group By Operator [GBY_324] (rows=365777643230 width=843)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8
+                      <-Reducer 6 [SIMPLE_EDGE]
+                        SHUFFLE [RS_34]
+                          PartitionCols:_col0, _col1, _col2
+                          Group By Operator [GBY_33] (rows=365777643230 width=843)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(_col4)"],keys:_col15, _col16, _col11, _col20, _col6, _col7, _col8, _col9, _col12
+                            Merge Join Operator [MERGEJOIN_281] (rows=365777643230 width=843)
+                              Conds:RS_29._col13, _col17=RS_322._col1, _col2(Inner),Output:["_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col15","_col16","_col20"]
+                            <-Map 23 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_322]
+                                PartitionCols:_col1, _col2
+                                 Please refer to the previous Select Operator [SEL_321]
+                            <-Reducer 5 [SIMPLE_EDGE]
+                              SHUFFLE [RS_29]
+                                PartitionCols:_col13, _col17
+                                Merge Join Operator [MERGEJOIN_280] (rows=92733777 width=910)
+                                  Conds:RS_26._col0, _col3=RS_318._col0, _col1(Inner),Output:["_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col15","_col16","_col17"]
+                                <-Map 22 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_318]
+                                    PartitionCols:_col0, _col1
+                                     Please refer to the previous Select Operator [SEL_317]
+                                <-Reducer 4 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_26]
+                                    PartitionCols:_col0, _col3
+                                    Merge Join Operator [MERGEJOIN_279] (rows=56246341 width=899)
+                                      Conds:RS_23._col1=RS_315._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col15","_col16","_col17"]
+                                    <-Map 21 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_315]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_314]
+                                    <-Reducer 3 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_23]
+                                        PartitionCols:_col1
+                                        Merge Join Operator [MERGEJOIN_278] (rows=56246341 width=630)
+                                          Conds:RS_20._col2=RS_300._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col13"]
+                                        <-Map 16 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_300]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_299]
+                                        <-Reducer 2 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_20]
+                                            PartitionCols:_col2
+                                            Merge Join Operator [MERGEJOIN_277] (rows=76612563 width=382)
+                                              Conds:RS_312._col0=RS_292._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col6","_col7","_col8","_col9"]
+                                            <-Map 9 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_292]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_290] (rows=7000 width=295)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                  Filter Operator [FIL_288] (rows=7000 width=384)
+                                                    predicate:(i_color = 'orchid')
+                                                     Please refer to the previous TableScan [TS_3]
+                                            <-Map 1 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_312]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_311] (rows=525333486 width=122)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                  Filter Operator [FIL_310] (rows=525333486 width=122)
+                                                    predicate:((ss_item_sk BETWEEN DynamicValue(RS_18_item_i_item_sk_min) AND DynamicValue(RS_18_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_18_item_i_item_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_21_store_s_store_sk_min) AND DynamicValue(RS_21_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_21_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_store_sk is not null)
+                                                    TableScan [TS_0] (rows=575995635 width=122)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
+                                                    <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_297]
+                                                        Group By Operator [GBY_296] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_295]
+                                                            Group By Operator [GBY_294] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_293] (rows=7000 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_290]
+                                                    <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_309]
+                                                        Group By Operator [GBY_308] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_306]
+                                                            Group By Operator [GBY_304] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_301] (rows=155 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_299]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query25.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query25.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query25.q.out
new file mode 100644
index 0000000..a353c6a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query25.q.out
@@ -0,0 +1,321 @@
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 12 (BROADCAST_EDGE), Reducer 13 (BROADCAST_EDGE), Reducer 16 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Map 18 <- Reducer 14 (BROADCAST_EDGE), Reducer 16 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Reducer 10 <- Map 18 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Reducer 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 19 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 11 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 20 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 21 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_259]
+        Limit [LIM_258] (rows=100 width=808)
+          Number of rows:100
+          Select Operator [SEL_257] (rows=4248052806 width=808)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_256]
+              Group By Operator [GBY_255] (rows=4248052806 width=808)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+              <-Reducer 5 [SIMPLE_EDGE]
+                SHUFFLE [RS_47]
+                  PartitionCols:_col0, _col1, _col2, _col3
+                  Group By Operator [GBY_46] (rows=4248052806 width=808)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col5)","sum(_col16)","sum(_col10)"],keys:_col19, _col20, _col22, _col23
+                    Top N Key Operator [TNK_93] (rows=4248052806 width=807)
+                      keys:_col19, _col20, _col22, _col23,sort order:++++,top n:100
+                      Merge Join Operator [MERGEJOIN_212] (rows=4248052806 width=807)
+                        Conds:RS_42._col3=RS_254._col0(Inner),Output:["_col5","_col10","_col16","_col19","_col20","_col22","_col23"]
+                      <-Map 21 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_254]
+                          PartitionCols:_col0
+                          Select Operator [SEL_253] (rows=1704 width=192)
+                            Output:["_col0","_col1","_col2"]
+                            TableScan [TS_31] (rows=1704 width=192)
+                              default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id","s_store_name"]
+                      <-Reducer 4 [SIMPLE_EDGE]
+                        SHUFFLE [RS_42]
+                          PartitionCols:_col3
+                          Merge Join Operator [MERGEJOIN_211] (rows=4248052806 width=623)
+                            Conds:RS_39._col1=RS_252._col0(Inner),Output:["_col3","_col5","_col10","_col16","_col19","_col20"]
+                          <-Map 20 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_252]
+                              PartitionCols:_col0
+                              Select Operator [SEL_251] (rows=462000 width=288)
+                                Output:["_col0","_col1","_col2"]
+                                TableScan [TS_29] (rows=462000 width=288)
+                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_item_desc"]
+                          <-Reducer 3 [SIMPLE_EDGE]
+                            SHUFFLE [RS_39]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_210] (rows=4248052806 width=343)
+                                Conds:RS_36._col1, _col2, _col4=RS_37._col6, _col7, _col8(Inner),Output:["_col1","_col3","_col5","_col10","_col16"]
+                              <-Reducer 11 [SIMPLE_EDGE]
+                                SHUFFLE [RS_37]
+                                  PartitionCols:_col6, _col7, _col8
+                                  Merge Join Operator [MERGEJOIN_209] (rows=1893811716 width=235)
+                                    Conds:RS_25._col2, _col1=RS_26._col1, _col2(Inner),Output:["_col3","_col6","_col7","_col8","_col9"]
+                                  <-Reducer 10 [SIMPLE_EDGE]
+                                    PARTITION_ONLY_SHUFFLE [RS_25]
+                                      PartitionCols:_col2, _col1
+                                      Merge Join Operator [MERGEJOIN_207] (rows=54418158 width=119)
+                                        Conds:RS_243._col0=RS_221._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_221]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_217] (rows=351 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_214] (rows=351 width=12)
+                                              predicate:((d_year = 2000) and d_moy BETWEEN 4 AND 10)
+                                              TableScan [TS_3] (rows=73049 width=12)
+                                                default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                      <-Map 18 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_243]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_242] (rows=285117831 width=123)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_241] (rows=285117831 width=123)
+                                              predicate:((cs_bill_customer_sk BETWEEN DynamicValue(RS_26_store_returns_sr_customer_sk_min) AND DynamicValue(RS_26_store_returns_sr_customer_sk_max) and in_bloom_filter(cs_bill_customer_sk, DynamicValue(RS_26_store_returns_sr_customer_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_26_store_returns_sr_item_sk_min) AND DynamicValue(RS_26_store_returns_sr_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_26_store_returns_sr_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_23_d3_d_date_sk_min) AND DynamicValue(RS_23_d3_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_23_d3_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                              TableScan [TS_6] (rows=287989836 width=123)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_net_profit"]
+                                              <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_235]
+                                                  Group By Operator [GBY_233] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_106]
+                                                      Group By Operator [GBY_105] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_104] (rows=9402909 width=8)
+                                                          Output:["_col0"]
+                                                          Merge Join Operator [MERGEJOIN_208] (rows=9402909 width=100)
+                                                            Conds:RS_232._col0=RS_223._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                          <-Map 8 [SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_223]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_218] (rows=351 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_215] (rows=351 width=12)
+                                                                  predicate:((d_year = 2000) and d_moy BETWEEN 4 AND 10)
+                                                                   Please refer to the previous TableScan [TS_3]
+                                                          <-Map 19 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_232]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_231] (rows=53632139 width=123)
+                                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                                Filter Operator [FIL_230] (rows=53632139 width=123)
+                                                                  predicate:(sr_customer_sk is not null and sr_returned_date_sk is not null)
+                                                                  TableScan [TS_12] (rows=57591150 width=123)
+                                                                    default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number","sr_net_loss"]
+                                              <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_240]
+                                                  Group By Operator [GBY_238] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                    PARTITION_ONLY_SHUFFLE [RS_121]
+                                                      Group By Operator [GBY_120] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_119] (rows=9402909 width=6)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_208]
+                                              <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_237]
+                                                  Group By Operator [GBY_236] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_227]
+                                                      Group By Operator [GBY_225] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_222] (rows=351 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_217]
+                                  <-Reducer 15 [SIMPLE_EDGE]
+                                    PARTITION_ONLY_SHUFFLE [RS_26]
+                                      PartitionCols:_col1, _col2
+                                       Please refer to the previous Merge Join Operator [MERGEJOIN_208]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_36]
+                                  PartitionCols:_col1, _col2, _col4
+                                  Merge Join Operator [MERGEJOIN_206] (rows=13737330 width=8)
+                                    Conds:RS_250._col0=RS_219._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5"]
+                                  <-Map 8 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_219]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_216] (rows=50 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_213] (rows=50 width=12)
+                                          predicate:((d_moy = 4) and (d_year = 2000))
+                                           Please refer to the previous TableScan [TS_3]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_250]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_249] (rows=501694138 width=126)
+                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                        Filter Operator [FIL_248] (rows=501694138 width=126)
+                                          predicate:((ss_customer_sk BETWEEN DynamicValue(RS_25_catalog_sales_cs_bill_customer_sk_min) AND DynamicValue(RS_25_catalog_sales_cs_bill_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_25_catalog_sales_cs_bill_customer_sk_bloom_filter))) and (ss_customer_sk BETWEEN DynamicValue(RS_26_store_returns_sr_customer_sk_min) AND DynamicValue(RS_26_store_returns_sr_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_26_store_returns_sr_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_25_catalog_sales_cs_item_sk_min) AND DynamicValue(RS_25_catalog_sales_cs_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_25_catalog_sales_cs_item_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_26_store_returns_sr_item_sk_min) AND DynamicValue(RS_26_store_returns_sr_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_26_store_returns_sr_item_sk_bloom_filter))) and (ss_sold_date_sk 
 BETWEEN DynamicValue(RS_34_d1_d_date_sk_min) AND DynamicValue(RS_34_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_34_d1_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                          TableScan [TS_0] (rows=575995635 width=126)
+                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_net_profit"]
+                                          <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_234]
+                                               Please refer to the previous Group By Operator [GBY_233]
+                                          <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_239]
+                                               Please refer to the previous Group By Operator [GBY_238]
+                                          <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_245]
+                                              Group By Operator [GBY_244] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_111]
+                                                  Group By Operator [GBY_110] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_109] (rows=54418158 width=8)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Merge Join Operator [MERGEJOIN_207]
+                                          <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_247]
+                                              Group By Operator [GBY_246] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Reducer 10 [CUSTOM_SIMPLE_EDGE]
+                                                PARTITION_ONLY_SHUFFLE [RS_126]
+                                                  Group By Operator [GBY_125] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_124] (rows=54418158 width=7)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Merge Join Operator [MERGEJOIN_207]
+                                          <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_229]
+                                              Group By Operator [GBY_228] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_226]
+                                                  Group By Operator [GBY_224] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_220] (rows=50 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_216]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query26.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query26.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query26.q.out
new file mode 100644
index 0000000..ed032b1
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query26.q.out
@@ -0,0 +1,171 @@
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 12 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 13 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_128]
+        Limit [LIM_127] (rows=100 width=444)
+          Number of rows:100
+          Select Operator [SEL_126] (rows=310774 width=444)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_125]
+              Select Operator [SEL_124] (rows=310774 width=444)
+                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Group By Operator [GBY_123] (rows=310774 width=476)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","sum(VALUE._col6)","count(VALUE._col7)"],keys:KEY._col0
+                <-Reducer 5 [SIMPLE_EDGE]
+                  SHUFFLE [RS_28]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_27] (rows=462000 width=476)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(_col4)","count(_col4)","sum(_col5)","count(_col5)","sum(_col7)","count(_col7)","sum(_col6)","count(_col6)"],keys:_col12
+                      Top N Key Operator [TNK_54] (rows=809521 width=100)
+                        keys:_col12,sort order:+,top n:100
+                        Merge Join Operator [MERGEJOIN_98] (rows=809521 width=100)
+                          Conds:RS_23._col2=RS_122._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col12"]
+                        <-Map 13 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_122]
+                            PartitionCols:_col0
+                            Select Operator [SEL_121] (rows=462000 width=104)
+                              Output:["_col0","_col1"]
+                              TableScan [TS_12] (rows=462000 width=104)
+                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                        <-Reducer 4 [SIMPLE_EDGE]
+                          SHUFFLE [RS_23]
+                            PartitionCols:_col2
+                            Merge Join Operator [MERGEJOIN_97] (rows=809521 width=4)
+                              Conds:RS_20._col3=RS_120._col0(Inner),Output:["_col2","_col4","_col5","_col6","_col7"]
+                            <-Map 12 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_120]
+                                PartitionCols:_col0
+                                Select Operator [SEL_119] (rows=2300 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_118] (rows=2300 width=174)
+                                    predicate:((p_channel_email = 'N') or (p_channel_event = 'N'))
+                                    TableScan [TS_9] (rows=2300 width=174)
+                                      default@promotion,promotion,Tbl:COMPLETE,Col:COMPLETE,Output:["p_promo_sk","p_channel_email","p_channel_event"]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_20]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_96] (rows=809521 width=4)
+                                  Conds:RS_17._col0=RS_109._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col7"]
+                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_109]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_108] (rows=652 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_107] (rows=652 width=8)
+                                        predicate:(d_year = 1998)
+                                        TableScan [TS_6] (rows=73049 width=8)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_17]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_95] (rows=2283326 width=135)
+                                      Conds:RS_117._col1=RS_101._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_101]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_100] (rows=14776 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_99] (rows=14776 width=268)
+                                            predicate:((cd_education_status = 'Primary') and (cd_gender = 'F') and (cd_marital_status = 'W'))
+                                            TableScan [TS_3] (rows=1861800 width=268)
+                                              default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_117]
+                                        PartitionCols:_col1
+                                        Select Operator [SEL_116] (rows=283691050 width=354)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                          Filter Operator [FIL_115] (rows=283691050 width=354)
+                                            predicate:((cs_bill_cdemo_sk BETWEEN DynamicValue(RS_15_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_15_customer_demographics_cd_demo_sk_max) and in_bloom_filter(cs_bill_cdemo_sk, DynamicValue(RS_15_customer_demographics_cd_demo_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_18_date_dim_d_date_sk_min) AND DynamicValue(RS_18_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_18_date_dim_d_date_sk_bloom_filter))) and cs_bill_cdemo_sk is not null and cs_promo_sk is not null and cs_sold_date_sk is not null)
+                                            TableScan [TS_0] (rows=287989836 width=354)
+                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_cdemo_sk","cs_item_sk","cs_promo_sk","cs_quantity","cs_list_price","cs_sales_price","cs_coupon_amt"]
+                                            <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_114]
+                                                Group By Operator [GBY_113] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_112]
+                                                    Group By Operator [GBY_111] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_110] (rows=652 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_108]
+                                            <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_106]
+                                                Group By Operator [GBY_105] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_104]
+                                                    Group By Operator [GBY_103] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_102] (rows=14776 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_100]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out
new file mode 100644
index 0000000..fdc1791
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query27.q.out
@@ -0,0 +1,189 @@
+PREHOOK: query: explain
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE), Reducer 13 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 12 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 14 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_134]
+        Limit [LIM_133] (rows=100 width=538)
+          Number of rows:100
+          Select Operator [SEL_132] (rows=4281825 width=538)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_131]
+              Select Operator [SEL_130] (rows=4281825 width=538)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                Group By Operator [GBY_129] (rows=4281825 width=570)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","sum(VALUE._col6)","count(VALUE._col7)"],keys:KEY._col0, KEY._col1, KEY._col2
+                <-Reducer 5 [SIMPLE_EDGE]
+                  SHUFFLE [RS_29]
+                    PartitionCols:_col0, _col1, _col2
+                    Group By Operator [GBY_28] (rows=4281825 width=570)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col2)","count(_col2)","sum(_col3)","count(_col3)","sum(_col4)","count(_col4)","sum(_col5)","count(_col5)"],keys:_col0, _col1, 0L
+                      Top N Key Operator [TNK_55] (rows=1427275 width=186)
+                        keys:_col0, _col1, 0L,sort order:+++,top n:100
+                        Select Operator [SEL_26] (rows=1427275 width=186)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          Merge Join Operator [MERGEJOIN_99] (rows=1427275 width=186)
+                            Conds:RS_23._col1=RS_128._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col11","_col13"]
+                          <-Map 14 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_128]
+                              PartitionCols:_col0
+                              Select Operator [SEL_127] (rows=462000 width=104)
+                                Output:["_col0","_col1"]
+                                TableScan [TS_12] (rows=462000 width=104)
+                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                          <-Reducer 4 [SIMPLE_EDGE]
+                            SHUFFLE [RS_23]
+                              PartitionCols:_col1
+                              Merge Join Operator [MERGEJOIN_98] (rows=1427275 width=90)
+                                Conds:RS_20._col3=RS_118._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col11"]
+                              <-Map 12 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_118]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_117] (rows=209 width=90)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_116] (rows=209 width=90)
+                                      predicate:(s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC')
+                                      TableScan [TS_9] (rows=1704 width=90)
+                                        default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
+                              <-Reducer 3 [SIMPLE_EDGE]
+                                SHUFFLE [RS_20]
+                                  PartitionCols:_col3
+                                  Merge Join Operator [MERGEJOIN_97] (rows=1441779 width=4)
+                                    Conds:RS_17._col0=RS_110._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                                  <-Map 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_110]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_109] (rows=652 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_108] (rows=652 width=8)
+                                          predicate:(d_year = 2001)
+                                          TableScan [TS_6] (rows=73049 width=8)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                  <-Reducer 2 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_17]
+                                      PartitionCols:_col0
+                                      Merge Join Operator [MERGEJOIN_96] (rows=4037920 width=4)
+                                        Conds:RS_126._col2=RS_102._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_102]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_101] (rows=14776 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_100] (rows=14776 width=268)
+                                              predicate:((cd_education_status = '2 yr Degree') and (cd_gender = 'M') and (cd_marital_status = 'U'))
+                                              TableScan [TS_3] (rows=1861800 width=268)
+                                                default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_126]
+                                          PartitionCols:_col2
+                                          Select Operator [SEL_125] (rows=501690006 width=340)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                            Filter Operator [FIL_124] (rows=501690006 width=340)
+                                              predicate:((ss_cdemo_sk BETWEEN DynamicValue(RS_15_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_15_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_15_customer_demographics_cd_demo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_18_date_dim_d_date_sk_min) AND DynamicValue(RS_18_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_18_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_21_store_s_store_sk_min) AND DynamicValue(RS_21_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_21_store_s_store_sk_bloom_filter))) and ss_cdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                              TableScan [TS_0] (rows=575995635 width=340)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_store_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
+                                              <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_115]
+                                                  Group By Operator [GBY_114] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_113]
+                                                      Group By Operator [GBY_112] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_111] (rows=652 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_109]
+                                              <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_123]
+                                                  Group By Operator [GBY_122] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_121]
+                                                      Group By Operator [GBY_120] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_119] (rows=209 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_117]
+                                              <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_107]
+                                                  Group By Operator [GBY_106] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_105]
+                                                      Group By Operator [GBY_104] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_103] (rows=14776 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_101]
+


[58/75] [abbrv] hive git commit: HIVE-20542: Incremental REPL DUMP progress information log message is incorrect (Ashutosh Bapat, reviewed by Sankar Hariappan)

Posted by se...@apache.org.
HIVE-20542: Incremental REPL DUMP progress information log message is incorrect (Ashutosh Bapat, reviewed by Sankar Hariappan)

Signed-off-by: Sankar Hariappan <sa...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0d4d03fd
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0d4d03fd
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0d4d03fd

Branch: refs/heads/master-tez092
Commit: 0d4d03fd1daeb3b75182b73f7b40de7a3b7d48ea
Parents: 7765e90
Author: Ashutosh Bapat <ab...@hortonworks.com>
Authored: Tue Oct 23 17:56:47 2018 +0530
Committer: Sankar Hariappan <sa...@apache.org>
Committed: Tue Oct 23 17:56:47 2018 +0530

----------------------------------------------------------------------
 .../listener/DbNotificationListener.java        |  75 ++++++-
 .../listener/TestDbNotificationListener.java    |  59 ++++++
 .../TestReplicationScenariosAcidTables.java     |   6 +-
 .../hadoop/hive/ql/parse/WarehouseInstance.java |  17 ++
 .../hadoop/hive/ql/exec/repl/ReplDumpTask.java  |   9 +-
 .../hive/ql/metadata/events/EventUtils.java     |  16 +-
 .../api/NotificationEventsCountRequest.java     | 206 ++++++++++++++++++-
 .../src/gen/thrift/gen-php/metastore/Types.php  |  46 +++++
 .../gen/thrift/gen-py/hive_metastore/ttypes.py  |  28 ++-
 .../gen/thrift/gen-rb/hive_metastore_types.rb   |   6 +-
 .../src/main/thrift/hive_metastore.thrift       |   4 +-
 .../hadoop/hive/metastore/ObjectStore.java      |  58 +++++-
 .../hadoop/hive/metastore/txn/TxnHandler.java   |   2 +-
 13 files changed, 503 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
----------------------------------------------------------------------
diff --git a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
index c23aab2..fe101d3 100644
--- a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
+++ b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
@@ -24,6 +24,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -939,19 +940,71 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
       long nextNLId = getNextNLId(stmt, sqlGenerator,
               "org.apache.hadoop.hive.metastore.model.MNotificationLog");
 
-      String insertVal = "(" + nextNLId + "," + nextEventId + "," + now() + ", ?, ?," +
-              quoteString(" ") + ",?, ?)";
+      String insertVal;
+      String columns;
+      List<String> params = new ArrayList<String>();
+
+      // Construct the values string, parameters and column string step by step simultaneously so
+      // that the positions of columns and of their corresponding values do not go out of sync.
+
+      // Notification log id
+      columns = "\"NL_ID\"";
+      insertVal = "" + nextNLId;
+
+      // Event id
+      columns = columns + ", \"EVENT_ID\"";
+      insertVal = insertVal + "," + nextEventId;
+
+      // Event time
+      columns = columns + ", \"EVENT_TIME\"";
+      insertVal = insertVal + "," + now();
+
+      // Event type
+      columns = columns + ", \"EVENT_TYPE\"";
+      insertVal = insertVal + ", ?";
+      params.add(event.getEventType());
+
+      // Message
+      columns = columns + ", \"MESSAGE\"";
+      insertVal = insertVal + ", ?";
+      params.add(event.getMessage());
+
+      // Message format
+      columns = columns + ", \"MESSAGE_FORMAT\"";
+      insertVal = insertVal + ", ?";
+      params.add(event.getMessageFormat());
+
+      // Database name, optional
+      String dbName = event.getDbName();
+      if (dbName != null) {
+        assert dbName.equals(dbName.toLowerCase());
+        columns = columns + ", \"DB_NAME\"";
+        insertVal = insertVal + ", ?";
+        params.add(dbName);
+      }
 
-      s = "insert into \"NOTIFICATION_LOG\" (\"NL_ID\", \"EVENT_ID\", \"EVENT_TIME\", " +
-              " \"EVENT_TYPE\", \"DB_NAME\", " +
-              " \"TBL_NAME\", \"MESSAGE\", \"MESSAGE_FORMAT\") VALUES " + insertVal;
-      List<String> params = Arrays.asList(
-              event.getEventType(), event.getDbName(), event.getMessage(), event.getMessageFormat());
-      pst = sqlGenerator.prepareStmtWithParameters(dbConn, s, params);
+      // Table name, optional
+      String tableName = event.getTableName();
+      if (tableName != null) {
+        assert tableName.equals(tableName.toLowerCase());
+        columns = columns + ", \"TBL_NAME\"";
+        insertVal = insertVal + ", ?";
+        params.add(tableName);
+      }
 
-      LOG.debug("Going to execute insert <" + s.replaceAll("\\?", "{}") + ">",
-              quoteString(event.getEventType()), quoteString(event.getDbName()),
-              quoteString(event.getMessage()), quoteString(event.getMessageFormat()));
+      // Catalog name, optional
+      String catName = event.getCatName();
+      if (catName != null) {
+        assert catName.equals(catName.toLowerCase());
+        columns = columns + ", \"CAT_NAME\"";
+        insertVal = insertVal + ", ?";
+        params.add(catName);
+      }
+
+      s = "insert into \"NOTIFICATION_LOG\" (" + columns + ") VALUES (" + insertVal + ")";
+      pst = sqlGenerator.prepareStmtWithParameters(dbConn, s, params);
+      LOG.debug("Going to execute insert <" + s + "> with parameters (" +
+              String.join(", ", params) + ")");
       pst.execute();
 
       // Set the DB_NOTIFICATION_EVENT_ID for future reference by other listeners.

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
----------------------------------------------------------------------
diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
index dc555a4..3e404df 100644
--- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
+++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
@@ -54,6 +54,7 @@ import org.apache.hadoop.hive.metastore.api.InsertEventRequestData;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
 import org.apache.hadoop.hive.metastore.api.NotificationEventResponse;
+import org.apache.hadoop.hive.metastore.api.NotificationEventsCountRequest;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.api.ResourceType;
@@ -300,6 +301,21 @@ public class TestDbNotificationListener {
     MockMetaStoreEventListener.clearEvents();
   }
 
+  // Test if the number of events between the given event ids and with the given database name are
+  // same as expected. toEventId = 0 is treated as unbounded. Same is the case with limit 0.
+  private void testEventCounts(String dbName, long fromEventId, Long toEventId, Integer limit,
+                               long expectedCount) throws Exception {
+    NotificationEventsCountRequest rqst = new NotificationEventsCountRequest(fromEventId, dbName);
+
+    if (toEventId != null) {
+      rqst.setToEventId(toEventId);
+    }
+    if (limit != null) {
+      rqst.setLimit(limit);
+    }
+
+    assertEquals(expectedCount, msClient.getNotificationEventsCount(rqst).getEventsCount());
+  }
 
   @Test
   public void createDatabase() throws Exception {
@@ -341,6 +357,10 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(1, rsp.getEventsSize());
+
+    // There's only one event corresponding to CREATE DATABASE
+    testEventCounts(dbName, firstEventId, null, null, 1);
+    testEventCounts(dbName2, firstEventId, null, null, 0);
   }
 
   @Test
@@ -358,6 +378,7 @@ public class TestDbNotificationListener {
 
     // Two events: one for create db and other for drop db
     assertEquals(2, rsp.getEventsSize());
+    testEventCounts(dbName, firstEventId, null, null, 2);
 
     // Read event from notification
     NotificationEvent event = rsp.getEvents().get(1);
@@ -388,6 +409,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(3, rsp.getEventsSize());
+    testEventCounts(dbName2, firstEventId, null, null, 1);
   }
 
   @Test
@@ -443,6 +465,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(1, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 1);
   }
 
   @Test
@@ -501,6 +524,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(2, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 2);
   }
 
   @Test
@@ -567,6 +591,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(3, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 3);
   }
 
   @Test
@@ -636,6 +661,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(2, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 2);
   }
 
   @Test
@@ -704,6 +730,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(3, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 3);
   }
 
   @Test
@@ -778,6 +805,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(4, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 4);
   }
 
   @Test
@@ -873,6 +901,7 @@ public class TestDbNotificationListener {
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.ADD_PARTITION, firstEventId + 3);
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_TABLE, firstEventId + 2);
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_TABLE, firstEventId + 1);
+    testEventCounts(dbName, firstEventId, null, null, 5);
   }
 
   @Test
@@ -931,6 +960,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(1, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 1);
   }
 
   @Test
@@ -985,6 +1015,7 @@ public class TestDbNotificationListener {
     }
     rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(3, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 3);
   }
 
   @Test
@@ -1040,6 +1071,7 @@ public class TestDbNotificationListener {
     // Verify the eventID was passed to the non-transactional listener
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.INSERT, firstEventId + 2);
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_TABLE, firstEventId + 1);
+    testEventCounts(defaultDbName, firstEventId, null, null, 2);
   }
 
   @Test
@@ -1106,6 +1138,7 @@ public class TestDbNotificationListener {
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.INSERT, firstEventId + 3);
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.ADD_PARTITION, firstEventId + 2);
     MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_TABLE, firstEventId + 1);
+    testEventCounts(defaultDbName, firstEventId, null, null, 3);
   }
 
 
@@ -1200,10 +1233,12 @@ public class TestDbNotificationListener {
     event = rsp.getEvents().get(5);
     assertEquals(firstEventId + 6, event.getEventId());
     assertEquals(EventType.DROP_TABLE.toString(), event.getEventType());
+    testEventCounts(defaultDbName, firstEventId, null, null, 6);
   }
 
   @Test
   public void sqlCTAS() throws Exception {
+    String defaultDbName = "default";
     String sourceTblName = "sqlctasins1";
     String targetTblName = "sqlctasins2";
     // Event 1
@@ -1229,10 +1264,12 @@ public class TestDbNotificationListener {
     event = rsp.getEvents().get(4);
     assertEquals(firstEventId + 5, event.getEventId());
     assertEquals(EventType.CREATE_TABLE.toString(), event.getEventType());
+    testEventCounts(defaultDbName, firstEventId, null, null, 6);
   }
 
   @Test
   public void sqlTempTable() throws Exception {
+    String defaultDbName = "default";
     String tempTblName = "sqltemptbl";
     driver.run("create temporary table " + tempTblName + "  (c int)");
     driver.run("insert into table " + tempTblName + " values (1)");
@@ -1240,6 +1277,7 @@ public class TestDbNotificationListener {
     // Get notifications from metastore
     NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(0, rsp.getEventsSize());
+    testEventCounts(defaultDbName, firstEventId, null, null, 0);
   }
 
   @Test
@@ -1263,6 +1301,7 @@ public class TestDbNotificationListener {
 
   @Test
   public void sqlInsertPartition() throws Exception {
+    String defaultDbName = "default";
     String tblName = "sqlinsptn";
     // Event 1
     driver.run("create table " + tblName + " (c int) partitioned by (ds string)");
@@ -1274,6 +1313,13 @@ public class TestDbNotificationListener {
     driver.run("insert into table " + tblName + " partition (ds) values (3, 'today')");
     // Event 9, 10
     driver.run("alter table " + tblName + " add partition (ds = 'yesterday')");
+
+    testEventCounts(defaultDbName, firstEventId, null, null, 10);
+    // Test a limit higher than available events
+    testEventCounts(defaultDbName, firstEventId, null, 100, 10);
+    // Test toEventId lower than current eventId
+    testEventCounts(defaultDbName, firstEventId, (long) firstEventId + 5, null, 5);
+
     // Event 10, 11, 12
     driver.run("insert into table " + tblName + " partition (ds = 'yesterday') values (2)");
     // Event 12, 13, 14
@@ -1340,6 +1386,9 @@ public class TestDbNotificationListener {
     assertEquals(EventType.ALTER_PARTITION.toString(), event.getEventType());
     assertTrue(event.getMessage().matches(".*\"ds\":\"todaytwo\".*"));
 
+    // Test fromEventId different from the very first
+    testEventCounts(defaultDbName, event.getEventId(), null, null, 3);
+
     event = rsp.getEvents().get(21);
     assertEquals(firstEventId + 22, event.getEventId());
     assertEquals(EventType.INSERT.toString(), event.getEventType());
@@ -1355,6 +1404,16 @@ public class TestDbNotificationListener {
     assertEquals(firstEventId + 24, event.getEventId());
     assertEquals(EventType.ALTER_PARTITION.toString(), event.getEventType());
     assertTrue(event.getMessage().matches(".*\"ds\":\"todaytwo\".*"));
+    testEventCounts(defaultDbName, firstEventId, null, null, 24);
+
+    // Test a limit within the available events
+    testEventCounts(defaultDbName, firstEventId, null, 10, 10);
+    // Test toEventId greater than current eventId
+    testEventCounts(defaultDbName, firstEventId, (long) firstEventId + 100, null, 24);
+    // Test toEventId greater than current eventId with some limit within available events
+    testEventCounts(defaultDbName, firstEventId, (long) firstEventId + 100, 10, 10);
+    // Test toEventId greater than current eventId with some limit beyond available events
+    testEventCounts(defaultDbName, firstEventId, (long) firstEventId + 100, 50, 24);
   }
 
   private void verifyInsert(NotificationEvent event, String dbName, String tblName) throws Exception {

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
index 4ceb9fa..af65d6a 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
@@ -482,7 +482,6 @@ public class TestReplicationScenariosAcidTables {
             .run("REPL STATUS " + replicatedDbName)
             .verifyResult(bootStrapDump.lastReplicationId);
 
-    // create table will start and coomit the transaction
     primary.run("use " + primaryDbName)
            .run("CREATE TABLE " + tableName +
             " (key int, value int) PARTITIONED BY (load_date date) " +
@@ -495,6 +494,11 @@ public class TestReplicationScenariosAcidTables {
 
     WarehouseInstance.Tuple incrementalDump =
             primary.dump(primaryDbName, bootStrapDump.lastReplicationId);
+
+    long lastReplId = Long.parseLong(bootStrapDump.lastReplicationId);
+    primary.testEventCounts(primaryDbName, lastReplId, null, null, 20);
+
+    // Test load
     replica.load(replicatedDbName, incrementalDump.dumpLocation)
             .run("REPL STATUS " + replicatedDbName)
             .verifyResult(incrementalDump.lastReplicationId);

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
index aae7bd7..7900779 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.ForeignKeysRequest;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.NotNullConstraintsRequest;
+import org.apache.hadoop.hive.metastore.api.NotificationEventsCountRequest;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.PrimaryKeysRequest;
 import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
@@ -416,6 +417,22 @@ public class WarehouseInstance implements Closeable {
     return new ReplicationV1CompatRule(client, hiveConf, testsToSkip);
   }
 
+  // Test if the number of events between the given event ids and with the given database name are
+  // same as expected. toEventId = 0 is treated as unbounded. Same is the case with limit 0.
+  public void testEventCounts(String dbName, long fromEventId, Long toEventId, Integer limit,
+                               long expectedCount) throws Exception {
+    NotificationEventsCountRequest rqst = new NotificationEventsCountRequest(fromEventId, dbName);
+
+    if (toEventId != null) {
+      rqst.setToEventId(toEventId);
+    }
+    if (limit != null) {
+      rqst.setLimit(limit);
+    }
+
+    assertEquals(expectedCount, client.getNotificationEventsCount(rqst).getEventsCount());
+  }
+
   @Override
   public void close() throws IOException {
     if (miniDFSCluster != null && miniDFSCluster.isClusterUp()) {

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
index c75bde5..28d61f9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
@@ -163,11 +163,18 @@ public class ReplDumpTask extends Task<ReplDumpWork> implements Serializable {
         evFetcher, work.eventFrom, work.maxEventLimit(), evFilter);
 
     lastReplId = work.eventTo;
+
+    // Right now the only pattern allowed to be specified is *, which matches all the database
+    // names. So passing dbname as is works since getDbNotificationEventsCount can exclude filter
+    // on database name when it's *. In future, if we support more elaborate patterns, we will
+    // have to pass DatabaseAndTableFilter created above to getDbNotificationEventsCount() to get
+    // correct event count.
     String dbName = (null != work.dbNameOrPattern && !work.dbNameOrPattern.isEmpty())
         ? work.dbNameOrPattern
         : "?";
     replLogger = new IncrementalDumpLogger(dbName, dumpRoot.toString(),
-            evFetcher.getDbNotificationEventsCount(work.eventFrom, dbName));
+            evFetcher.getDbNotificationEventsCount(work.eventFrom, dbName, work.eventTo,
+                    work.maxEventLimit()));
     replLogger.startLog();
     while (evIter.hasNext()) {
       NotificationEvent ev = evIter.next();

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/ql/src/java/org/apache/hadoop/hive/ql/metadata/events/EventUtils.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/events/EventUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/events/EventUtils.java
index 66abd51..f925271 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/events/EventUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/events/EventUtils.java
@@ -36,7 +36,8 @@ public class EventUtils {
   public interface NotificationFetcher {
     int getBatchSize() throws IOException;
     long getCurrentNotificationEventId() throws IOException;
-    long getDbNotificationEventsCount(long fromEventId, String dbName) throws IOException;
+    long getDbNotificationEventsCount(long fromEventId, String dbName, Long toEventId,
+                                      int limit) throws IOException;
     List<NotificationEvent> getNextNotificationEvents(
         long pos, IMetaStoreClient.NotificationFilter filter) throws IOException;
   }
@@ -78,10 +79,21 @@ public class EventUtils {
     }
 
     @Override
-    public long getDbNotificationEventsCount(long fromEventId, String dbName) throws IOException {
+    public long getDbNotificationEventsCount(long fromEventId, String dbName, Long toEventId,
+                                             int limit) throws IOException {
       try {
+        // Number of events is always bounded by limit, which when non-positive, will result
+        // in no events being counted..
+        if (limit <= 0) {
+          return 0;
+        }
+
         NotificationEventsCountRequest rqst
                 = new NotificationEventsCountRequest(fromEventId, dbName);
+        if (toEventId != null) {
+          rqst.setToEventId(toEventId);
+        }
+        rqst.setLimit(limit);
         return hiveDb.getMSC().getNotificationEventsCount(rqst).getEventsCount();
       } catch (TException e) {
         throw new IOException(e);

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/NotificationEventsCountRequest.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/NotificationEventsCountRequest.java b/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/NotificationEventsCountRequest.java
index a4a5218..95af1a4 100644
--- a/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/NotificationEventsCountRequest.java
+++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/NotificationEventsCountRequest.java
@@ -41,6 +41,8 @@ import org.slf4j.LoggerFactory;
   private static final org.apache.thrift.protocol.TField FROM_EVENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("fromEventId", org.apache.thrift.protocol.TType.I64, (short)1);
   private static final org.apache.thrift.protocol.TField DB_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("dbName", org.apache.thrift.protocol.TType.STRING, (short)2);
   private static final org.apache.thrift.protocol.TField CAT_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("catName", org.apache.thrift.protocol.TType.STRING, (short)3);
+  private static final org.apache.thrift.protocol.TField TO_EVENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("toEventId", org.apache.thrift.protocol.TType.I64, (short)4);
+  private static final org.apache.thrift.protocol.TField LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("limit", org.apache.thrift.protocol.TType.I64, (short)5);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -51,12 +53,16 @@ import org.slf4j.LoggerFactory;
   private long fromEventId; // required
   private String dbName; // required
   private String catName; // optional
+  private long toEventId; // optional
+  private long limit; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
     FROM_EVENT_ID((short)1, "fromEventId"),
     DB_NAME((short)2, "dbName"),
-    CAT_NAME((short)3, "catName");
+    CAT_NAME((short)3, "catName"),
+    TO_EVENT_ID((short)4, "toEventId"),
+    LIMIT((short)5, "limit");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -77,6 +83,10 @@ import org.slf4j.LoggerFactory;
           return DB_NAME;
         case 3: // CAT_NAME
           return CAT_NAME;
+        case 4: // TO_EVENT_ID
+          return TO_EVENT_ID;
+        case 5: // LIMIT
+          return LIMIT;
         default:
           return null;
       }
@@ -118,8 +128,10 @@ import org.slf4j.LoggerFactory;
 
   // isset id assignments
   private static final int __FROMEVENTID_ISSET_ID = 0;
+  private static final int __TOEVENTID_ISSET_ID = 1;
+  private static final int __LIMIT_ISSET_ID = 2;
   private byte __isset_bitfield = 0;
-  private static final _Fields optionals[] = {_Fields.CAT_NAME};
+  private static final _Fields optionals[] = {_Fields.CAT_NAME,_Fields.TO_EVENT_ID,_Fields.LIMIT};
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
   static {
     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -129,6 +141,10 @@ import org.slf4j.LoggerFactory;
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     tmpMap.put(_Fields.CAT_NAME, new org.apache.thrift.meta_data.FieldMetaData("catName", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.TO_EVENT_ID, new org.apache.thrift.meta_data.FieldMetaData("toEventId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.LIMIT, new org.apache.thrift.meta_data.FieldMetaData("limit", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(NotificationEventsCountRequest.class, metaDataMap);
   }
@@ -158,6 +174,8 @@ import org.slf4j.LoggerFactory;
     if (other.isSetCatName()) {
       this.catName = other.catName;
     }
+    this.toEventId = other.toEventId;
+    this.limit = other.limit;
   }
 
   public NotificationEventsCountRequest deepCopy() {
@@ -170,6 +188,10 @@ import org.slf4j.LoggerFactory;
     this.fromEventId = 0;
     this.dbName = null;
     this.catName = null;
+    setToEventIdIsSet(false);
+    this.toEventId = 0;
+    setLimitIsSet(false);
+    this.limit = 0;
   }
 
   public long getFromEventId() {
@@ -240,6 +262,50 @@ import org.slf4j.LoggerFactory;
     }
   }
 
+  public long getToEventId() {
+    return this.toEventId;
+  }
+
+  public void setToEventId(long toEventId) {
+    this.toEventId = toEventId;
+    setToEventIdIsSet(true);
+  }
+
+  public void unsetToEventId() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TOEVENTID_ISSET_ID);
+  }
+
+  /** Returns true if field toEventId is set (has been assigned a value) and false otherwise */
+  public boolean isSetToEventId() {
+    return EncodingUtils.testBit(__isset_bitfield, __TOEVENTID_ISSET_ID);
+  }
+
+  public void setToEventIdIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TOEVENTID_ISSET_ID, value);
+  }
+
+  public long getLimit() {
+    return this.limit;
+  }
+
+  public void setLimit(long limit) {
+    this.limit = limit;
+    setLimitIsSet(true);
+  }
+
+  public void unsetLimit() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __LIMIT_ISSET_ID);
+  }
+
+  /** Returns true if field limit is set (has been assigned a value) and false otherwise */
+  public boolean isSetLimit() {
+    return EncodingUtils.testBit(__isset_bitfield, __LIMIT_ISSET_ID);
+  }
+
+  public void setLimitIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __LIMIT_ISSET_ID, value);
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case FROM_EVENT_ID:
@@ -266,6 +332,22 @@ import org.slf4j.LoggerFactory;
       }
       break;
 
+    case TO_EVENT_ID:
+      if (value == null) {
+        unsetToEventId();
+      } else {
+        setToEventId((Long)value);
+      }
+      break;
+
+    case LIMIT:
+      if (value == null) {
+        unsetLimit();
+      } else {
+        setLimit((Long)value);
+      }
+      break;
+
     }
   }
 
@@ -280,6 +362,12 @@ import org.slf4j.LoggerFactory;
     case CAT_NAME:
       return getCatName();
 
+    case TO_EVENT_ID:
+      return getToEventId();
+
+    case LIMIT:
+      return getLimit();
+
     }
     throw new IllegalStateException();
   }
@@ -297,6 +385,10 @@ import org.slf4j.LoggerFactory;
       return isSetDbName();
     case CAT_NAME:
       return isSetCatName();
+    case TO_EVENT_ID:
+      return isSetToEventId();
+    case LIMIT:
+      return isSetLimit();
     }
     throw new IllegalStateException();
   }
@@ -341,6 +433,24 @@ import org.slf4j.LoggerFactory;
         return false;
     }
 
+    boolean this_present_toEventId = true && this.isSetToEventId();
+    boolean that_present_toEventId = true && that.isSetToEventId();
+    if (this_present_toEventId || that_present_toEventId) {
+      if (!(this_present_toEventId && that_present_toEventId))
+        return false;
+      if (this.toEventId != that.toEventId)
+        return false;
+    }
+
+    boolean this_present_limit = true && this.isSetLimit();
+    boolean that_present_limit = true && that.isSetLimit();
+    if (this_present_limit || that_present_limit) {
+      if (!(this_present_limit && that_present_limit))
+        return false;
+      if (this.limit != that.limit)
+        return false;
+    }
+
     return true;
   }
 
@@ -363,6 +473,16 @@ import org.slf4j.LoggerFactory;
     if (present_catName)
       list.add(catName);
 
+    boolean present_toEventId = true && (isSetToEventId());
+    list.add(present_toEventId);
+    if (present_toEventId)
+      list.add(toEventId);
+
+    boolean present_limit = true && (isSetLimit());
+    list.add(present_limit);
+    if (present_limit)
+      list.add(limit);
+
     return list.hashCode();
   }
 
@@ -404,6 +524,26 @@ import org.slf4j.LoggerFactory;
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetToEventId()).compareTo(other.isSetToEventId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetToEventId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.toEventId, other.toEventId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLimit()).compareTo(other.isSetLimit());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLimit()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.limit, other.limit);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -445,6 +585,18 @@ import org.slf4j.LoggerFactory;
       }
       first = false;
     }
+    if (isSetToEventId()) {
+      if (!first) sb.append(", ");
+      sb.append("toEventId:");
+      sb.append(this.toEventId);
+      first = false;
+    }
+    if (isSetLimit()) {
+      if (!first) sb.append(", ");
+      sb.append("limit:");
+      sb.append(this.limit);
+      first = false;
+    }
     sb.append(")");
     return sb.toString();
   }
@@ -522,6 +674,22 @@ import org.slf4j.LoggerFactory;
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 4: // TO_EVENT_ID
+            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+              struct.toEventId = iprot.readI64();
+              struct.setToEventIdIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 5: // LIMIT
+            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+              struct.limit = iprot.readI64();
+              struct.setLimitIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -550,6 +718,16 @@ import org.slf4j.LoggerFactory;
           oprot.writeFieldEnd();
         }
       }
+      if (struct.isSetToEventId()) {
+        oprot.writeFieldBegin(TO_EVENT_ID_FIELD_DESC);
+        oprot.writeI64(struct.toEventId);
+        oprot.writeFieldEnd();
+      }
+      if (struct.isSetLimit()) {
+        oprot.writeFieldBegin(LIMIT_FIELD_DESC);
+        oprot.writeI64(struct.limit);
+        oprot.writeFieldEnd();
+      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -573,10 +751,22 @@ import org.slf4j.LoggerFactory;
       if (struct.isSetCatName()) {
         optionals.set(0);
       }
-      oprot.writeBitSet(optionals, 1);
+      if (struct.isSetToEventId()) {
+        optionals.set(1);
+      }
+      if (struct.isSetLimit()) {
+        optionals.set(2);
+      }
+      oprot.writeBitSet(optionals, 3);
       if (struct.isSetCatName()) {
         oprot.writeString(struct.catName);
       }
+      if (struct.isSetToEventId()) {
+        oprot.writeI64(struct.toEventId);
+      }
+      if (struct.isSetLimit()) {
+        oprot.writeI64(struct.limit);
+      }
     }
 
     @Override
@@ -586,11 +776,19 @@ import org.slf4j.LoggerFactory;
       struct.setFromEventIdIsSet(true);
       struct.dbName = iprot.readString();
       struct.setDbNameIsSet(true);
-      BitSet incoming = iprot.readBitSet(1);
+      BitSet incoming = iprot.readBitSet(3);
       if (incoming.get(0)) {
         struct.catName = iprot.readString();
         struct.setCatNameIsSet(true);
       }
+      if (incoming.get(1)) {
+        struct.toEventId = iprot.readI64();
+        struct.setToEventIdIsSet(true);
+      }
+      if (incoming.get(2)) {
+        struct.limit = iprot.readI64();
+        struct.setLimitIsSet(true);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php b/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php
index 775c9d9..5fd5d78 100644
--- a/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php
+++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Types.php
@@ -22619,6 +22619,14 @@ class NotificationEventsCountRequest {
    * @var string
    */
   public $catName = null;
+  /**
+   * @var int
+   */
+  public $toEventId = null;
+  /**
+   * @var int
+   */
+  public $limit = null;
 
   public function __construct($vals=null) {
     if (!isset(self::$_TSPEC)) {
@@ -22635,6 +22643,14 @@ class NotificationEventsCountRequest {
           'var' => 'catName',
           'type' => TType::STRING,
           ),
+        4 => array(
+          'var' => 'toEventId',
+          'type' => TType::I64,
+          ),
+        5 => array(
+          'var' => 'limit',
+          'type' => TType::I64,
+          ),
         );
     }
     if (is_array($vals)) {
@@ -22647,6 +22663,12 @@ class NotificationEventsCountRequest {
       if (isset($vals['catName'])) {
         $this->catName = $vals['catName'];
       }
+      if (isset($vals['toEventId'])) {
+        $this->toEventId = $vals['toEventId'];
+      }
+      if (isset($vals['limit'])) {
+        $this->limit = $vals['limit'];
+      }
     }
   }
 
@@ -22690,6 +22712,20 @@ class NotificationEventsCountRequest {
             $xfer += $input->skip($ftype);
           }
           break;
+        case 4:
+          if ($ftype == TType::I64) {
+            $xfer += $input->readI64($this->toEventId);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 5:
+          if ($ftype == TType::I64) {
+            $xfer += $input->readI64($this->limit);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
         default:
           $xfer += $input->skip($ftype);
           break;
@@ -22718,6 +22754,16 @@ class NotificationEventsCountRequest {
       $xfer += $output->writeString($this->catName);
       $xfer += $output->writeFieldEnd();
     }
+    if ($this->toEventId !== null) {
+      $xfer += $output->writeFieldBegin('toEventId', TType::I64, 4);
+      $xfer += $output->writeI64($this->toEventId);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->limit !== null) {
+      $xfer += $output->writeFieldBegin('limit', TType::I64, 5);
+      $xfer += $output->writeI64($this->limit);
+      $xfer += $output->writeFieldEnd();
+    }
     $xfer += $output->writeFieldStop();
     $xfer += $output->writeStructEnd();
     return $xfer;

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py b/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py
index 9d3885c..03c2a4e 100644
--- a/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py
+++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/ttypes.py
@@ -15814,6 +15814,8 @@ class NotificationEventsCountRequest:
    - fromEventId
    - dbName
    - catName
+   - toEventId
+   - limit
   """
 
   thrift_spec = (
@@ -15821,12 +15823,16 @@ class NotificationEventsCountRequest:
     (1, TType.I64, 'fromEventId', None, None, ), # 1
     (2, TType.STRING, 'dbName', None, None, ), # 2
     (3, TType.STRING, 'catName', None, None, ), # 3
+    (4, TType.I64, 'toEventId', None, None, ), # 4
+    (5, TType.I64, 'limit', None, None, ), # 5
   )
 
-  def __init__(self, fromEventId=None, dbName=None, catName=None,):
+  def __init__(self, fromEventId=None, dbName=None, catName=None, toEventId=None, limit=None,):
     self.fromEventId = fromEventId
     self.dbName = dbName
     self.catName = catName
+    self.toEventId = toEventId
+    self.limit = limit
 
   def read(self, iprot):
     if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
@@ -15852,6 +15858,16 @@ class NotificationEventsCountRequest:
           self.catName = iprot.readString()
         else:
           iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.I64:
+          self.toEventId = iprot.readI64()
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TType.I64:
+          self.limit = iprot.readI64()
+        else:
+          iprot.skip(ftype)
       else:
         iprot.skip(ftype)
       iprot.readFieldEnd()
@@ -15874,6 +15890,14 @@ class NotificationEventsCountRequest:
       oprot.writeFieldBegin('catName', TType.STRING, 3)
       oprot.writeString(self.catName)
       oprot.writeFieldEnd()
+    if self.toEventId is not None:
+      oprot.writeFieldBegin('toEventId', TType.I64, 4)
+      oprot.writeI64(self.toEventId)
+      oprot.writeFieldEnd()
+    if self.limit is not None:
+      oprot.writeFieldBegin('limit', TType.I64, 5)
+      oprot.writeI64(self.limit)
+      oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
 
@@ -15890,6 +15914,8 @@ class NotificationEventsCountRequest:
     value = (value * 31) ^ hash(self.fromEventId)
     value = (value * 31) ^ hash(self.dbName)
     value = (value * 31) ^ hash(self.catName)
+    value = (value * 31) ^ hash(self.toEventId)
+    value = (value * 31) ^ hash(self.limit)
     return value
 
   def __repr__(self):

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb b/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb
index 26b89c0..2eea181 100644
--- a/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb
+++ b/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_types.rb
@@ -3518,11 +3518,15 @@ class NotificationEventsCountRequest
   FROMEVENTID = 1
   DBNAME = 2
   CATNAME = 3
+  TOEVENTID = 4
+  LIMIT = 5
 
   FIELDS = {
     FROMEVENTID => {:type => ::Thrift::Types::I64, :name => 'fromEventId'},
     DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
-    CATNAME => {:type => ::Thrift::Types::STRING, :name => 'catName', :optional => true}
+    CATNAME => {:type => ::Thrift::Types::STRING, :name => 'catName', :optional => true},
+    TOEVENTID => {:type => ::Thrift::Types::I64, :name => 'toEventId', :optional => true},
+    LIMIT => {:type => ::Thrift::Types::I64, :name => 'limit', :optional => true}
   }
 
   def struct_fields; FIELDS; end

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
index a2a6740..4b7b615 100644
--- a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
+++ b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
@@ -1147,7 +1147,9 @@ struct CurrentNotificationEventId {
 struct NotificationEventsCountRequest {
     1: required i64 fromEventId,
     2: required string dbName,
-    3: optional string catName
+    3: optional string catName,
+    4: optional i64 toEventId,
+    5: optional i64 limit
 }
 
 struct NotificationEventsCountResponse {

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index ddd64e7..9c15804 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -10260,14 +10260,60 @@ public class ObjectStore implements RawStore, Configurable {
       long fromEventId = rqst.getFromEventId();
       String inputDbName = rqst.getDbName();
       String catName = rqst.isSetCatName() ? rqst.getCatName() : getDefaultCatalog(conf);
-      String queryStr = "select count(eventId) from " + MNotificationLog.class.getName()
-                + " where eventId > fromEventId && dbName == inputDbName && catalogName == catName";
+      long toEventId;
+      String paramSpecs;
+      List<Object> paramVals = new ArrayList<Object>();
+
+      // We store a catalog name in lower case in metastore and also use the same way everywhere in
+      // hive.
+      assert catName.equals(catName.toLowerCase());
+
+      // Build the query to count events, part by part
+      String queryStr = "select count(eventId) from " + MNotificationLog.class.getName();
+      // count fromEventId onwards events
+      queryStr = queryStr + " where eventId > fromEventId";
+      paramSpecs = "java.lang.Long fromEventId";
+      paramVals.add(Long.valueOf(fromEventId));
+
+      // Input database name can be a database name or a *. In the first case we add a filter
+      // condition on dbName column, but not in the second case, since a * means all the
+      // databases. In case we support more elaborate database name patterns in future, we will
+      // have to apply a method similar to getNextNotification() method of MetaStoreClient.
+      if (!inputDbName.equals("*")) {
+        // dbName could be NULL in case of transaction related events, which also need to be
+        // counted.
+        queryStr = queryStr + " && (dbName == inputDbName || dbName == null)";
+        paramSpecs = paramSpecs + ", java.lang.String inputDbName";
+        // We store a database name in lower case in metastore.
+        paramVals.add(inputDbName.toLowerCase());
+      }
+
+      // catName could be NULL in case of transaction related events, which also need to be
+      // counted.
+      queryStr = queryStr + " && (catalogName == catName || catalogName == null)";
+      paramSpecs = paramSpecs +", java.lang.String catName";
+      paramVals.add(catName);
+
+      // count events upto toEventId if specified
+      if (rqst.isSetToEventId()) {
+        toEventId = rqst.getToEventId();
+        queryStr = queryStr + " && eventId <= toEventId";
+        paramSpecs = paramSpecs + ", java.lang.Long toEventId";
+        paramVals.add(Long.valueOf(toEventId));
+      }
+
       query = pm.newQuery(queryStr);
-      query.declareParameters("java.lang.Long fromEventId, java.lang.String inputDbName," +
-          " java.lang.String catName");
-      result = (Long) query.execute(fromEventId, inputDbName, catName);
+      query.declareParameters(paramSpecs);
+      result = (Long) query.executeWithArray(paramVals.toArray());
       commited = commitTransaction();
-      return new NotificationEventsCountResponse(result.longValue());
+
+      // Cap the event count by limit if specified.
+      long  eventCount = result.longValue();
+      if (rqst.isSetLimit() && eventCount > rqst.getLimit()) {
+        eventCount = rqst.getLimit();
+      }
+
+      return new NotificationEventsCountResponse(eventCount);
     } finally {
       rollbackAndCleanup(commited, query);
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/0d4d03fd/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
index 351fafd..0bb739f 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
@@ -1652,7 +1652,7 @@ abstract class TxnHandler implements TxnStore, TxnStore.MutexAPI {
         if (transactionalListeners != null) {
           MetaStoreListenerNotifier.notifyEventWithDirectSql(transactionalListeners,
                   EventMessage.EventType.ALLOC_WRITE_ID,
-                  new AllocWriteIdEvent(txnToWriteIds, rqst.getDbName(), rqst.getTableName(), null),
+                  new AllocWriteIdEvent(txnToWriteIds, dbName, tblName, null),
                   dbConn, sqlGenerator);
         }
 


[43/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
new file mode 100644
index 0000000..9c31d61
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query49.q.out
@@ -0,0 +1,330 @@
+PREHOOK: query: explain cbo
+select  
+ 'web' as channel
+ ,web.item
+ ,web.return_ratio
+ ,web.return_rank
+ ,web.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select ws.ws_item_sk as item
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		 web_sales ws left outer join web_returns wr 
+ 			on (ws.ws_order_number = wr.wr_order_number and 
+ 			ws.ws_item_sk = wr.wr_item_sk)
+                 ,date_dim
+ 		where 
+ 			wr.wr_return_amt > 10000 
+ 			and ws.ws_net_profit > 1
+                         and ws.ws_net_paid > 0
+                         and ws.ws_quantity > 0
+                         and ws_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by ws.ws_item_sk
+ 	) in_web
+ ) web
+ where 
+ (
+ web.return_rank <= 10
+ or
+ web.currency_rank <= 10
+ )
+ union
+ select 
+ 'catalog' as channel
+ ,catalog.item
+ ,catalog.return_ratio
+ ,catalog.return_rank
+ ,catalog.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select 
+ 		cs.cs_item_sk as item
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		catalog_sales cs left outer join catalog_returns cr
+ 			on (cs.cs_order_number = cr.cr_order_number and 
+ 			cs.cs_item_sk = cr.cr_item_sk)
+                ,date_dim
+ 		where 
+ 			cr.cr_return_amount > 10000 
+ 			and cs.cs_net_profit > 1
+                         and cs.cs_net_paid > 0
+                         and cs.cs_quantity > 0
+                         and cs_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+                 group by cs.cs_item_sk
+ 	) in_cat
+ ) catalog
+ where 
+ (
+ catalog.return_rank <= 10
+ or
+ catalog.currency_rank <=10
+ )
+ union
+ select 
+ 'store' as channel
+ ,store.item
+ ,store.return_ratio
+ ,store.return_rank
+ ,store.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select sts.ss_item_sk as item
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		store_sales sts left outer join store_returns sr
+ 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
+                ,date_dim
+ 		where 
+ 			sr.sr_return_amt > 10000 
+ 			and sts.ss_net_profit > 1
+                         and sts.ss_net_paid > 0 
+                         and sts.ss_quantity > 0
+                         and ss_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by sts.ss_item_sk
+ 	) in_store
+ ) store
+ where  (
+ store.return_rank <= 10
+ or 
+ store.currency_rank <= 10
+ )
+ order by 1,4,5
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+ 'web' as channel
+ ,web.item
+ ,web.return_ratio
+ ,web.return_rank
+ ,web.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select ws.ws_item_sk as item
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		 web_sales ws left outer join web_returns wr 
+ 			on (ws.ws_order_number = wr.wr_order_number and 
+ 			ws.ws_item_sk = wr.wr_item_sk)
+                 ,date_dim
+ 		where 
+ 			wr.wr_return_amt > 10000 
+ 			and ws.ws_net_profit > 1
+                         and ws.ws_net_paid > 0
+                         and ws.ws_quantity > 0
+                         and ws_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by ws.ws_item_sk
+ 	) in_web
+ ) web
+ where 
+ (
+ web.return_rank <= 10
+ or
+ web.currency_rank <= 10
+ )
+ union
+ select 
+ 'catalog' as channel
+ ,catalog.item
+ ,catalog.return_ratio
+ ,catalog.return_rank
+ ,catalog.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select 
+ 		cs.cs_item_sk as item
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		catalog_sales cs left outer join catalog_returns cr
+ 			on (cs.cs_order_number = cr.cr_order_number and 
+ 			cs.cs_item_sk = cr.cr_item_sk)
+                ,date_dim
+ 		where 
+ 			cr.cr_return_amount > 10000 
+ 			and cs.cs_net_profit > 1
+                         and cs.cs_net_paid > 0
+                         and cs.cs_quantity > 0
+                         and cs_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+                 group by cs.cs_item_sk
+ 	) in_cat
+ ) catalog
+ where 
+ (
+ catalog.return_rank <= 10
+ or
+ catalog.currency_rank <=10
+ )
+ union
+ select 
+ 'store' as channel
+ ,store.item
+ ,store.return_ratio
+ ,store.return_rank
+ ,store.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select sts.ss_item_sk as item
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		store_sales sts left outer join store_returns sr
+ 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
+                ,date_dim
+ 		where 
+ 			sr.sr_return_amt > 10000 
+ 			and sts.ss_net_profit > 1
+                         and sts.ss_net_paid > 0 
+                         and sts.ss_quantity > 0
+                         and ss_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by sts.ss_item_sk
+ 	) in_store
+ ) store
+ where  (
+ store.return_rank <= 10
+ or 
+ store.currency_rank <= 10
+ )
+ order by 1,4,5
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$4], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+    HiveAggregate(group=[{0, 1, 2, 3, 4}])
+      HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+            HiveAggregate(group=[{0, 1, 2, 3, 4}])
+              HiveProject(channel=[$0], item=[$1], return_ratio=[$2], return_rank=[$3], currency_rank=[$4])
+                HiveUnion(all=[true])
+                  HiveProject(channel=[_UTF-16LE'web'], item=[$0], return_ratio=[$1], return_rank=[$2], currency_rank=[$3])
+                    HiveFilter(condition=[OR(<=($2, 10), <=($3, 10))])
+                      HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                          HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
+                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_quantity=[$14], wr_return_amt=[$15])
+                                  HiveFilter(condition=[AND(>($15, 10000), IS NOT NULL($13), IS NOT NULL($2))])
+                                    HiveTableScan(table=[[default, web_returns]], table:alias=[wr])
+                                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_order_number=[$17], ws_quantity=[$18], ws_net_paid=[$29], ws_net_profit=[$33])
+                                    HiveFilter(condition=[AND(>($33, 1), >($29, 0), >($18, 0), IS NOT NULL($17), IS NOT NULL($3), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, web_sales]], table:alias=[ws])
+                                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(12):INTEGER])
+                                    HiveFilter(condition=[AND(=($6, 2000), =($8, 12), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(channel=[_UTF-16LE'catalog'], item=[$0], return_ratio=[$1], return_rank=[$2], currency_rank=[$3])
+                    HiveFilter(condition=[OR(<=($2, 10), <=($3, 10))])
+                      HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                          HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
+                            HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                              HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_quantity=[$17], cr_return_amount=[$18])
+                                  HiveFilter(condition=[AND(>($18, 10000), IS NOT NULL($16), IS NOT NULL($2))])
+                                    HiveTableScan(table=[[default, catalog_returns]], table:alias=[cr])
+                                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_net_paid=[$29], cs_net_profit=[$33])
+                                    HiveFilter(condition=[AND(>($33, 1), >($29, 0), >($18, 0), IS NOT NULL($17), IS NOT NULL($15), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[cs])
+                                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(12):INTEGER])
+                                    HiveFilter(condition=[AND(=($6, 2000), =($8, 12), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'store'], item=[$0], return_ratio=[$1], return_rank=[$2], currency_rank=[$3])
+            HiveFilter(condition=[OR(<=($2, 10), <=($3, 10))])
+              HiveProject(item=[$0], return_ratio=[/(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4))], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($1):DECIMAL(15, 4), CAST($2):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY 0 ORDER BY /(CAST($3):DECIMAL(15, 4), CAST($4):DECIMAL(15, 4)) NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                  HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)], agg#3=[sum($4)])
+                    HiveProject($f0=[$5], $f1=[CASE(IS NOT NULL($2), $2, 0)], $f2=[CASE(IS NOT NULL($7), $7, 0)], $f3=[CASE(IS NOT NULL($3), $3, 0)], $f4=[CASE(IS NOT NULL($8), $8, 0)])
+                      HiveJoin(condition=[AND(=($6, $1), =($5, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_quantity=[$10], sr_return_amt=[$11])
+                          HiveFilter(condition=[AND(>($11, 10000), IS NOT NULL($9), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, store_returns]], table:alias=[sr])
+                        HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ticket_number=[$9], ss_quantity=[$10], ss_net_paid=[$20], ss_net_profit=[$22])
+                            HiveFilter(condition=[AND(>($22, 1), >($20, 0), >($10, 0), IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[sts])
+                          HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(12):INTEGER])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 12), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query5.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query5.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query5.q.out
new file mode 100644
index 0000000..a82f011
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query5.q.out
@@ -0,0 +1,342 @@
+PREHOOK: query: explain cbo
+with ssr as
+ (select s_store_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ss_store_sk as store_sk,
+            ss_sold_date_sk  as date_sk,
+            ss_ext_sales_price as sales_price,
+            ss_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from store_sales
+    union all
+    select sr_store_sk as store_sk,
+           sr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           sr_return_amt as return_amt,
+           sr_net_loss as net_loss
+    from store_returns
+   ) salesreturns,
+     date_dim,
+     store
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  14 days)
+       and store_sk = s_store_sk
+ group by s_store_id)
+ ,
+ csr as
+ (select cp_catalog_page_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  cs_catalog_page_sk as page_sk,
+            cs_sold_date_sk  as date_sk,
+            cs_ext_sales_price as sales_price,
+            cs_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from catalog_sales
+    union all
+    select cr_catalog_page_sk as page_sk,
+           cr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           cr_return_amount as return_amt,
+           cr_net_loss as net_loss
+    from catalog_returns
+   ) salesreturns,
+     date_dim,
+     catalog_page
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and page_sk = cp_catalog_page_sk
+ group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select web_site_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ws_web_site_sk as wsr_web_site_sk,
+            ws_sold_date_sk  as date_sk,
+            ws_ext_sales_price as sales_price,
+            ws_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from web_sales
+    union all
+    select ws_web_site_sk as wsr_web_site_sk,
+           wr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           wr_return_amt as return_amt,
+           wr_net_loss as net_loss
+    from web_returns left outer join web_sales on
+         ( wr_item_sk = ws_item_sk
+           and wr_order_number = ws_order_number)
+   ) salesreturns,
+     date_dim,
+     web_site
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and wsr_web_site_sk = web_site_sk
+ group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || s_store_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || cp_catalog_page_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_page
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssr as
+ (select s_store_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ss_store_sk as store_sk,
+            ss_sold_date_sk  as date_sk,
+            ss_ext_sales_price as sales_price,
+            ss_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from store_sales
+    union all
+    select sr_store_sk as store_sk,
+           sr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           sr_return_amt as return_amt,
+           sr_net_loss as net_loss
+    from store_returns
+   ) salesreturns,
+     date_dim,
+     store
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  14 days)
+       and store_sk = s_store_sk
+ group by s_store_id)
+ ,
+ csr as
+ (select cp_catalog_page_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  cs_catalog_page_sk as page_sk,
+            cs_sold_date_sk  as date_sk,
+            cs_ext_sales_price as sales_price,
+            cs_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from catalog_sales
+    union all
+    select cr_catalog_page_sk as page_sk,
+           cr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           cr_return_amount as return_amt,
+           cr_net_loss as net_loss
+    from catalog_returns
+   ) salesreturns,
+     date_dim,
+     catalog_page
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and page_sk = cp_catalog_page_sk
+ group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select web_site_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ws_web_site_sk as wsr_web_site_sk,
+            ws_sold_date_sk  as date_sk,
+            ws_ext_sales_price as sales_price,
+            ws_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from web_sales
+    union all
+    select ws_web_site_sk as wsr_web_site_sk,
+           wr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           wr_return_amt as return_amt,
+           wr_net_loss as net_loss
+    from web_returns left outer join web_sales on
+         ( wr_item_sk = ws_item_sk
+           and wr_order_number = ws_order_number)
+   ) salesreturns,
+     date_dim,
+     web_site
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and wsr_web_site_sk = web_site_sk
+ group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || s_store_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || cp_catalog_page_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_page
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(channel=[$0], id=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
+      HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store channel'], id=[||(_UTF-16LE'store', $0)], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveAggregate(group=[{9}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)])
+              HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(store_sk=[$0], date_sk=[$1], sales_price=[$2], profit=[$3], return_amt=[$4], net_loss=[$5])
+                    HiveUnion(all=[true])
+                      HiveProject(store_sk=[$7], date_sk=[$0], sales_price=[$15], profit=[$22], return_amt=[CAST(0):DECIMAL(7, 2)], net_loss=[CAST(0):DECIMAL(7, 2)])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(store_sk=[$7], date_sk=[$0], sales_price=[CAST(0):DECIMAL(7, 2)], profit=[CAST(0):DECIMAL(7, 2)], return_amt=[$11], net_loss=[$19])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-08-18 00:00:00), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_store_id=[$1])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveProject(channel=[_UTF-16LE'catalog channel'], id=[||(_UTF-16LE'catalog_page', $0)], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveAggregate(group=[{1}], agg#0=[sum($4)], agg#1=[sum($5)], agg#2=[sum($6)], agg#3=[sum($7)])
+              HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cp_catalog_page_sk=[$0], cp_catalog_page_id=[$1])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, catalog_page]], table:alias=[catalog_page])
+                HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(page_sk=[$0], date_sk=[$1], sales_price=[$2], profit=[$3], return_amt=[$4], net_loss=[$5])
+                    HiveUnion(all=[true])
+                      HiveProject(page_sk=[$12], date_sk=[$0], sales_price=[$23], profit=[$33], return_amt=[CAST(0):DECIMAL(7, 2)], net_loss=[CAST(0):DECIMAL(7, 2)])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(page_sk=[$12], date_sk=[$0], sales_price=[CAST(0):DECIMAL(7, 2)], profit=[CAST(0):DECIMAL(7, 2)], return_amt=[$18], net_loss=[$26])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12))])
+                          HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-08-18 00:00:00), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'web channel'], id=[||(_UTF-16LE'web_site', $0)], sales=[$1], returns=[$3], profit=[-($2, $4)])
+            HiveAggregate(group=[{9}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)])
+              HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(wsr_web_site_sk=[$0], date_sk=[$1], sales_price=[$2], profit=[$3], return_amt=[$4], net_loss=[$5])
+                    HiveUnion(all=[true])
+                      HiveProject(wsr_web_site_sk=[$13], date_sk=[$0], sales_price=[$23], profit=[$33], return_amt=[CAST(0):DECIMAL(7, 2)], net_loss=[CAST(0):DECIMAL(7, 2)])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($13))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(wsr_web_site_sk=[$1], date_sk=[$3], sales_price=[CAST(0):DECIMAL(7, 2)], profit=[CAST(0):DECIMAL(7, 2)], return_amt=[$6], net_loss=[$7])
+                        HiveJoin(condition=[AND(=($4, $0), =($5, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ws_item_sk=[$3], ws_web_site_sk=[$13], ws_order_number=[$17])
+                            HiveFilter(condition=[AND(IS NOT NULL($13), IS NOT NULL($3), IS NOT NULL($17))])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(wr_returned_date_sk=[$0], wr_item_sk=[$2], wr_order_number=[$13], wr_return_amt=[$15], wr_net_loss=[$23])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2), IS NOT NULL($13))])
+                              HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-08-18 00:00:00), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(web_site_sk=[$0], web_site_id=[$1])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query50.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query50.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query50.q.out
new file mode 100644
index 0000000..2be59c1
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query50.q.out
@@ -0,0 +1,151 @@
+PREHOOK: query: explain cbo
+select  
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   store_sales
+  ,store_returns
+  ,store
+  ,date_dim d1
+  ,date_dim d2
+where
+    d2.d_year = 2000
+and d2.d_moy  = 9
+and ss_ticket_number = sr_ticket_number
+and ss_item_sk = sr_item_sk
+and ss_sold_date_sk   = d1.d_date_sk
+and sr_returned_date_sk   = d2.d_date_sk
+and ss_customer_sk = sr_customer_sk
+and ss_store_sk = s_store_sk
+group by
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+order by s_store_name
+        ,s_company_id
+        ,s_street_number
+        ,s_street_name
+        ,s_street_type
+        ,s_suite_number
+        ,s_city
+        ,s_county
+        ,s_state
+        ,s_zip
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   store_sales
+  ,store_returns
+  ,store
+  ,date_dim d1
+  ,date_dim d2
+where
+    d2.d_year = 2000
+and d2.d_moy  = 9
+and ss_ticket_number = sr_ticket_number
+and ss_item_sk = sr_item_sk
+and ss_sold_date_sk   = d1.d_date_sk
+and sr_returned_date_sk   = d2.d_date_sk
+and ss_customer_sk = sr_customer_sk
+and ss_store_sk = s_store_sk
+group by
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+order by s_store_name
+        ,s_company_id
+        ,s_street_number
+        ,s_street_name
+        ,s_street_type
+        ,s_suite_number
+        ,s_city
+        ,s_county
+        ,s_state
+        ,s_zip
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14])
+    HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}], agg#0=[sum($10)], agg#1=[sum($11)], agg#2=[sum($12)], agg#3=[sum($13)], agg#4=[sum($14)])
+      HiveProject($f0=[$14], $f1=[$15], $f2=[$16], $f3=[$17], $f4=[$18], $f5=[$19], $f6=[$20], $f7=[$21], $f8=[$22], $f9=[$23], $f10=[CASE(<=(-($5, $0), 30), 1, 0)], $f11=[CASE(AND(>(-($5, $0), 30), <=(-($5, $0), 60)), 1, 0)], $f12=[CASE(AND(>(-($5, $0), 60), <=(-($5, $0), 90)), 1, 0)], $f13=[CASE(AND(>(-($5, $0), 90), <=(-($5, $0), 120)), 1, 0)], $f14=[CASE(>(-($5, $0), 120), 1, 0)])
+        HiveJoin(condition=[=($3, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[AND(AND(=($4, $8), =($1, $6)), =($2, $7))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9])
+                HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($3), IS NOT NULL($7), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9])
+                  HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($3), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(9):INTEGER])
+                  HiveFilter(condition=[AND(=($6, 2000), =($8, 9), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+            HiveProject(d_date_sk=[$0])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+          HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_id=[$16], s_street_number=[$18], s_street_name=[$19], s_street_type=[$20], s_suite_number=[$21], s_city=[$22], s_county=[$23], s_state=[$24], s_zip=[$25])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query51.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query51.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query51.q.out
new file mode 100644
index 0000000..fed8677
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query51.q.out
@@ -0,0 +1,125 @@
+PREHOOK: query: explain cbo
+WITH web_v1 as (
+select
+  ws_item_sk item_sk, d_date,
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from web_sales
+    ,date_dim
+where ws_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ws_item_sk is not NULL
+group by ws_item_sk, d_date),
+store_v1 as (
+select
+  ss_item_sk item_sk, d_date,
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from store_sales
+    ,date_dim
+where ss_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ss_item_sk is not NULL
+group by ss_item_sk, d_date)
+ select  *
+from (select item_sk
+     ,d_date
+     ,web_sales
+     ,store_sales
+     ,max(web_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
+     ,max(store_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
+     from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
+                 ,case when web.d_date is not null then web.d_date else store.d_date end d_date
+                 ,web.cume_sales web_sales
+                 ,store.cume_sales store_sales
+           from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
+                                                          and web.d_date = store.d_date)
+          )x )y
+where web_cumulative > store_cumulative
+order by item_sk
+        ,d_date
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+WITH web_v1 as (
+select
+  ws_item_sk item_sk, d_date,
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from web_sales
+    ,date_dim
+where ws_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ws_item_sk is not NULL
+group by ws_item_sk, d_date),
+store_v1 as (
+select
+  ss_item_sk item_sk, d_date,
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from store_sales
+    ,date_dim
+where ss_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ss_item_sk is not NULL
+group by ss_item_sk, d_date)
+ select  *
+from (select item_sk
+     ,d_date
+     ,web_sales
+     ,store_sales
+     ,max(web_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
+     ,max(store_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
+     from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
+                 ,case when web.d_date is not null then web.d_date else store.d_date end d_date
+                 ,web.cume_sales web_sales
+                 ,store.cume_sales store_sales
+           from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
+                                                          and web.d_date = store.d_date)
+          )x )y
+where web_cumulative > store_cumulative
+order by item_sk
+        ,d_date
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(item_sk=[$0], d_date=[$1], web_sales=[$2], store_sales=[$3], max_window_0=[$4], max_window_1=[$5])
+    HiveFilter(condition=[>($4, $5)])
+      HiveProject(item_sk=[CASE(IS NOT NULL($3), $3, $0)], d_date=[CASE(IS NOT NULL($4), $4, $1)], web_sales=[$5], store_sales=[$2], max_window_0=[max($5) OVER (PARTITION BY CASE(IS NOT NULL($3), $3, $0) ORDER BY CASE(IS NOT NULL($4), $4, $1) NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)], max_window_1=[max($2) OVER (PARTITION BY CASE(IS NOT NULL($3), $3, $0) ORDER BY CASE(IS NOT NULL($4), $4, $1) NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)])
+        HiveJoin(condition=[AND(=($3, $0), =($4, $1))], joinType=[full], algorithm=[none], cost=[not available])
+          HiveProject((tok_table_or_col ss_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[$2])
+            HiveProject((tok_table_or_col ss_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[sum($2) OVER (PARTITION BY $0 ORDER BY $1 NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)], window_col_0=[$2])
+              HiveProject(ss_item_sk=[$0], d_date=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 4}], agg#0=[sum($2)])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                      HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject((tok_table_or_col ws_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[$2])
+            HiveProject((tok_table_or_col ws_item_sk)=[$0], (tok_table_or_col d_date)=[$1], sum_window_0=[sum($2) OVER (PARTITION BY $0 ORDER BY $1 NULLS LAST ROWS BETWEEN CURRENT ROW AND 2147483647 PRECEDING)], window_col_0=[$2])
+              HiveProject(ws_item_sk=[$0], d_date=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 4}], agg#0=[sum($2)])
+                  HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_sales_price=[$21])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                      HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query52.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query52.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query52.q.out
new file mode 100644
index 0000000..627b8b0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query52.q.out
@@ -0,0 +1,67 @@
+PREHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_brand_id brand_id
+ 	,item.i_brand brand
+ 	,sum(ss_ext_sales_price) ext_price
+ 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_manager_id = 1
+    and dt.d_moy=12
+    and dt.d_year=1998
+ group by dt.d_year
+ 	,item.i_brand
+ 	,item.i_brand_id
+ order by dt.d_year
+ 	,ext_price desc
+ 	,brand_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_brand_id brand_id
+ 	,item.i_brand brand
+ 	,sum(ss_ext_sales_price) ext_price
+ 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_manager_id = 1
+    and dt.d_moy=12
+    and dt.d_year=1998
+ group by dt.d_year
+ 	,item.i_brand
+ 	,item.i_brand_id
+ order by dt.d_year
+ 	,ext_price desc
+ 	,brand_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(d_year=[CAST(1998):INTEGER], brand_id=[$0], brand=[$1], ext_price=[$2])
+  HiveSortLimit(sort0=[$2], sort1=[$0], dir0=[DESC-nulls-last], dir1=[ASC], fetch=[100])
+    HiveProject(i_brand_id=[$0], i_brand=[$1], $f2=[$2])
+      HiveAggregate(group=[{7, 8}], agg#0=[sum($2)])
+        HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER], d_moy=[CAST(12):INTEGER])
+              HiveFilter(condition=[AND(=($8, 12), =($6, 1998), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[dt])
+          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8], i_manager_id=[CAST(1):INTEGER])
+            HiveFilter(condition=[AND(=($20, 1), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out
new file mode 100644
index 0000000..56b1ba2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query53.q.out
@@ -0,0 +1,87 @@
+PREHOOK: query: explain cbo
+select  * from 
+(select i_manufact_id,
+sum(ss_sales_price) sum_sales,
+avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+ss_sold_date_sk = d_date_sk and
+ss_store_sk = s_store_sk and
+d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
+((i_category in ('Books','Children','Electronics') and
+i_class in ('personal','portable','reference','self-help') and
+i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		'exportiunivamalg #9','scholaramalgamalg #9'))
+or(i_category in ('Women','Music','Men') and
+i_class in ('accessories','classical','fragrances','pants') and
+i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		'importoamalg #1')))
+group by i_manufact_id, d_qoy ) tmp1
+where case when avg_quarterly_sales > 0 
+	then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales 
+	else null end > 0.1
+order by avg_quarterly_sales,
+	 sum_sales,
+	 i_manufact_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  * from 
+(select i_manufact_id,
+sum(ss_sales_price) sum_sales,
+avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+ss_sold_date_sk = d_date_sk and
+ss_store_sk = s_store_sk and
+d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
+((i_category in ('Books','Children','Electronics') and
+i_class in ('personal','portable','reference','self-help') and
+i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		'exportiunivamalg #9','scholaramalgamalg #9'))
+or(i_category in ('Women','Music','Men') and
+i_class in ('accessories','classical','fragrances','pants') and
+i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		'importoamalg #1')))
+group by i_manufact_id, d_qoy ) tmp1
+where case when avg_quarterly_sales > 0 
+	then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales 
+	else null end > 0.1
+order by avg_quarterly_sales,
+	 sum_sales,
+	 i_manufact_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$2], sort1=[$1], sort2=[$0], dir0=[ASC], dir1=[ASC], dir2=[ASC], fetch=[100])
+  HiveProject((tok_table_or_col i_manufact_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$1], avg_window_0=[$2])
+    HiveFilter(condition=[CASE(>($2, 0), >(/(ABS(-($1, $2)), $2), 0.1), null)])
+      HiveProject((tok_table_or_col i_manufact_id)=[$0], (tok_function sum (tok_table_or_col ss_sales_price))=[$2], avg_window_0=[avg($2) OVER (PARTITION BY $0 ORDER BY $0 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+        HiveProject(i_manufact_id=[$0], d_qoy=[$1], $f2=[$2])
+          HiveAggregate(group=[{9, 12}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(s_store_sk=[$0])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12], i_manufact_id=[$13])
+                    HiveFilter(condition=[AND(IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'reference', _UTF-16LE'self-help', _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9', _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'), IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics', _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), OR(AND(IN($12, _UTF-16LE'Books', _UTF-16LE'Children', _UTF-16LE'Electronics'), IN($10, _UTF-16LE'personal', _UTF-16LE'portable', _UTF-16LE'reference', _UTF-16LE'self-help'), IN($8, _UTF-16LE'scholaramalgamalg #14', _UTF-16LE'scholaramalgamalg #7', _UTF-16LE'exportiunivamalg #9', _UTF-16LE'scholaramalgamalg #9')), AND(IN($12, _UTF-16LE'Women', _UTF-16LE'Music', _UTF-16LE'Men'), IN($10, 
 _UTF-16LE'accessories', _UTF-16LE'classical', _UTF-16LE'fragrances', _UTF-16LE'pants'), IN($8, _UTF-16LE'amalgimporto #1', _UTF-16LE'edu packscholar #1', _UTF-16LE'exportiimporto #1', _UTF-16LE'importoamalg #1'))), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3], d_qoy=[$10])
+                  HiveFilter(condition=[AND(IN($3, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query54.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query54.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query54.q.out
new file mode 100644
index 0000000..eaf2536
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query54.q.out
@@ -0,0 +1,213 @@
+Warning: Shuffle Join MERGEJOIN[271][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[272][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[270][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 32' is a cross product
+Warning: Shuffle Join MERGEJOIN[273][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 6' is a cross product
+PREHOOK: query: explain cbo
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(segment=[$0], num_customers=[$1], segment_base=[*($0, 50)])
+    HiveAggregate(group=[{0}], agg#0=[count()])
+      HiveProject(segment=[CAST(/($1, CAST(50):DECIMAL(10, 0))):INTEGER])
+        HiveAggregate(group=[{0}], agg#0=[sum($1)])
+          HiveFilter(condition=[BETWEEN(false, $2, $3, $4)])
+            HiveProject(c_customer_sk=[$0], ss_ext_sales_price=[$4], d_month_seq=[$11], _o__c0=[$13], $f0=[$14])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f0=[$10], $f1=[$11], ss_sold_date_sk=[$0], ss_customer_sk=[$1], ss_ext_sales_price=[$2], ca_address_sk=[$5], ca_county=[$6], ca_state=[$7], s_county=[$8], s_state=[$9], d_date_sk=[$3], d_month_seq=[$4], cnt=[$12], $f00=[$13])
+                  HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($10, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_ext_sales_price=[$15])
+                            HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(ca_address_sk=[$0], ca_county=[$1], ca_state=[$2], s_county=[$3], s_state=[$4], c_customer_sk=[$5], c_current_addr_sk=[$6])
+                          HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[AND(=($1, $3), =($2, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(ca_address_sk=[$0], ca_county=[$7], ca_state=[$8])
+                                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($8))])
+                                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                              HiveProject(s_county=[$23], s_state=[$24])
+                                HiveFilter(condition=[AND(IS NOT NULL($23), IS NOT NULL($24))])
+                                  HiveTableScan(table=[[default, store]], table:alias=[store])
+                            HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$1])
+                              HiveAggregate(group=[{0, 1}])
+                                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                  HiveJoin(condition=[=($2, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2])
+                                        HiveUnion(all=[true])
+                                          HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15])
+                                            HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0), IS NOT NULL($3))])
+                                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                          HiveProject(sold_date_sk=[$0], customer_sk=[$4], item_sk=[$3])
+                                            HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0), IS NOT NULL($4))])
+                                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(3):INTEGER])
+                                        HiveFilter(condition=[AND(=($8, 3), =($6, 1999), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                    HiveProject(i_item_sk=[$0], i_class=[CAST(_UTF-16LE'consignment'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_category=[CAST(_UTF-16LE'Jewelry'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Jewelry'), =($10, _UTF-16LE'consignment'), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveProject(cnt=[$0])
+                        HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                          HiveProject(cnt=[$0])
+                            HiveAggregate(group=[{}], cnt=[COUNT()])
+                              HiveProject($f0=[$0])
+                                HiveAggregate(group=[{0}])
+                                  HiveProject($f0=[+($3, 1)])
+                                    HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject($f0=[$0])
+                      HiveAggregate(group=[{0}])
+                        HiveProject($f0=[+($3, 1)])
+                          HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveJoin(condition=[true], joinType=[right], algorithm=[none], cost=[not available])
+                  HiveProject($f0=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveProject($f0=[+($3, 3)])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(cnt=[$0])
+                    HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                      HiveProject(cnt=[$0])
+                        HiveAggregate(group=[{}], cnt=[COUNT()])
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{0}])
+                              HiveProject($f0=[+($3, 3)])
+                                HiveFilter(condition=[AND(=($6, 1999), =($8, 3))])
+                                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query55.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query55.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query55.q.out
new file mode 100644
index 0000000..4182de0
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query55.q.out
@@ -0,0 +1,51 @@
+PREHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+ 	and ss_item_sk = i_item_sk
+ 	and i_manager_id=36
+ 	and d_moy=12
+ 	and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_brand_id brand_id, i_brand brand,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+ 	and ss_item_sk = i_item_sk
+ 	and i_manager_id=36
+ 	and d_moy=12
+ 	and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(brand_id=[$0], brand=[$1], ext_price=[$2])
+  HiveSortLimit(sort0=[$2], sort1=[$3], dir0=[DESC-nulls-last], dir1=[ASC], fetch=[100])
+    HiveProject(brand_id=[$0], brand=[$1], ext_price=[$2], (tok_table_or_col i_brand_id)=[$0])
+      HiveAggregate(group=[{7, 8}], agg#0=[sum($2)])
+        HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER], d_moy=[CAST(12):INTEGER])
+              HiveFilter(condition=[AND(=($8, 12), =($6, 2001), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8], i_manager_id=[CAST(36):INTEGER])
+            HiveFilter(condition=[AND(=($20, 36), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out
new file mode 100644
index 0000000..579d06a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query56.q.out
@@ -0,0 +1,224 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(i_item_id=[$0], $f1=[$1])
+        HiveUnion(all=[true])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace'), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], ss_sold_date_sk=[$2], ss_item_sk=[$3], ss_addr_sk=[$4], ss_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-8):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -8), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(1):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 2000), =($8, 1), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace'), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], cs_sold_date_sk=[$2], cs_bill_addr_sk=[$3], cs_item_sk=[$4], cs_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-8):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -8), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($15))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(1):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 2000), =($8, 1), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_item_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                    HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_item_id=[$0])
+                    HiveAggregate(group=[{1}])
+                      HiveFilter(condition=[AND(IN($17, _UTF-16LE'orchid', _UTF-16LE'chiffon', _UTF-16LE'lace'), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], ws_sold_date_sk=[$2], ws_item_sk=[$3], ws_bill_addr_sk=[$4], ws_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-8):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -8), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(1):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 2000), =($8, 1), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[73/75] [abbrv] hive git commit: HIVE-20638 : Upgrade version of Jetty to 9.3.25.v20180904 (Laszlo Bodor via Thejas Nair)

Posted by se...@apache.org.
HIVE-20638 : Upgrade version of Jetty to 9.3.25.v20180904 (Laszlo Bodor  via Thejas Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/1002e89b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/1002e89b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/1002e89b

Branch: refs/heads/master-tez092
Commit: 1002e89b6501afca7f886323e96f2f37b4b9ac60
Parents: 0d70154
Author: Thejas M Nair <th...@hortonworks.com>
Authored: Fri Oct 26 09:37:34 2018 -0700
Committer: Thejas M Nair <th...@hortonworks.com>
Committed: Fri Oct 26 09:37:34 2018 -0700

----------------------------------------------------------------------
 hbase-handler/pom.xml        | 12 +++++++++++-
 hcatalog/webhcat/svr/pom.xml | 10 +++++-----
 pom.xml                      |  8 +++++++-
 serde/pom.xml                | 20 ++++++++++++++++++++
 4 files changed, 43 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/1002e89b/hbase-handler/pom.xml
----------------------------------------------------------------------
diff --git a/hbase-handler/pom.xml b/hbase-handler/pom.xml
index 06939a4..58666f8 100644
--- a/hbase-handler/pom.xml
+++ b/hbase-handler/pom.xml
@@ -51,7 +51,7 @@
       <version>${hadoop.version}</version>
       <optional>true</optional>
         <exclusions>
-             <exclusion>
+          <exclusion>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
           </exclusion>
@@ -59,6 +59,10 @@
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
           </exclusion>
+          <exclusion>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-util</artifactId>
+          </exclusion>
       </exclusions>
     </dependency>
     <dependency>
@@ -130,6 +134,12 @@
       <version>${hadoop.version}</version>
       <classifier>tests</classifier>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-util</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>

http://git-wip-us.apache.org/repos/asf/hive/blob/1002e89b/hcatalog/webhcat/svr/pom.xml
----------------------------------------------------------------------
diff --git a/hcatalog/webhcat/svr/pom.xml b/hcatalog/webhcat/svr/pom.xml
index d19e99a..4dfade5 100644
--- a/hcatalog/webhcat/svr/pom.xml
+++ b/hcatalog/webhcat/svr/pom.xml
@@ -164,13 +164,13 @@
       <version>${hadoop.version}</version>
       <exclusions>
         <exclusion>
-          <groupId>org.mortbay.jetty</groupId>
+          <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty</artifactId>
         </exclusion>
         <exclusion>
-          <groupId>org.mortbay.jetty</groupId>
+          <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty-util</artifactId>
-	</exclusion>
+        </exclusion>
       </exclusions>
     </dependency>
     <dependency>
@@ -179,11 +179,11 @@
       <version>${hadoop.version}</version>
       <exclusions>
         <exclusion>
-          <groupId>org.mortbay.jetty</groupId>
+          <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty</artifactId>
         </exclusion>
         <exclusion>
-          <groupId>org.mortbay.jetty</groupId>
+          <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty-util</artifactId>
         </exclusion>
       </exclusions>

http://git-wip-us.apache.org/repos/asf/hive/blob/1002e89b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 716db28..842a143 100644
--- a/pom.xml
+++ b/pom.xml
@@ -171,7 +171,7 @@
     <javolution.version>5.5.1</javolution.version>
     <jdo-api.version>3.0.1</jdo-api.version>
     <jettison.version>1.1</jettison.version>
-    <jetty.version>9.3.20.v20170531</jetty.version>
+    <jetty.version>9.3.25.v20180904</jetty.version>
     <jersey.version>1.19</jersey.version>
     <!-- Glassfish jersey is included for Spark client test only -->
     <glassfish.jersey.version>2.22.2</glassfish.jersey.version>
@@ -1003,6 +1003,12 @@
       <groupId>org.mockito</groupId>
       <artifactId>mockito-all</artifactId>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-util</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/hive/blob/1002e89b/serde/pom.xml
----------------------------------------------------------------------
diff --git a/serde/pom.xml b/serde/pom.xml
index 8c37414..3756582 100644
--- a/serde/pom.xml
+++ b/serde/pom.xml
@@ -114,6 +114,10 @@
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
           </exclusion>
+          <exclusion>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-util</artifactId>
+          </exclusion>
         </exclusions>
    </dependency>
     <dependency>
@@ -163,6 +167,10 @@
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
           </exclusion>
+          <exclusion>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-util</artifactId>
+          </exclusion>
         </exclusions>
    </dependency>
     <dependency>
@@ -176,6 +184,12 @@
       <artifactId>hadoop-hdfs</artifactId>
       <version>${hadoop.version}</version>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-util</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
@@ -183,6 +197,12 @@
       <version>${hadoop.version}</version>
       <classifier>tests</classifier>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-util</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
 


[39/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out
new file mode 100644
index 0000000..66b345c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query78.q.out
@@ -0,0 +1,183 @@
+PREHOOK: query: explain cbo
+with ws as
+  (select d_year AS ws_sold_year, ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+   from web_sales
+   left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk
+   join date_dim on ws_sold_date_sk = d_date_sk
+   where wr_order_number is null
+   group by d_year, ws_item_sk, ws_bill_customer_sk
+   ),
+cs as
+  (select d_year AS cs_sold_year, cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+   from catalog_sales
+   left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk
+   join date_dim on cs_sold_date_sk = d_date_sk
+   where cr_order_number is null
+   group by d_year, cs_item_sk, cs_bill_customer_sk
+   ),
+ss as
+  (select d_year AS ss_sold_year, ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+   from store_sales
+   left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk
+   join date_dim on ss_sold_date_sk = d_date_sk
+   where sr_ticket_number is null
+   group by d_year, ss_item_sk, ss_customer_sk
+   )
+ select 
+ss_sold_year, ss_item_sk, ss_customer_sk,
+round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
+ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
+coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
+coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
+coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
+from ss
+left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
+order by 
+  ss_sold_year, ss_item_sk, ss_customer_sk,
+  ss_qty desc, ss_wc desc, ss_sp desc,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ws as
+  (select d_year AS ws_sold_year, ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+   from web_sales
+   left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk
+   join date_dim on ws_sold_date_sk = d_date_sk
+   where wr_order_number is null
+   group by d_year, ws_item_sk, ws_bill_customer_sk
+   ),
+cs as
+  (select d_year AS cs_sold_year, cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+   from catalog_sales
+   left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk
+   join date_dim on cs_sold_date_sk = d_date_sk
+   where cr_order_number is null
+   group by d_year, cs_item_sk, cs_bill_customer_sk
+   ),
+ss as
+  (select d_year AS ss_sold_year, ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+   from store_sales
+   left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk
+   join date_dim on ss_sold_date_sk = d_date_sk
+   where sr_ticket_number is null
+   group by d_year, ss_item_sk, ss_customer_sk
+   )
+ select 
+ss_sold_year, ss_item_sk, ss_customer_sk,
+round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
+ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
+coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
+coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
+coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
+from ss
+left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
+order by 
+  ss_sold_year, ss_item_sk, ss_customer_sk,
+  ss_qty desc, ss_wc desc, ss_sp desc,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject(ss_sold_year=[CAST(2000):INTEGER], ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[$2], store_qty=[$3], store_wholesale_cost=[$4], store_sales_price=[$5], other_chan_qty=[$6], other_chan_wholesale_cost=[$7], other_chan_sales_price=[$8])
+    HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$9], sort3=[$10], sort4=[$11], sort5=[$6], sort6=[$7], sort7=[$8], sort8=[$12], dir0=[ASC], dir1=[ASC], dir2=[DESC-nulls-last], dir3=[DESC-nulls-last], dir4=[DESC-nulls-last], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC])
+      HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], ratio=[round(/(CAST($2):DOUBLE, CAST(CASE(AND(IS NOT NULL($7), IS NOT NULL($11)), +($7, $11), 1)):DOUBLE), 2)], store_qty=[$2], store_wholesale_cost=[$3], store_sales_price=[$4], other_chan_qty=[+(CASE(IS NOT NULL($7), $7, 0), CASE(IS NOT NULL($11), $11, 0))], other_chan_wholesale_cost=[+(CASE(IS NOT NULL($8), $8, 0), CASE(IS NOT NULL($12), $12, 0))], other_chan_sales_price=[+(CASE(IS NOT NULL($9), $9, 0), CASE(IS NOT NULL($13), $13, 0))], ss_qty=[$2], ss_wc=[$3], ss_sp=[$4], (tok_function round (/ (tok_table_or_col ss_qty) (tok_function coalesce (+ (tok_table_or_col ws_qty) (tok_table_or_col cs_qty)) 1)) 2)=[round(/(CAST($2):DOUBLE, CAST(CASE(AND(IS NOT NULL($7), IS NOT NULL($11)), +($7, $11), 1)):DOUBLE), 2)])
+        HiveFilter(condition=[CASE(IS NOT NULL($11), >($11, 0), false)])
+          HiveJoin(condition=[=($10, $1)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4], ws_item_sk=[$5], ws_bill_customer_sk=[$6], $f20=[$7], $f30=[$8], $f40=[$9])
+              HiveFilter(condition=[CASE(IS NOT NULL($7), >($7, 0), false)])
+                HiveJoin(condition=[AND(=($5, $0), =($6, $1))], joinType=[left], algorithm=[none], cost=[not available])
+                  HiveProject(ss_item_sk=[$0], ss_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                    HiveAggregate(group=[{3, 4}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)])
+                      HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER])
+                          HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$1], ss_customer_sk=[$2], ss_ticket_number=[$3], ss_quantity=[$4], ss_wholesale_cost=[$5], ss_sales_price=[$6], sr_item_sk=[$7], sr_ticket_number=[$8])
+                          HiveFilter(condition=[IS NULL($8)])
+                            HiveJoin(condition=[AND(=($8, $3), =($1, $7))], joinType=[left], algorithm=[none], cost=[not available])
+                              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_ticket_number=[$9], ss_quantity=[$10], ss_wholesale_cost=[$11], ss_sales_price=[$13])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                              HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                                HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                  HiveProject(ws_item_sk=[$0], ws_bill_customer_sk=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                    HiveAggregate(group=[{3, 4}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)])
+                      HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER])
+                          HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$1], ws_bill_customer_sk=[$2], ws_order_number=[$3], ws_quantity=[$4], ws_wholesale_cost=[$5], ws_sales_price=[$6], wr_item_sk=[$7], wr_order_number=[$8])
+                          HiveFilter(condition=[IS NULL($8)])
+                            HiveJoin(condition=[AND(=($8, $3), =($1, $7))], joinType=[left], algorithm=[none], cost=[not available])
+                              HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_customer_sk=[$4], ws_order_number=[$17], ws_quantity=[$18], ws_wholesale_cost=[$19], ws_sales_price=[$21])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                              HiveProject(wr_item_sk=[$2], wr_order_number=[$13])
+                                HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+            HiveProject($f2=[$0], $f3=[$2], $f4=[$3], $f5=[$4])
+              HiveAggregate(group=[{3, 4}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)])
+                HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_item_sk=[$2], cs_order_number=[$3], cs_quantity=[$4], cs_wholesale_cost=[$5], cs_sales_price=[$6], cr_item_sk=[$7], cr_order_number=[$8])
+                    HiveFilter(condition=[IS NULL($8)])
+                      HiveJoin(condition=[AND(=($8, $3), =($2, $7))], joinType=[left], algorithm=[none], cost=[not available])
+                        HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_order_number=[$17], cs_quantity=[$18], cs_wholesale_cost=[$19], cs_sales_price=[$21])
+                          HiveFilter(condition=[AND(=($15, $15), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                        HiveProject(cr_item_sk=[$2], cr_order_number=[$16])
+                          HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query79.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query79.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query79.q.out
new file mode 100644
index 0000000..6da8ac2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query79.q.out
@@ -0,0 +1,82 @@
+PREHOOK: query: explain cbo
+select 
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
+  from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,store.s_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
+    and date_dim.d_dow = 1
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_number_employees between 200 and 295
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
+    where ss_customer_sk = c_customer_sk
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select 
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
+  from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,store.s_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
+    and date_dim.d_dow = 1
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_number_employees between 200 and 295
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
+    where ss_customer_sk = c_customer_sk
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(c_last_name=[$0], c_first_name=[$1], _o__c2=[$2], ss_ticket_number=[$3], amt=[$4], profit=[$5])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$6], sort3=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+    HiveProject(c_last_name=[$2], c_first_name=[$1], _o__c2=[substr($5, 1, 30)], ss_ticket_number=[$3], amt=[$6], profit=[$7], (tok_function substr (tok_table_or_col s_city) 1 30)=[substr($5, 1, 30)])
+      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ss_ticket_number=[$2], ss_customer_sk=[$0], s_city=[$3], amt=[$4], profit=[$5])
+          HiveAggregate(group=[{1, 3, 5, 13}], agg#0=[sum($6)], agg#1=[sum($7)])
+            HiveJoin(condition=[=($2, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($4, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_coupon_amt=[$19], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[$6], d_dow=[CAST(1):INTEGER])
+                    HiveFilter(condition=[AND(IN($6, 1998, 1999, 2000), =($7, 1), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_number_employees=[$6], s_city=[$22])
+                  HiveFilter(condition=[AND(BETWEEN(false, $6, 200, 295), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                HiveFilter(condition=[AND(OR(=($3, 8), >($4, 0)), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out
new file mode 100644
index 0000000..5c4f7a2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query8.q.out
@@ -0,0 +1,266 @@
+PREHOOK: query: explain cbo
+select  s_store_name
+      ,sum(ss_net_profit)
+ from store_sales
+     ,date_dim
+     ,store,
+     (select ca_zip
+     from (
+     (SELECT substr(ca_zip,1,5) ca_zip
+      FROM customer_address
+      WHERE substr(ca_zip,1,5) IN (
+                          '89436','30868','65085','22977','83927','77557',
+                          '58429','40697','80614','10502','32779',
+                          '91137','61265','98294','17921','18427',
+                          '21203','59362','87291','84093','21505',
+                          '17184','10866','67898','25797','28055',
+                          '18377','80332','74535','21757','29742',
+                          '90885','29898','17819','40811','25990',
+                          '47513','89531','91068','10391','18846',
+                          '99223','82637','41368','83658','86199',
+                          '81625','26696','89338','88425','32200',
+                          '81427','19053','77471','36610','99823',
+                          '43276','41249','48584','83550','82276',
+                          '18842','78890','14090','38123','40936',
+                          '34425','19850','43286','80072','79188',
+                          '54191','11395','50497','84861','90733',
+                          '21068','57666','37119','25004','57835',
+                          '70067','62878','95806','19303','18840',
+                          '19124','29785','16737','16022','49613',
+                          '89977','68310','60069','98360','48649',
+                          '39050','41793','25002','27413','39736',
+                          '47208','16515','94808','57648','15009',
+                          '80015','42961','63982','21744','71853',
+                          '81087','67468','34175','64008','20261',
+                          '11201','51799','48043','45645','61163',
+                          '48375','36447','57042','21218','41100',
+                          '89951','22745','35851','83326','61125',
+                          '78298','80752','49858','52940','96976',
+                          '63792','11376','53582','18717','90226',
+                          '50530','94203','99447','27670','96577',
+                          '57856','56372','16165','23427','54561',
+                          '28806','44439','22926','30123','61451',
+                          '92397','56979','92309','70873','13355',
+                          '21801','46346','37562','56458','28286',
+                          '47306','99555','69399','26234','47546',
+                          '49661','88601','35943','39936','25632',
+                          '24611','44166','56648','30379','59785',
+                          '11110','14329','93815','52226','71381',
+                          '13842','25612','63294','14664','21077',
+                          '82626','18799','60915','81020','56447',
+                          '76619','11433','13414','42548','92713',
+                          '70467','30884','47484','16072','38936',
+                          '13036','88376','45539','35901','19506',
+                          '65690','73957','71850','49231','14276',
+                          '20005','18384','76615','11635','38177',
+                          '55607','41369','95447','58581','58149',
+                          '91946','33790','76232','75692','95464',
+                          '22246','51061','56692','53121','77209',
+                          '15482','10688','14868','45907','73520',
+                          '72666','25734','17959','24677','66446',
+                          '94627','53535','15560','41967','69297',
+                          '11929','59403','33283','52232','57350',
+                          '43933','40921','36635','10827','71286',
+                          '19736','80619','25251','95042','15526',
+                          '36496','55854','49124','81980','35375',
+                          '49157','63512','28944','14946','36503',
+                          '54010','18767','23969','43905','66979',
+                          '33113','21286','58471','59080','13395',
+                          '79144','70373','67031','38360','26705',
+                          '50906','52406','26066','73146','15884',
+                          '31897','30045','61068','45550','92454',
+                          '13376','14354','19770','22928','97790',
+                          '50723','46081','30202','14410','20223',
+                          '88500','67298','13261','14172','81410',
+                          '93578','83583','46047','94167','82564',
+                          '21156','15799','86709','37931','74703',
+                          '83103','23054','70470','72008','49247',
+                          '91911','69998','20961','70070','63197',
+                          '54853','88191','91830','49521','19454',
+                          '81450','89091','62378','25683','61869',
+                          '51744','36580','85778','36871','48121',
+                          '28810','83712','45486','67393','26935',
+                          '42393','20132','55349','86057','21309',
+                          '80218','10094','11357','48819','39734',
+                          '40758','30432','21204','29467','30214',
+                          '61024','55307','74621','11622','68908',
+                          '33032','52868','99194','99900','84936',
+                          '69036','99149','45013','32895','59004',
+                          '32322','14933','32936','33562','72550',
+                          '27385','58049','58200','16808','21360',
+                          '32961','18586','79307','15492'))
+     intersect
+     (select ca_zip
+      from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
+            FROM customer_address, customer
+            WHERE ca_address_sk = c_current_addr_sk and
+                  c_preferred_cust_flag='Y'
+            group by ca_zip
+            having count(*) > 10)A1))A2) V1
+ where ss_store_sk = s_store_sk
+  and ss_sold_date_sk = d_date_sk
+  and d_qoy = 1 and d_year = 2002
+  and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
+ group by s_store_name
+ order by s_store_name
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  s_store_name
+      ,sum(ss_net_profit)
+ from store_sales
+     ,date_dim
+     ,store,
+     (select ca_zip
+     from (
+     (SELECT substr(ca_zip,1,5) ca_zip
+      FROM customer_address
+      WHERE substr(ca_zip,1,5) IN (
+                          '89436','30868','65085','22977','83927','77557',
+                          '58429','40697','80614','10502','32779',
+                          '91137','61265','98294','17921','18427',
+                          '21203','59362','87291','84093','21505',
+                          '17184','10866','67898','25797','28055',
+                          '18377','80332','74535','21757','29742',
+                          '90885','29898','17819','40811','25990',
+                          '47513','89531','91068','10391','18846',
+                          '99223','82637','41368','83658','86199',
+                          '81625','26696','89338','88425','32200',
+                          '81427','19053','77471','36610','99823',
+                          '43276','41249','48584','83550','82276',
+                          '18842','78890','14090','38123','40936',
+                          '34425','19850','43286','80072','79188',
+                          '54191','11395','50497','84861','90733',
+                          '21068','57666','37119','25004','57835',
+                          '70067','62878','95806','19303','18840',
+                          '19124','29785','16737','16022','49613',
+                          '89977','68310','60069','98360','48649',
+                          '39050','41793','25002','27413','39736',
+                          '47208','16515','94808','57648','15009',
+                          '80015','42961','63982','21744','71853',
+                          '81087','67468','34175','64008','20261',
+                          '11201','51799','48043','45645','61163',
+                          '48375','36447','57042','21218','41100',
+                          '89951','22745','35851','83326','61125',
+                          '78298','80752','49858','52940','96976',
+                          '63792','11376','53582','18717','90226',
+                          '50530','94203','99447','27670','96577',
+                          '57856','56372','16165','23427','54561',
+                          '28806','44439','22926','30123','61451',
+                          '92397','56979','92309','70873','13355',
+                          '21801','46346','37562','56458','28286',
+                          '47306','99555','69399','26234','47546',
+                          '49661','88601','35943','39936','25632',
+                          '24611','44166','56648','30379','59785',
+                          '11110','14329','93815','52226','71381',
+                          '13842','25612','63294','14664','21077',
+                          '82626','18799','60915','81020','56447',
+                          '76619','11433','13414','42548','92713',
+                          '70467','30884','47484','16072','38936',
+                          '13036','88376','45539','35901','19506',
+                          '65690','73957','71850','49231','14276',
+                          '20005','18384','76615','11635','38177',
+                          '55607','41369','95447','58581','58149',
+                          '91946','33790','76232','75692','95464',
+                          '22246','51061','56692','53121','77209',
+                          '15482','10688','14868','45907','73520',
+                          '72666','25734','17959','24677','66446',
+                          '94627','53535','15560','41967','69297',
+                          '11929','59403','33283','52232','57350',
+                          '43933','40921','36635','10827','71286',
+                          '19736','80619','25251','95042','15526',
+                          '36496','55854','49124','81980','35375',
+                          '49157','63512','28944','14946','36503',
+                          '54010','18767','23969','43905','66979',
+                          '33113','21286','58471','59080','13395',
+                          '79144','70373','67031','38360','26705',
+                          '50906','52406','26066','73146','15884',
+                          '31897','30045','61068','45550','92454',
+                          '13376','14354','19770','22928','97790',
+                          '50723','46081','30202','14410','20223',
+                          '88500','67298','13261','14172','81410',
+                          '93578','83583','46047','94167','82564',
+                          '21156','15799','86709','37931','74703',
+                          '83103','23054','70470','72008','49247',
+                          '91911','69998','20961','70070','63197',
+                          '54853','88191','91830','49521','19454',
+                          '81450','89091','62378','25683','61869',
+                          '51744','36580','85778','36871','48121',
+                          '28810','83712','45486','67393','26935',
+                          '42393','20132','55349','86057','21309',
+                          '80218','10094','11357','48819','39734',
+                          '40758','30432','21204','29467','30214',
+                          '61024','55307','74621','11622','68908',
+                          '33032','52868','99194','99900','84936',
+                          '69036','99149','45013','32895','59004',
+                          '32322','14933','32936','33562','72550',
+                          '27385','58049','58200','16808','21360',
+                          '32961','18586','79307','15492'))
+     intersect
+     (select ca_zip
+      from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
+            FROM customer_address, customer
+            WHERE ca_address_sk = c_current_addr_sk and
+                  c_preferred_cust_flag='Y'
+            group by ca_zip
+            having count(*) > 10)A1))A2) V1
+ where ss_store_sk = s_store_sk
+  and ss_sold_date_sk = d_date_sk
+  and d_qoy = 1 and d_year = 2002
+  and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
+ group by s_store_name
+ order by s_store_name
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(s_store_name=[$0], $f1=[$1])
+    HiveAggregate(group=[{8}], agg#0=[sum($2)])
+      HiveJoin(condition=[=($1, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_net_profit=[$22])
+            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER], d_qoy=[CAST(1):INTEGER])
+            HiveFilter(condition=[AND(=($10, 1), =($6, 2002), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject($f0=[$0], s_store_sk=[$1], s_store_name=[$2], s_zip=[$3])
+          HiveJoin(condition=[=(substr($3, 1, 2), substr($0, 1, 2))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject($f0=[$0])
+              HiveFilter(condition=[=($1, 2)])
+                HiveAggregate(group=[{0}], agg#0=[count($1)])
+                  HiveProject(ca_zip=[$0], $f1=[$1])
+                    HiveUnion(all=[true])
+                      HiveProject(ca_zip=[$0], $f1=[$1])
+                        HiveAggregate(group=[{0}], agg#0=[count()])
+                          HiveProject(ca_zip=[substr($9, 1, 5)])
+                            HiveFilter(condition=[AND(IN(substr($9, 1, 5), _UTF-16LE'89436', _UTF-16LE'30868', _UTF-16LE'65085', _UTF-16LE'22977', _UTF-16LE'83927', _UTF-16LE'77557', _UTF-16LE'58429', _UTF-16LE'40697', _UTF-16LE'80614', _UTF-16LE'10502', _UTF-16LE'32779', _UTF-16LE'91137', _UTF-16LE'61265', _UTF-16LE'98294', _UTF-16LE'17921', _UTF-16LE'18427', _UTF-16LE'21203', _UTF-16LE'59362', _UTF-16LE'87291', _UTF-16LE'84093', _UTF-16LE'21505', _UTF-16LE'17184', _UTF-16LE'10866', _UTF-16LE'67898', _UTF-16LE'25797', _UTF-16LE'28055', _UTF-16LE'18377', _UTF-16LE'80332', _UTF-16LE'74535', _UTF-16LE'21757', _UTF-16LE'29742', _UTF-16LE'90885', _UTF-16LE'29898', _UTF-16LE'17819', _UTF-16LE'40811', _UTF-16LE'25990', _UTF-16LE'47513', _UTF-16LE'89531', _UTF-16LE'91068', _UTF-16LE'10391', _UTF-16LE'18846', _UTF-16LE'99223', _UTF-16LE'82637', _UTF-16LE'41368', _UTF-16LE'83658', _UTF-16LE'86199', _UTF-16LE'81625', _UTF-16LE'26696', _UTF-16LE'89338', _UTF-16LE'88425', _UTF-16LE'32200', _UTF
 -16LE'81427', _UTF-16LE'19053', _UTF-16LE'77471', _UTF-16LE'36610', _UTF-16LE'99823', _UTF-16LE'43276', _UTF-16LE'41249', _UTF-16LE'48584', _UTF-16LE'83550', _UTF-16LE'82276', _UTF-16LE'18842', _UTF-16LE'78890', _UTF-16LE'14090', _UTF-16LE'38123', _UTF-16LE'40936', _UTF-16LE'34425', _UTF-16LE'19850', _UTF-16LE'43286', _UTF-16LE'80072', _UTF-16LE'79188', _UTF-16LE'54191', _UTF-16LE'11395', _UTF-16LE'50497', _UTF-16LE'84861', _UTF-16LE'90733', _UTF-16LE'21068', _UTF-16LE'57666', _UTF-16LE'37119', _UTF-16LE'25004', _UTF-16LE'57835', _UTF-16LE'70067', _UTF-16LE'62878', _UTF-16LE'95806', _UTF-16LE'19303', _UTF-16LE'18840', _UTF-16LE'19124', _UTF-16LE'29785', _UTF-16LE'16737', _UTF-16LE'16022', _UTF-16LE'49613', _UTF-16LE'89977', _UTF-16LE'68310', _UTF-16LE'60069', _UTF-16LE'98360', _UTF-16LE'48649', _UTF-16LE'39050', _UTF-16LE'41793', _UTF-16LE'25002', _UTF-16LE'27413', _UTF-16LE'39736', _UTF-16LE'47208', _UTF-16LE'16515', _UTF-16LE'94808', _UTF-16LE'57648', _UTF-16LE'15009', _UTF-16LE'8
 0015', _UTF-16LE'42961', _UTF-16LE'63982', _UTF-16LE'21744', _UTF-16LE'71853', _UTF-16LE'81087', _UTF-16LE'67468', _UTF-16LE'34175', _UTF-16LE'64008', _UTF-16LE'20261', _UTF-16LE'11201', _UTF-16LE'51799', _UTF-16LE'48043', _UTF-16LE'45645', _UTF-16LE'61163', _UTF-16LE'48375', _UTF-16LE'36447', _UTF-16LE'57042', _UTF-16LE'21218', _UTF-16LE'41100', _UTF-16LE'89951', _UTF-16LE'22745', _UTF-16LE'35851', _UTF-16LE'83326', _UTF-16LE'61125', _UTF-16LE'78298', _UTF-16LE'80752', _UTF-16LE'49858', _UTF-16LE'52940', _UTF-16LE'96976', _UTF-16LE'63792', _UTF-16LE'11376', _UTF-16LE'53582', _UTF-16LE'18717', _UTF-16LE'90226', _UTF-16LE'50530', _UTF-16LE'94203', _UTF-16LE'99447', _UTF-16LE'27670', _UTF-16LE'96577', _UTF-16LE'57856', _UTF-16LE'56372', _UTF-16LE'16165', _UTF-16LE'23427', _UTF-16LE'54561', _UTF-16LE'28806', _UTF-16LE'44439', _UTF-16LE'22926', _UTF-16LE'30123', _UTF-16LE'61451', _UTF-16LE'92397', _UTF-16LE'56979', _UTF-16LE'92309', _UTF-16LE'70873', _UTF-16LE'13355', _UTF-16LE'21801', 
 _UTF-16LE'46346', _UTF-16LE'37562', _UTF-16LE'56458', _UTF-16LE'28286', _UTF-16LE'47306', _UTF-16LE'99555', _UTF-16LE'69399', _UTF-16LE'26234', _UTF-16LE'47546', _UTF-16LE'49661', _UTF-16LE'88601', _UTF-16LE'35943', _UTF-16LE'39936', _UTF-16LE'25632', _UTF-16LE'24611', _UTF-16LE'44166', _UTF-16LE'56648', _UTF-16LE'30379', _UTF-16LE'59785', _UTF-16LE'11110', _UTF-16LE'14329', _UTF-16LE'93815', _UTF-16LE'52226', _UTF-16LE'71381', _UTF-16LE'13842', _UTF-16LE'25612', _UTF-16LE'63294', _UTF-16LE'14664', _UTF-16LE'21077', _UTF-16LE'82626', _UTF-16LE'18799', _UTF-16LE'60915', _UTF-16LE'81020', _UTF-16LE'56447', _UTF-16LE'76619', _UTF-16LE'11433', _UTF-16LE'13414', _UTF-16LE'42548', _UTF-16LE'92713', _UTF-16LE'70467', _UTF-16LE'30884', _UTF-16LE'47484', _UTF-16LE'16072', _UTF-16LE'38936', _UTF-16LE'13036', _UTF-16LE'88376', _UTF-16LE'45539', _UTF-16LE'35901', _UTF-16LE'19506', _UTF-16LE'65690', _UTF-16LE'73957', _UTF-16LE'71850', _UTF-16LE'49231', _UTF-16LE'14276', _UTF-16LE'20005', _UTF-16
 LE'18384', _UTF-16LE'76615', _UTF-16LE'11635', _UTF-16LE'38177', _UTF-16LE'55607', _UTF-16LE'41369', _UTF-16LE'95447', _UTF-16LE'58581', _UTF-16LE'58149', _UTF-16LE'91946', _UTF-16LE'33790', _UTF-16LE'76232', _UTF-16LE'75692', _UTF-16LE'95464', _UTF-16LE'22246', _UTF-16LE'51061', _UTF-16LE'56692', _UTF-16LE'53121', _UTF-16LE'77209', _UTF-16LE'15482', _UTF-16LE'10688', _UTF-16LE'14868', _UTF-16LE'45907', _UTF-16LE'73520', _UTF-16LE'72666', _UTF-16LE'25734', _UTF-16LE'17959', _UTF-16LE'24677', _UTF-16LE'66446', _UTF-16LE'94627', _UTF-16LE'53535', _UTF-16LE'15560', _UTF-16LE'41967', _UTF-16LE'69297', _UTF-16LE'11929', _UTF-16LE'59403', _UTF-16LE'33283', _UTF-16LE'52232', _UTF-16LE'57350', _UTF-16LE'43933', _UTF-16LE'40921', _UTF-16LE'36635', _UTF-16LE'10827', _UTF-16LE'71286', _UTF-16LE'19736', _UTF-16LE'80619', _UTF-16LE'25251', _UTF-16LE'95042', _UTF-16LE'15526', _UTF-16LE'36496', _UTF-16LE'55854', _UTF-16LE'49124', _UTF-16LE'81980', _UTF-16LE'35375', _UTF-16LE'49157', _UTF-16LE'6351
 2', _UTF-16LE'28944', _UTF-16LE'14946', _UTF-16LE'36503', _UTF-16LE'54010', _UTF-16LE'18767', _UTF-16LE'23969', _UTF-16LE'43905', _UTF-16LE'66979', _UTF-16LE'33113', _UTF-16LE'21286', _UTF-16LE'58471', _UTF-16LE'59080', _UTF-16LE'13395', _UTF-16LE'79144', _UTF-16LE'70373', _UTF-16LE'67031', _UTF-16LE'38360', _UTF-16LE'26705', _UTF-16LE'50906', _UTF-16LE'52406', _UTF-16LE'26066', _UTF-16LE'73146', _UTF-16LE'15884', _UTF-16LE'31897', _UTF-16LE'30045', _UTF-16LE'61068', _UTF-16LE'45550', _UTF-16LE'92454', _UTF-16LE'13376', _UTF-16LE'14354', _UTF-16LE'19770', _UTF-16LE'22928', _UTF-16LE'97790', _UTF-16LE'50723', _UTF-16LE'46081', _UTF-16LE'30202', _UTF-16LE'14410', _UTF-16LE'20223', _UTF-16LE'88500', _UTF-16LE'67298', _UTF-16LE'13261', _UTF-16LE'14172', _UTF-16LE'81410', _UTF-16LE'93578', _UTF-16LE'83583', _UTF-16LE'46047', _UTF-16LE'94167', _UTF-16LE'82564', _UTF-16LE'21156', _UTF-16LE'15799', _UTF-16LE'86709', _UTF-16LE'37931', _UTF-16LE'74703', _UTF-16LE'83103', _UTF-16LE'23054', _UT
 F-16LE'70470', _UTF-16LE'72008', _UTF-16LE'49247', _UTF-16LE'91911', _UTF-16LE'69998', _UTF-16LE'20961', _UTF-16LE'70070', _UTF-16LE'63197', _UTF-16LE'54853', _UTF-16LE'88191', _UTF-16LE'91830', _UTF-16LE'49521', _UTF-16LE'19454', _UTF-16LE'81450', _UTF-16LE'89091', _UTF-16LE'62378', _UTF-16LE'25683', _UTF-16LE'61869', _UTF-16LE'51744', _UTF-16LE'36580', _UTF-16LE'85778', _UTF-16LE'36871', _UTF-16LE'48121', _UTF-16LE'28810', _UTF-16LE'83712', _UTF-16LE'45486', _UTF-16LE'67393', _UTF-16LE'26935', _UTF-16LE'42393', _UTF-16LE'20132', _UTF-16LE'55349', _UTF-16LE'86057', _UTF-16LE'21309', _UTF-16LE'80218', _UTF-16LE'10094', _UTF-16LE'11357', _UTF-16LE'48819', _UTF-16LE'39734', _UTF-16LE'40758', _UTF-16LE'30432', _UTF-16LE'21204', _UTF-16LE'29467', _UTF-16LE'30214', _UTF-16LE'61024', _UTF-16LE'55307', _UTF-16LE'74621', _UTF-16LE'11622', _UTF-16LE'68908', _UTF-16LE'33032', _UTF-16LE'52868', _UTF-16LE'99194', _UTF-16LE'99900', _UTF-16LE'84936', _UTF-16LE'69036', _UTF-16LE'99149', _UTF-16LE'
 45013', _UTF-16LE'32895', _UTF-16LE'59004', _UTF-16LE'32322', _UTF-16LE'14933', _UTF-16LE'32936', _UTF-16LE'33562', _UTF-16LE'72550', _UTF-16LE'27385', _UTF-16LE'58049', _UTF-16LE'58200', _UTF-16LE'16808', _UTF-16LE'21360', _UTF-16LE'32961', _UTF-16LE'18586', _UTF-16LE'79307', _UTF-16LE'15492'), IS NOT NULL(substr(substr($9, 1, 5), 1, 2)))])
+                              HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                      HiveProject(ca_zip=[$0], $f1=[$1])
+                        HiveAggregate(group=[{0}], agg#0=[count()])
+                          HiveProject(ca_zip=[substr($0, 1, 5)])
+                            HiveFilter(condition=[>($1, 10)])
+                              HiveAggregate(group=[{1}], agg#0=[count()])
+                                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveProject(ca_address_sk=[$0], ca_zip=[$9])
+                                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL(substr(substr($9, 1, 5), 1, 2)))])
+                                      HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                                  HiveProject(c_current_addr_sk=[$4], c_preferred_cust_flag=[CAST(_UTF-16LE'Y'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                                    HiveFilter(condition=[AND(=($10, _UTF-16LE'Y'), IS NOT NULL($4))])
+                                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+            HiveProject(s_store_sk=[$0], s_store_name=[$5], s_zip=[$25])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL(substr($25, 1, 2)))])
+                HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
new file mode 100644
index 0000000..9c43294
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query80.q.out
@@ -0,0 +1,301 @@
+PREHOOK: query: explain cbo
+with ssr as
+ (select  s_store_id as store_id,
+          sum(ss_ext_sales_price) as sales,
+          sum(coalesce(sr_return_amt, 0)) as returns,
+          sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit
+  from store_sales left outer join store_returns on
+         (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number),
+     date_dim,
+     store,
+     item,
+     promotion
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ss_store_sk = s_store_sk
+       and ss_item_sk = i_item_sk
+       and i_current_price > 50
+       and ss_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+ group by s_store_id)
+ ,
+ csr as
+ (select  cp_catalog_page_id as catalog_page_id,
+          sum(cs_ext_sales_price) as sales,
+          sum(coalesce(cr_return_amount, 0)) as returns,
+          sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit
+  from catalog_sales left outer join catalog_returns on
+         (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number),
+     date_dim,
+     catalog_page,
+     item,
+     promotion
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and cs_catalog_page_sk = cp_catalog_page_sk
+       and cs_item_sk = i_item_sk
+       and i_current_price > 50
+       and cs_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select  web_site_id,
+          sum(ws_ext_sales_price) as sales,
+          sum(coalesce(wr_return_amt, 0)) as returns,
+          sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit
+  from web_sales left outer join web_returns on
+         (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number),
+     date_dim,
+     web_site,
+     item,
+     promotion
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and ws_web_site_sk = web_site_sk
+       and ws_item_sk = i_item_sk
+       and i_current_price > 50
+       and ws_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || store_id as id
+        , sales
+        , returns
+        , profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || catalog_page_id as id
+        , sales
+        , returns
+        , profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_page
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with ssr as
+ (select  s_store_id as store_id,
+          sum(ss_ext_sales_price) as sales,
+          sum(coalesce(sr_return_amt, 0)) as returns,
+          sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit
+  from store_sales left outer join store_returns on
+         (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number),
+     date_dim,
+     store,
+     item,
+     promotion
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ss_store_sk = s_store_sk
+       and ss_item_sk = i_item_sk
+       and i_current_price > 50
+       and ss_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+ group by s_store_id)
+ ,
+ csr as
+ (select  cp_catalog_page_id as catalog_page_id,
+          sum(cs_ext_sales_price) as sales,
+          sum(coalesce(cr_return_amount, 0)) as returns,
+          sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit
+  from catalog_sales left outer join catalog_returns on
+         (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number),
+     date_dim,
+     catalog_page,
+     item,
+     promotion
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and cs_catalog_page_sk = cp_catalog_page_sk
+       and cs_item_sk = i_item_sk
+       and i_current_price > 50
+       and cs_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select  web_site_id,
+          sum(ws_ext_sales_price) as sales,
+          sum(coalesce(wr_return_amt, 0)) as returns,
+          sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit
+  from web_sales left outer join web_returns on
+         (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number),
+     date_dim,
+     web_site,
+     item,
+     promotion
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and ws_web_site_sk = web_site_sk
+       and ws_item_sk = i_item_sk
+       and i_current_price > 50
+       and ws_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || store_id as id
+        , sales
+        , returns
+        , profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || catalog_page_id as id
+        , sales
+        , returns
+        , profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_page
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(channel=[$0], id=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)])
+      HiveProject(channel=[$0], id=[$1], sales=[$2], returns=[$3], profit=[$4])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store channel'], id=[||(_UTF-16LE'store', $0)], sales=[$1], returns=[$2], profit=[$3])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
+              HiveProject($f0=[$1], $f1=[$9], $f2=[CASE(IS NOT NULL($13), $13, 0)], $f3=[-($10, CASE(IS NOT NULL($14), $14, 0))])
+                HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(s_store_sk=[$0], s_store_id=[$1])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, store]], table:alias=[store])
+                  HiveJoin(condition=[=($5, $15)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_current_price=[$5])
+                        HiveFilter(condition=[AND(>($5, 50), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[AND(=($1, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ticket_number=[$9], ss_ext_sales_price=[$15], ss_net_profit=[$22])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($2), IS NOT NULL($8))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9], sr_return_amt=[$11], sr_net_loss=[$19])
+                            HiveFilter(condition=[IS NOT NULL($2)])
+                              HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                        HiveProject(d_date_sk=[$0], d_date=[$2])
+                          HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(p_promo_sk=[$0], p_channel_tv=[CAST(_UTF-16LE'N'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(=($11, _UTF-16LE'N'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+          HiveProject(channel=[_UTF-16LE'catalog channel'], id=[||(_UTF-16LE'catalog_page', $0)], sales=[$1], returns=[$2], profit=[$3])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
+              HiveProject($f0=[$1], $f1=[$9], $f2=[CASE(IS NOT NULL($13), $13, 0)], $f3=[-($10, CASE(IS NOT NULL($14), $14, 0))])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cp_catalog_page_sk=[$0], cp_catalog_page_id=[$1])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, catalog_page]], table:alias=[catalog_page])
+                  HiveJoin(condition=[=($5, $15)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_current_price=[$5])
+                        HiveFilter(condition=[AND(>($5, 50), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[AND(=($2, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_catalog_page_sk=[$12], cs_item_sk=[$15], cs_promo_sk=[$16], cs_order_number=[$17], cs_ext_sales_price=[$23], cs_net_profit=[$33])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($15), IS NOT NULL($16))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_return_amount=[$18], cr_net_loss=[$26])
+                            HiveFilter(condition=[IS NOT NULL($2)])
+                              HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                        HiveProject(d_date_sk=[$0], d_date=[$2])
+                          HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(p_promo_sk=[$0], p_channel_tv=[CAST(_UTF-16LE'N'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(=($11, _UTF-16LE'N'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+          HiveProject(channel=[_UTF-16LE'web channel'], id=[||(_UTF-16LE'web_site', $0)], sales=[$1], returns=[$2], profit=[$3])
+            HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)], agg#2=[sum($3)])
+              HiveProject($f0=[$18], $f1=[$9], $f2=[CASE(IS NOT NULL($13), $13, 0)], $f3=[-($10, CASE(IS NOT NULL($14), $14, 0))])
+                HiveJoin(condition=[=($6, $17)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(p_promo_sk=[$0], p_channel_tv=[CAST(_UTF-16LE'N'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(=($11, _UTF-16LE'N'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+                    HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_current_price=[$5])
+                        HiveFilter(condition=[AND(>($5, 50), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[AND(=($1, $7), =($4, $8))], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_web_site_sk=[$13], ws_promo_sk=[$16], ws_order_number=[$17], ws_ext_sales_price=[$23], ws_net_profit=[$33])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($13), IS NOT NULL($3), IS NOT NULL($16))])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(wr_item_sk=[$2], wr_order_number=[$13], wr_return_amt=[$15], wr_net_loss=[$23])
+                            HiveFilter(condition=[IS NOT NULL($2)])
+                              HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                        HiveProject(d_date_sk=[$0], d_date=[$2])
+                          HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-08-04 00:00:00, 1998-09-03 00:00:00), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(web_site_sk=[$0], web_site_id=[$1])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, web_site]], table:alias=[web_site])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query81.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query81.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query81.q.out
new file mode 100644
index 0000000..e13017f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query81.q.out
@@ -0,0 +1,113 @@
+PREHOOK: query: explain cbo
+with customer_total_return as
+ (select cr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(cr_return_amt_inc_tax) as ctr_total_return
+ from catalog_returns
+     ,date_dim
+     ,customer_address
+ where cr_returned_date_sk = d_date_sk 
+   and d_year =1998
+   and cr_returning_addr_sk = ca_address_sk 
+ group by cr_returning_customer_sk
+         ,ca_state )
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with customer_total_return as
+ (select cr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(cr_return_amt_inc_tax) as ctr_total_return
+ from catalog_returns
+     ,date_dim
+     ,customer_address
+ where cr_returned_date_sk = d_date_sk 
+   and d_year =1998
+   and cr_returning_addr_sk = ca_address_sk 
+ group by cr_returning_customer_sk
+         ,ca_state )
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(c_customer_id=[$0], c_salutation=[$1], c_first_name=[$2], c_last_name=[$3], ca_street_number=[$4], ca_street_name=[$5], ca_street_type=[$6], ca_suite_number=[$7], ca_city=[$8], ca_county=[$9], ca_state=[CAST(_UTF-16LE'IL'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], ca_zip=[$10], ca_country=[$11], ca_gmt_offset=[$12], ca_location_type=[$13], ctr_total_return=[$14])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], sort10=[$10], sort11=[$11], sort12=[$12], sort13=[$13], sort14=[$14], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], dir10=[ASC], dir11=[ASC], dir12=[ASC], dir13=[ASC], dir14=[ASC], fetch=[100])
+    HiveProject(c_customer_id=[$1], c_salutation=[$3], c_first_name=[$4], c_last_name=[$5], ca_street_number=[$7], ca_street_name=[$8], ca_street_type=[$9], ca_suite_number=[$10], ca_city=[$11], ca_county=[$12], ca_zip=[$14], ca_country=[$15], ca_gmt_offset=[$16], ca_location_type=[$17], ctr_total_return=[$20])
+      HiveJoin(condition=[=($18, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($6, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_current_addr_sk=[$4], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9])
+            HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+          HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_street_type=[$4], ca_suite_number=[$5], ca_city=[$6], ca_county=[$7], ca_state=[CAST(_UTF-16LE'IL'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], ca_zip=[$9], ca_country=[$10], ca_gmt_offset=[$11], ca_location_type=[$12])
+            HiveFilter(condition=[AND(=($8, _UTF-16LE'IL'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+        HiveProject(cr_returning_customer_sk=[$0], ca_state=[$1], $f2=[$2], _o__c0=[$3], ctr_state=[$4])
+          HiveJoin(condition=[AND(=($1, $4), >($2, $3))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cr_returning_customer_sk=[$1], ca_state=[$0], $f2=[$2])
+              HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+                HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($8))])
+                      HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$7], cr_returning_addr_sk=[$10], cr_return_amt_inc_tax=[$20])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER])
+                      HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(_o__c0=[*(/($1, $2), 1.2)], ctr_state=[$0])
+              HiveAggregate(group=[{0}], agg#0=[sum($2)], agg#1=[count($2)])
+                HiveProject(ca_state=[$0], cr_returning_customer_sk=[$1], $f2=[$2])
+                  HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+                    HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($8))])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$7], cr_returning_addr_sk=[$10], cr_return_amt_inc_tax=[$20])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10))])
+                            HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                        HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER])
+                          HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out
new file mode 100644
index 0000000..08d9992
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query82.q.out
@@ -0,0 +1,63 @@
+PREHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, store_sales
+ where i_current_price between 30 and 30+30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
+ and i_manufact_id in (437,129,727,663)
+ and inv_quantity_on_hand between 100 and 500
+ and ss_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, store_sales
+ where i_current_price between 30 and 30+30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
+ and i_manufact_id in (437,129,727,663)
+ and inv_quantity_on_hand between 100 and 500
+ and ss_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], i_current_price=[$2])
+    HiveAggregate(group=[{2, 3, 4}])
+      HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_item_sk=[$2])
+            HiveFilter(condition=[IS NOT NULL($2)])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_manufact_id=[$13])
+            HiveFilter(condition=[AND(IN($13, 437, 129, 727, 663), BETWEEN(false, $5, 30, 60), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_quantity_on_hand=[$2], d_date_sk=[$3], d_date=[$4])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_quantity_on_hand=[$3])
+              HiveFilter(condition=[AND(BETWEEN(false, $3, 100, 500), IS NOT NULL($1), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+            HiveProject(d_date_sk=[$0], d_date=[$2])
+              HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 2002-05-30 00:00:00, 2002-07-29 00:00:00), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out
new file mode 100644
index 0000000..d5a3d66
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query83.q.out
@@ -0,0 +1,222 @@
+PREHOOK: query: explain cbo
+with sr_items as
+ (select i_item_id item_id,
+        sum(sr_return_quantity) sr_item_qty
+ from store_returns,
+      item,
+      date_dim
+ where sr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   sr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+        sum(cr_return_quantity) cr_item_qty
+ from catalog_returns,
+      item,
+      date_dim
+ where cr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   cr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+        sum(wr_return_quantity) wr_item_qty
+ from web_returns,
+      item,
+      date_dim
+ where wr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+		where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   wr_returned_date_sk   = d_date_sk
+ group by i_item_id)
+  select  sr_items.item_id
+       ,sr_item_qty
+       ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev
+       ,cr_item_qty
+       ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev
+       ,wr_item_qty
+       ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev
+       ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average
+ from sr_items
+     ,cr_items
+     ,wr_items
+ where sr_items.item_id=cr_items.item_id
+   and sr_items.item_id=wr_items.item_id 
+ order by sr_items.item_id
+         ,sr_item_qty
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@web_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with sr_items as
+ (select i_item_id item_id,
+        sum(sr_return_quantity) sr_item_qty
+ from store_returns,
+      item,
+      date_dim
+ where sr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   sr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+        sum(cr_return_quantity) cr_item_qty
+ from catalog_returns,
+      item,
+      date_dim
+ where cr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   cr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+        sum(wr_return_quantity) wr_item_qty
+ from web_returns,
+      item,
+      date_dim
+ where wr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+		where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   wr_returned_date_sk   = d_date_sk
+ group by i_item_id)
+  select  sr_items.item_id
+       ,sr_item_qty
+       ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev
+       ,cr_item_qty
+       ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev
+       ,wr_item_qty
+       ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev
+       ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average
+ from sr_items
+     ,cr_items
+     ,wr_items
+ where sr_items.item_id=cr_items.item_id
+   and sr_items.item_id=wr_items.item_id 
+ order by sr_items.item_id
+         ,sr_item_qty
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(item_id=[$0], sr_item_qty=[$3], sr_dev=[*(/(/(CAST($3):DOUBLE, CAST(+(+($3, $1), $5)):DOUBLE), CAST(3):DOUBLE), CAST(100):DOUBLE)], cr_item_qty=[$1], cr_dev=[*(/(/(CAST($1):DOUBLE, CAST(+(+($3, $1), $5)):DOUBLE), CAST(3):DOUBLE), CAST(100):DOUBLE)], wr_item_qty=[$5], wr_dev=[*(/(/(CAST($5):DOUBLE, CAST(+(+($3, $1), $5)):DOUBLE), CAST(3):DOUBLE), CAST(100):DOUBLE)], average=[/(CAST(+(+($3, $1), $5)):DECIMAL(19, 0), 3)])
+    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_id=[$0], $f1=[$1])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cr_returned_date_sk=[$0], cr_item_sk=[$2], cr_return_quantity=[$17])
+                  HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveSemiJoin(condition=[=($1, $6)], joinType=[inner])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(d_date_sk=[$0], d_date_id=[$1], d_date=[$2], d_month_seq=[$3], d_week_seq=[$4], d_quarter_seq=[$5], d_year=[$6], d_dow=[$7], d_moy=[$8], d_dom=[$9], d_qoy=[$10], d_fy_year=[$11], d_fy_quarter_seq=[$12], d_fy_week_seq=[$13], d_day_name=[$14], d_quarter_name=[$15], d_holiday=[$16], d_weekend=[$17], d_following_holiday=[$18], d_first_dom=[$19], d_last_dom=[$20], d_same_day_ly=[$21], d_same_day_lq=[$22], d_current_day=[$23], d_current_week=[$24], d_current_month=[$25], d_current_quarter=[$26], d_current_year=[$27], BLOCK__OFFSET__INSIDE__FILE=[$28], INPUT__FILE__NAME=[$29], ROW__ID=[$30])
+                          HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(i_item_id=[$0], $f1=[$1])
+          HiveAggregate(group=[{4}], agg#0=[sum($2)])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_return_quantity=[$10])
+                  HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(d_date=[$0])
+                    HiveAggregate(group=[{0}])
+                      HiveSemiJoin(condition=[=($1, $6)], joinType=[inner])
+                        HiveProject(d_date=[$2], d_week_seq=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(d_date_sk=[$0], d_date_id=[$1], d_date=[$2], d_month_seq=[$3], d_week_seq=[$4], d_quarter_seq=[$5], d_year=[$6], d_dow=[$7], d_moy=[$8], d_dom=[$9], d_qoy=[$10], d_fy_year=[$11], d_fy_quarter_seq=[$12], d_fy_week_seq=[$13], d_day_name=[$14], d_quarter_name=[$15], d_holiday=[$16], d_weekend=[$17], d_following_holiday=[$18], d_first_dom=[$19], d_last_dom=[$20], d_same_day_ly=[$21], d_same_day_lq=[$22], d_current_day=[$23], d_current_week=[$24], d_current_month=[$25], d_current_quarter=[$26], d_current_year=[$27], BLOCK__OFFSET__INSIDE__FILE=[$28], INPUT__FILE__NAME=[$29], ROW__ID=[$30])
+                          HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(i_item_id=[$0], $f1=[$1])
+        HiveAggregate(group=[{4}], agg#0=[sum($2)])
+          HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(wr_returned_date_sk=[$0], wr_item_sk=[$2], wr_return_quantity=[$14])
+                HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+            HiveProject(d_date_sk=[$0], d_date=[$1], d_date0=[$2])
+              HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0], d_date=[$2])
+                  HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(d_date=[$0])
+                  HiveAggregate(group=[{0}])
+                    HiveSemiJoin(condition=[=($1, $6)], joinType=[inner])
+                      HiveProject(d_date=[$2], d_week_seq=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(d_date_sk=[$0], d_date_id=[$1], d_date=[$2], d_month_seq=[$3], d_week_seq=[$4], d_quarter_seq=[$5], d_year=[$6], d_dow=[$7], d_moy=[$8], d_dom=[$9], d_qoy=[$10], d_fy_year=[$11], d_fy_quarter_seq=[$12], d_fy_week_seq=[$13], d_day_name=[$14], d_quarter_name=[$15], d_holiday=[$16], d_weekend=[$17], d_following_holiday=[$18], d_first_dom=[$19], d_last_dom=[$20], d_same_day_ly=[$21], d_same_day_lq=[$22], d_current_day=[$23], d_current_week=[$24], d_current_month=[$25], d_current_quarter=[$26], d_current_year=[$27], BLOCK__OFFSET__INSIDE__FILE=[$28], INPUT__FILE__NAME=[$29], ROW__ID=[$30])
+                        HiveFilter(condition=[AND(IN($2, _UTF-16LE'1998-01-02', _UTF-16LE'1998-10-15', _UTF-16LE'1998-11-10'), IS NOT NULL($4))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query84.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query84.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query84.q.out
new file mode 100644
index 0000000..de765ab
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query84.q.out
@@ -0,0 +1,84 @@
+PREHOOK: query: explain cbo
+select  c_customer_id as customer_id
+       ,c_last_name || ', ' || c_first_name as customername
+ from customer
+     ,customer_address
+     ,customer_demographics
+     ,household_demographics
+     ,income_band
+     ,store_returns
+ where ca_city	        =  'Hopewell'
+   and c_current_addr_sk = ca_address_sk
+   and ib_lower_bound   >=  32287
+   and ib_upper_bound   <=  32287 + 50000
+   and ib_income_band_sk = hd_income_band_sk
+   and cd_demo_sk = c_current_cdemo_sk
+   and hd_demo_sk = c_current_hdemo_sk
+   and sr_cdemo_sk = cd_demo_sk
+ order by c_customer_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@income_band
+PREHOOK: Input: default@store_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  c_customer_id as customer_id
+       ,c_last_name || ', ' || c_first_name as customername
+ from customer
+     ,customer_address
+     ,customer_demographics
+     ,household_demographics
+     ,income_band
+     ,store_returns
+ where ca_city	        =  'Hopewell'
+   and c_current_addr_sk = ca_address_sk
+   and ib_lower_bound   >=  32287
+   and ib_upper_bound   <=  32287 + 50000
+   and ib_income_band_sk = hd_income_band_sk
+   and cd_demo_sk = c_current_cdemo_sk
+   and hd_demo_sk = c_current_hdemo_sk
+   and sr_cdemo_sk = cd_demo_sk
+ order by c_customer_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@income_band
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(customer_id=[$0], customername=[$1])
+  HiveSortLimit(sort0=[$2], dir0=[ASC], fetch=[100])
+    HiveProject(customer_id=[$2], customername=[||(||($7, _UTF-16LE', '), $6)], c_customer_id=[$2])
+      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(sr_cdemo_sk=[$4])
+            HiveFilter(condition=[IS NOT NULL($4)])
+              HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+          HiveProject(cd_demo_sk=[$0])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+        HiveProject(c_customer_id=[$0], c_current_cdemo_sk=[$1], c_current_hdemo_sk=[$2], c_current_addr_sk=[$3], c_first_name=[$4], c_last_name=[$5], ca_address_sk=[$6], ca_city=[$7], hd_demo_sk=[$8], hd_income_band_sk=[$9], ib_income_band_sk=[$10], ib_lower_bound=[$11], ib_upper_bound=[$12])
+          HiveJoin(condition=[=($8, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_id=[$1], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9])
+                HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2), IS NOT NULL($3))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveProject(ca_address_sk=[$0], ca_city=[CAST(_UTF-16LE'Hopewell'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                HiveFilter(condition=[AND(=($6, _UTF-16LE'Hopewell'), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1], ib_income_band_sk=[$2], ib_lower_bound=[$3], ib_upper_bound=[$4])
+              HiveJoin(condition=[=($2, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(ib_income_band_sk=[$0], ib_lower_bound=[$1], ib_upper_bound=[$2])
+                  HiveFilter(condition=[AND(>=($1, 32287), <=($2, 82287), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, income_band]], table:alias=[income_band])
+


[06/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out
new file mode 100644
index 0000000..78f7c28
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query77.q.out
@@ -0,0 +1,504 @@
+Warning: Shuffle Join MERGEJOIN[225][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 14' is a cross product
+PREHOOK: query: explain
+with ss as
+ (select s_store_sk,
+         sum(ss_ext_sales_price) as sales,
+         sum(ss_net_profit) as profit
+ from store_sales,
+      date_dim,
+      store
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days) 
+       and ss_store_sk = s_store_sk
+ group by s_store_sk)
+ ,
+ sr as
+ (select s_store_sk,
+         sum(sr_return_amt) as returns,
+         sum(sr_net_loss) as profit_loss
+ from store_returns,
+      date_dim,
+      store
+ where sr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and sr_store_sk = s_store_sk
+ group by s_store_sk), 
+ cs as
+ (select cs_call_center_sk,
+        sum(cs_ext_sales_price) as sales,
+        sum(cs_net_profit) as profit
+ from catalog_sales,
+      date_dim
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ group by cs_call_center_sk 
+ ), 
+ cr as
+ (select
+        sum(cr_return_amount) as returns,
+        sum(cr_net_loss) as profit_loss
+ from catalog_returns,
+      date_dim
+ where cr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ ), 
+ ws as
+ ( select wp_web_page_sk,
+        sum(ws_ext_sales_price) as sales,
+        sum(ws_net_profit) as profit
+ from web_sales,
+      date_dim,
+      web_page
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ws_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk), 
+ wr as
+ (select wp_web_page_sk,
+        sum(wr_return_amt) as returns,
+        sum(wr_net_loss) as profit_loss
+ from web_returns,
+      date_dim,
+      web_page
+ where wr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and wr_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , ss.s_store_sk as id
+        , sales
+        , coalesce(returns, 0) as returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ss left join sr
+        on  ss.s_store_sk = sr.s_store_sk
+ union all
+ select 'catalog channel' as channel
+        , cs_call_center_sk as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  cs
+       , cr
+ union all
+ select 'web channel' as channel
+        , ws.wp_web_page_sk as id
+        , sales
+        , coalesce(returns, 0) returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ws left join wr
+        on  ws.wp_web_page_sk = wr.wp_web_page_sk
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with ss as
+ (select s_store_sk,
+         sum(ss_ext_sales_price) as sales,
+         sum(ss_net_profit) as profit
+ from store_sales,
+      date_dim,
+      store
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days) 
+       and ss_store_sk = s_store_sk
+ group by s_store_sk)
+ ,
+ sr as
+ (select s_store_sk,
+         sum(sr_return_amt) as returns,
+         sum(sr_net_loss) as profit_loss
+ from store_returns,
+      date_dim,
+      store
+ where sr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and sr_store_sk = s_store_sk
+ group by s_store_sk), 
+ cs as
+ (select cs_call_center_sk,
+        sum(cs_ext_sales_price) as sales,
+        sum(cs_net_profit) as profit
+ from catalog_sales,
+      date_dim
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ group by cs_call_center_sk 
+ ), 
+ cr as
+ (select
+        sum(cr_return_amount) as returns,
+        sum(cr_net_loss) as profit_loss
+ from catalog_returns,
+      date_dim
+ where cr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ ), 
+ ws as
+ ( select wp_web_page_sk,
+        sum(ws_ext_sales_price) as sales,
+        sum(ws_net_profit) as profit
+ from web_sales,
+      date_dim,
+      web_page
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ws_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk), 
+ wr as
+ (select wp_web_page_sk,
+        sum(wr_return_amt) as returns,
+        sum(wr_net_loss) as profit_loss
+ from web_returns,
+      date_dim,
+      web_page
+ where wr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and wr_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , ss.s_store_sk as id
+        , sales
+        , coalesce(returns, 0) as returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ss left join sr
+        on  ss.s_store_sk = sr.s_store_sk
+ union all
+ select 'catalog channel' as channel
+        , cs_call_center_sk as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  cs
+       , cr
+ union all
+ select 'web channel' as channel
+        , ws.wp_web_page_sk as id
+        , sales
+        , coalesce(returns, 0) returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ws left join wr
+        on  ws.wp_web_page_sk = wr.wp_web_page_sk
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 9 (BROADCAST_EDGE)
+Map 25 <- Reducer 15 (BROADCAST_EDGE)
+Map 27 <- Reducer 21 (BROADCAST_EDGE)
+Reducer 10 <- Map 24 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Map 25 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (CUSTOM_SIMPLE_EDGE), Reducer 17 (CUSTOM_SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 15 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Map 26 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 27 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (ONE_TO_ONE_EDGE), Reducer 23 (ONE_TO_ONE_EDGE), Union 5 (CONTAINS)
+Reducer 21 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 22 <- Map 28 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 23 <- Reducer 22 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 11 (ONE_TO_ONE_EDGE), Reducer 3 (ONE_TO_ONE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_271]
+        Limit [LIM_270] (rows=24 width=437)
+          Number of rows:100
+          Select Operator [SEL_269] (rows=24 width=437)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_268]
+              Select Operator [SEL_267] (rows=24 width=437)
+                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Group By Operator [GBY_266] (rows=24 width=445)
+                  Output:["_col0","_col1","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2
+                <-Union 5 [SIMPLE_EDGE]
+                  <-Reducer 14 [CONTAINS]
+                    Reduce Output Operator [RS_230]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_229] (rows=58 width=445)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_228] (rows=39 width=435)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_226] (rows=2 width=439)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Merge Join Operator [MERGEJOIN_225] (rows=2 width=452)
+                              Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4"]
+                            <-Reducer 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_278]
+                                Group By Operator [GBY_277] (rows=2 width=228)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                                <-Reducer 12 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_45]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_44] (rows=56 width=227)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","sum(_col3)"],keys:_col1
+                                      Merge Join Operator [MERGEJOIN_212] (rows=31836679 width=222)
+                                        Conds:RS_276._col0=RS_242._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_242]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_238] (rows=8116 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_237] (rows=8116 width=98)
+                                              predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-08-04 00:00:00' AND TIMESTAMP'1998-09-03 00:00:00'
+                                              TableScan [TS_3] (rows=73049 width=98)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                      <-Map 25 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_276]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_275] (rows=286549727 width=231)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_274] (rows=286549727 width=231)
+                                              predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_41_date_dim_d_date_sk_min) AND DynamicValue(RS_41_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_41_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                              TableScan [TS_34] (rows=287989836 width=231)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_call_center_sk","cs_ext_sales_price","cs_net_profit"]
+                                              <-Reducer 15 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_273]
+                                                  Group By Operator [GBY_272] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_252]
+                                                      Group By Operator [GBY_249] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_243] (rows=8116 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_238]
+                            <-Reducer 17 [CUSTOM_SIMPLE_EDGE] vectorized
+                              PARTITION_ONLY_SHUFFLE [RS_283]
+                                Group By Operator [GBY_282] (rows=1 width=224)
+                                  Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"]
+                                <-Reducer 16 [CUSTOM_SIMPLE_EDGE]
+                                  PARTITION_ONLY_SHUFFLE [RS_59]
+                                    Group By Operator [GBY_58] (rows=1 width=224)
+                                      Output:["_col0","_col1"],aggregations:["sum(_col1)","sum(_col2)"]
+                                      Merge Join Operator [MERGEJOIN_213] (rows=3199657 width=183)
+                                        Conds:RS_281._col0=RS_244._col0(Inner),Output:["_col1","_col2"]
+                                      <-Map 8 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_244]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_238]
+                                      <-Map 26 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_281]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_280] (rows=28798881 width=223)
+                                            Output:["_col0","_col1","_col2"]
+                                            Filter Operator [FIL_279] (rows=28798881 width=223)
+                                              predicate:cr_returned_date_sk is not null
+                                              TableScan [TS_48] (rows=28798881 width=223)
+                                                default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_returned_date_sk","cr_return_amount","cr_net_loss"]
+                  <-Reducer 20 [CONTAINS]
+                    Reduce Output Operator [RS_236]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_235] (rows=58 width=445)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_234] (rows=39 width=435)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_232] (rows=25 width=435)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Merge Join Operator [MERGEJOIN_231] (rows=25 width=452)
+                              Conds:RS_290._col0=RS_295._col0(Left Outer),Output:["_col0","_col1","_col2","_col4","_col5"]
+                            <-Reducer 19 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_290]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_289] (rows=24 width=228)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                                <-Reducer 18 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_79]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_78] (rows=360 width=228)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","sum(_col2)"],keys:_col0
+                                      Select Operator [SEL_76] (rows=15991254 width=227)
+                                        Output:["_col0","_col1","_col2"]
+                                        Merge Join Operator [MERGEJOIN_214] (rows=15991254 width=227)
+                                          Conds:RS_288._col0=RS_245._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_245]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_238]
+                                        <-Map 27 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_288]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_287] (rows=143931136 width=231)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_286] (rows=143931136 width=231)
+                                                predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_74_date_dim_d_date_sk_min) AND DynamicValue(RS_74_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_74_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null and ws_web_page_sk is not null)
+                                                TableScan [TS_67] (rows=144002668 width=231)
+                                                  default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_web_page_sk","ws_ext_sales_price","ws_net_profit"]
+                                                <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_285]
+                                                    Group By Operator [GBY_284] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_253]
+                                                        Group By Operator [GBY_250] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_246] (rows=8116 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_238]
+                            <-Reducer 23 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_295]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_294] (rows=24 width=226)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                                <-Reducer 22 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_94]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_93] (rows=24 width=226)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","sum(_col2)"],keys:_col0
+                                      Select Operator [SEL_91] (rows=1458758 width=135)
+                                        Output:["_col0","_col1","_col2"]
+                                        Merge Join Operator [MERGEJOIN_215] (rows=1458758 width=135)
+                                          Conds:RS_293._col0=RS_247._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_247]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_238]
+                                        <-Map 28 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_293]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_292] (rows=13129719 width=221)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_291] (rows=13129719 width=221)
+                                                predicate:(wr_returned_date_sk is not null and wr_web_page_sk is not null)
+                                                TableScan [TS_82] (rows=14398467 width=221)
+                                                  default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_returned_date_sk","wr_web_page_sk","wr_return_amt","wr_net_loss"]
+                  <-Reducer 4 [CONTAINS]
+                    Reduce Output Operator [RS_224]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_223] (rows=58 width=445)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_222] (rows=39 width=435)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_220] (rows=12 width=436)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Merge Join Operator [MERGEJOIN_219] (rows=12 width=451)
+                              Conds:RS_260._col0=RS_265._col0(Left Outer),Output:["_col0","_col1","_col2","_col4","_col5"]
+                            <-Reducer 11 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_265]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_264] (rows=11 width=226)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                                <-Reducer 10 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_27]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_26] (rows=44 width=226)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","sum(_col2)"],keys:_col0
+                                      Select Operator [SEL_24] (rows=5959021 width=156)
+                                        Output:["_col0","_col1","_col2"]
+                                        Merge Join Operator [MERGEJOIN_211] (rows=5959021 width=156)
+                                          Conds:RS_263._col0=RS_241._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_241]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_238]
+                                        <-Map 24 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_263]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_262] (rows=53634860 width=223)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_261] (rows=53634860 width=223)
+                                                predicate:(sr_returned_date_sk is not null and sr_store_sk is not null)
+                                                TableScan [TS_15] (rows=57591150 width=223)
+                                                  default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_returned_date_sk","sr_store_sk","sr_return_amt","sr_net_loss"]
+                            <-Reducer 3 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_260]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_259] (rows=11 width=226)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_12]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_11] (rows=341 width=226)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col1)","sum(_col2)"],keys:_col0
+                                      Select Operator [SEL_9] (rows=58365993 width=135)
+                                        Output:["_col0","_col1","_col2"]
+                                        Merge Join Operator [MERGEJOIN_210] (rows=58365993 width=135)
+                                          Conds:RS_258._col0=RS_239._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_239]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_238]
+                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_258]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_257] (rows=525329897 width=221)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_256] (rows=525329897 width=221)
+                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_7_date_dim_d_date_sk_min) AND DynamicValue(RS_7_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_7_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_0] (rows=575995635 width=221)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_store_sk","ss_ext_sales_price","ss_net_profit"]
+                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_255]
+                                                    Group By Operator [GBY_254] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_251]
+                                                        Group By Operator [GBY_248] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_240] (rows=8116 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_238]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query78.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query78.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query78.q.out
new file mode 100644
index 0000000..ef4d6db
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query78.q.out
@@ -0,0 +1,345 @@
+PREHOOK: query: explain
+with ws as
+  (select d_year AS ws_sold_year, ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+   from web_sales
+   left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk
+   join date_dim on ws_sold_date_sk = d_date_sk
+   where wr_order_number is null
+   group by d_year, ws_item_sk, ws_bill_customer_sk
+   ),
+cs as
+  (select d_year AS cs_sold_year, cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+   from catalog_sales
+   left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk
+   join date_dim on cs_sold_date_sk = d_date_sk
+   where cr_order_number is null
+   group by d_year, cs_item_sk, cs_bill_customer_sk
+   ),
+ss as
+  (select d_year AS ss_sold_year, ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+   from store_sales
+   left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk
+   join date_dim on ss_sold_date_sk = d_date_sk
+   where sr_ticket_number is null
+   group by d_year, ss_item_sk, ss_customer_sk
+   )
+ select 
+ss_sold_year, ss_item_sk, ss_customer_sk,
+round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
+ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
+coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
+coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
+coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
+from ss
+left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
+order by 
+  ss_sold_year, ss_item_sk, ss_customer_sk,
+  ss_qty desc, ss_wc desc, ss_sp desc,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with ws as
+  (select d_year AS ws_sold_year, ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+   from web_sales
+   left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk
+   join date_dim on ws_sold_date_sk = d_date_sk
+   where wr_order_number is null
+   group by d_year, ws_item_sk, ws_bill_customer_sk
+   ),
+cs as
+  (select d_year AS cs_sold_year, cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+   from catalog_sales
+   left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk
+   join date_dim on cs_sold_date_sk = d_date_sk
+   where cr_order_number is null
+   group by d_year, cs_item_sk, cs_bill_customer_sk
+   ),
+ss as
+  (select d_year AS ss_sold_year, ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+   from store_sales
+   left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk
+   join date_dim on ss_sold_date_sk = d_date_sk
+   where sr_ticket_number is null
+   group by d_year, ss_item_sk, ss_customer_sk
+   )
+ select 
+ss_sold_year, ss_item_sk, ss_customer_sk,
+round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
+ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
+coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
+coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
+coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
+from ss
+left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
+order by 
+  ss_sold_year, ss_item_sk, ss_customer_sk,
+  ss_qty desc, ss_wc desc, ss_sp desc,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 14 <- Reducer 7 (BROADCAST_EDGE)
+Map 17 <- Reducer 10 (BROADCAST_EDGE)
+Map 20 <- Reducer 13 (BROADCAST_EDGE)
+Reducer 10 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Map 1 (SIMPLE_EDGE), Reducer 21 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Map 16 (SIMPLE_EDGE)
+Reducer 18 <- Map 17 (SIMPLE_EDGE), Map 19 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 21 <- Map 20 (SIMPLE_EDGE), Map 22 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (ONE_TO_ONE_EDGE), Reducer 9 (ONE_TO_ONE_EDGE)
+Reducer 5 <- Reducer 12 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Map 1 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_238]
+        Limit [LIM_237] (rows=100 width=484)
+          Number of rows:100
+          Select Operator [SEL_236] (rows=462576000046 width=483)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+          <-Reducer 5 [SIMPLE_EDGE]
+            SHUFFLE [RS_73]
+              Select Operator [SEL_72] (rows=462576000046 width=719)
+                Output:["_col0","_col1","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                Filter Operator [FIL_71] (rows=462576000046 width=702)
+                  predicate:CASE WHEN (_col11 is not null) THEN ((_col11 > 0L)) ELSE (false) END
+                  Merge Join Operator [MERGEJOIN_191] (rows=925152000093 width=702)
+                    Conds:RS_68._col1=RS_235._col0(Left Outer),Output:["_col0","_col1","_col2","_col3","_col4","_col7","_col8","_col9","_col11","_col12","_col13"]
+                  <-Reducer 12 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_235]
+                      PartitionCols:_col0
+                      Select Operator [SEL_234] (rows=101592102 width=235)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Group By Operator [GBY_233] (rows=101592102 width=239)
+                          Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1
+                        <-Reducer 11 [SIMPLE_EDGE]
+                          SHUFFLE [RS_65]
+                            PartitionCols:_col0, _col1
+                            Group By Operator [GBY_64] (rows=101592102 width=239)
+                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col4)","sum(_col5)","sum(_col6)"],keys:_col2, _col3
+                              Merge Join Operator [MERGEJOIN_189] (rows=101592102 width=233)
+                                Conds:RS_198._col0=RS_61._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6"]
+                              <-Map 1 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_198]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_193] (rows=652 width=4)
+                                    Output:["_col0"]
+                                    Filter Operator [FIL_192] (rows=652 width=8)
+                                      predicate:(d_year = 2000)
+                                      TableScan [TS_0] (rows=73049 width=8)
+                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                              <-Reducer 21 [SIMPLE_EDGE]
+                                SHUFFLE [RS_61]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_59] (rows=286549727 width=239)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                    Filter Operator [FIL_58] (rows=286549727 width=240)
+                                      predicate:_col8 is null
+                                      Merge Join Operator [MERGEJOIN_188] (rows=468719906 width=240)
+                                        Conds:RS_230._col2, _col3=RS_232._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col4","_col5","_col6","_col8"]
+                                      <-Map 20 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_230]
+                                          PartitionCols:_col2, _col3
+                                          Select Operator [SEL_229] (rows=286549727 width=242)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                            Filter Operator [FIL_228] (rows=286549727 width=242)
+                                              predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_60_date_dim_d_date_sk_min) AND DynamicValue(RS_60_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_60_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                              TableScan [TS_50] (rows=287989836 width=242)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_item_sk","cs_order_number","cs_quantity","cs_wholesale_cost","cs_sales_price"]
+                                              <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_227]
+                                                  Group By Operator [GBY_226] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 1 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_205]
+                                                      Group By Operator [GBY_202] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_199] (rows=652 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_193]
+                                      <-Map 22 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_232]
+                                          PartitionCols:_col0, _col1
+                                          Select Operator [SEL_231] (rows=28798881 width=8)
+                                            Output:["_col0","_col1"]
+                                            TableScan [TS_53] (rows=28798881 width=8)
+                                              default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_item_sk","cr_order_number"]
+                  <-Reducer 4 [SIMPLE_EDGE]
+                    SHUFFLE [RS_68]
+                      PartitionCols:_col1
+                      Filter Operator [FIL_45] (rows=4580227799 width=471)
+                        predicate:CASE WHEN (_col7 is not null) THEN ((_col7 > 0L)) ELSE (false) END
+                        Merge Join Operator [MERGEJOIN_190] (rows=9160455599 width=471)
+                          Conds:RS_215._col1, _col0=RS_225._col1, _col0(Left Outer),Output:["_col0","_col1","_col2","_col3","_col4","_col7","_col8","_col9"]
+                        <-Reducer 3 [ONE_TO_ONE_EDGE] vectorized
+                          FORWARD [RS_215]
+                            PartitionCols:_col1, _col0
+                            Select Operator [SEL_214] (rows=114214965 width=239)
+                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                              Group By Operator [GBY_213] (rows=114214965 width=239)
+                                Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_18]
+                                  PartitionCols:_col0, _col1
+                                  Group By Operator [GBY_17] (rows=114214965 width=239)
+                                    Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col4)","sum(_col5)","sum(_col6)"],keys:_col3, _col2
+                                    Merge Join Operator [MERGEJOIN_185] (rows=114214965 width=217)
+                                      Conds:RS_194._col0=RS_14._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_194]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_193]
+                                    <-Reducer 15 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_14]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_12] (rows=319876350 width=233)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                          Filter Operator [FIL_11] (rows=319876350 width=235)
+                                            predicate:_col8 is null
+                                            Merge Join Operator [MERGEJOIN_184] (rows=883006376 width=235)
+                                              Conds:RS_210._col1, _col3=RS_212._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col4","_col5","_col6","_col8"]
+                                            <-Map 14 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_210]
+                                                PartitionCols:_col1, _col3
+                                                Select Operator [SEL_209] (rows=550076554 width=233)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                  Filter Operator [FIL_208] (rows=550076554 width=233)
+                                                    predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_13_date_dim_d_date_sk_min) AND DynamicValue(RS_13_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_13_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                    TableScan [TS_3] (rows=575995635 width=233)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_ticket_number","ss_quantity","ss_wholesale_cost","ss_sales_price"]
+                                                    <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_207]
+                                                        Group By Operator [GBY_206] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 1 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_203]
+                                                            Group By Operator [GBY_200] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_195] (rows=652 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_193]
+                                            <-Map 16 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_212]
+                                                PartitionCols:_col0, _col1
+                                                Select Operator [SEL_211] (rows=57591150 width=8)
+                                                  Output:["_col0","_col1"]
+                                                  TableScan [TS_6] (rows=57591150 width=8)
+                                                    default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number"]
+                        <-Reducer 9 [ONE_TO_ONE_EDGE] vectorized
+                          FORWARD [RS_225]
+                            PartitionCols:_col1, _col0
+                            Select Operator [SEL_224] (rows=40539971 width=239)
+                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                              Group By Operator [GBY_223] (rows=40539971 width=239)
+                                Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1
+                              <-Reducer 8 [SIMPLE_EDGE]
+                                SHUFFLE [RS_39]
+                                  PartitionCols:_col0, _col1
+                                  Group By Operator [GBY_38] (rows=40539971 width=239)
+                                    Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col4)","sum(_col5)","sum(_col6)"],keys:_col3, _col2
+                                    Merge Join Operator [MERGEJOIN_187] (rows=40539971 width=235)
+                                      Conds:RS_196._col0=RS_35._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_196]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_193]
+                                    <-Reducer 18 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_35]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_33] (rows=113538342 width=239)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                          Filter Operator [FIL_32] (rows=113538342 width=242)
+                                            predicate:_col8 is null
+                                            Merge Join Operator [MERGEJOIN_186] (rows=254679677 width=242)
+                                              Conds:RS_220._col1, _col3=RS_222._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col4","_col5","_col6","_col8"]
+                                            <-Map 17 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_220]
+                                                PartitionCols:_col1, _col3
+                                                Select Operator [SEL_219] (rows=143966864 width=243)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                  Filter Operator [FIL_218] (rows=143966864 width=243)
+                                                    predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_34_date_dim_d_date_sk_min) AND DynamicValue(RS_34_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_34_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                                    TableScan [TS_24] (rows=144002668 width=243)
+                                                      default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_customer_sk","ws_order_number","ws_quantity","ws_wholesale_cost","ws_sales_price"]
+                                                    <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_217]
+                                                        Group By Operator [GBY_216] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 1 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_204]
+                                                            Group By Operator [GBY_201] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_197] (rows=652 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_193]
+                                            <-Map 19 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_222]
+                                                PartitionCols:_col0, _col1
+                                                Select Operator [SEL_221] (rows=14398467 width=8)
+                                                  Output:["_col0","_col1"]
+                                                  TableScan [TS_27] (rows=14398467 width=8)
+                                                    default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_item_sk","wr_order_number"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query79.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query79.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query79.q.out
new file mode 100644
index 0000000..fb94428
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query79.q.out
@@ -0,0 +1,175 @@
+PREHOOK: query: explain
+select 
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
+  from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,store.s_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
+    and date_dim.d_dow = 1
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_number_employees between 200 and 295
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
+    where ss_customer_sk = c_customer_sk
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select 
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
+  from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,store.s_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
+    and date_dim.d_dow = 1
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_number_employees between 200 and 295
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
+    where ss_customer_sk = c_customer_sk
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 4 <- Reducer 10 (BROADCAST_EDGE), Reducer 13 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 5 <- Map 4 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 6 <- Map 11 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 12 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 3 vectorized
+      File Output Operator [FS_129]
+        Limit [LIM_128] (rows=100 width=776)
+          Number of rows:100
+          Select Operator [SEL_127] (rows=43530621 width=776)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          <-Reducer 2 [SIMPLE_EDGE]
+            SHUFFLE [RS_32]
+              Select Operator [SEL_31] (rows=43530621 width=776)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                Merge Join Operator [MERGEJOIN_99] (rows=43530621 width=685)
+                  Conds:RS_101._col0=RS_126._col1(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col7","_col8"]
+                <-Map 1 [SIMPLE_EDGE] vectorized
+                  SHUFFLE [RS_101]
+                    PartitionCols:_col0
+                    Select Operator [SEL_100] (rows=80000000 width=184)
+                      Output:["_col0","_col1","_col2"]
+                      TableScan [TS_0] (rows=80000000 width=184)
+                        default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_first_name","c_last_name"]
+                <-Reducer 8 [SIMPLE_EDGE] vectorized
+                  SHUFFLE [RS_126]
+                    PartitionCols:_col1
+                    Select Operator [SEL_125] (rows=43530621 width=507)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                      Group By Operator [GBY_124] (rows=43530621 width=325)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+                      <-Reducer 7 [SIMPLE_EDGE]
+                        SHUFFLE [RS_25]
+                          PartitionCols:_col0, _col1, _col2, _col3
+                          Group By Operator [GBY_24] (rows=43530621 width=325)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col6)","sum(_col7)"],keys:_col1, _col3, _col5, _col10
+                            Merge Join Operator [MERGEJOIN_98] (rows=43530621 width=214)
+                              Conds:RS_20._col2=RS_112._col0(Inner),Output:["_col1","_col3","_col5","_col6","_col7","_col10"]
+                            <-Map 12 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_112]
+                                PartitionCols:_col0
+                                Select Operator [SEL_111] (rows=3055 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_110] (rows=3055 width=12)
+                                    predicate:((hd_dep_count = 8) or (hd_vehicle_count > 0))
+                                    TableScan [TS_11] (rows=7200 width=12)
+                                      default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_dep_count","hd_vehicle_count"]
+                            <-Reducer 6 [SIMPLE_EDGE]
+                              SHUFFLE [RS_20]
+                                PartitionCols:_col2
+                                Merge Join Operator [MERGEJOIN_97] (rows=102592623 width=283)
+                                  Conds:RS_17._col4=RS_123._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col7","_col10"]
+                                <-Map 11 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_123]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_122] (rows=1704 width=97)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_121] (rows=1704 width=100)
+                                        predicate:s_number_employees BETWEEN 200 AND 295
+                                        TableScan [TS_8] (rows=1704 width=100)
+                                          default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_number_employees","s_city"]
+                                <-Reducer 5 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_17]
+                                    PartitionCols:_col4
+                                    Merge Join Operator [MERGEJOIN_96] (rows=102592623 width=193)
+                                      Conds:RS_120._col0=RS_104._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                    <-Map 9 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_104]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_103] (rows=391 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_102] (rows=391 width=12)
+                                            predicate:((d_dow = 1) and (d_year) IN (1998, 1999, 2000))
+                                            TableScan [TS_5] (rows=73049 width=12)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_dow"]
+                                    <-Map 4 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_120]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_119] (rows=479121995 width=237)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                          Filter Operator [FIL_118] (rows=479121995 width=237)
+                                            predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_21_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_21_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_21_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_hdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                            TableScan [TS_2] (rows=575995635 width=237)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_hdemo_sk","ss_addr_sk","ss_store_sk","ss_ticket_number","ss_coupon_amt","ss_net_profit"]
+                                            <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_109]
+                                                Group By Operator [GBY_108] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_107]
+                                                    Group By Operator [GBY_106] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_105] (rows=391 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_103]
+                                            <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_117]
+                                                Group By Operator [GBY_116] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_115]
+                                                    Group By Operator [GBY_114] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_113] (rows=3055 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_111]
+


[60/75] [abbrv] hive git commit: HIVE-20420: Provide a fallback authorizer when no other authorizer is in use (Daniel Dai, reviewed by Laszlo Pinter, Thejas Nair)

Posted by se...@apache.org.
HIVE-20420: Provide a fallback authorizer when no other authorizer is in use (Daniel Dai, reviewed by Laszlo Pinter, Thejas Nair)

Signed-off-by: Thejas M Nair <th...@hortonworks.com>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/1a1d6ca1
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/1a1d6ca1
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/1a1d6ca1

Branch: refs/heads/master-tez092
Commit: 1a1d6ca1bc3ae840238dc345fa1eb2c7c28c8cb0
Parents: 72349bb
Author: Daniel Dai <da...@gmail.com>
Authored: Tue Oct 23 16:30:41 2018 -0700
Committer: Daniel Dai <da...@gmail.com>
Committed: Tue Oct 23 16:31:25 2018 -0700

----------------------------------------------------------------------
 ql/pom.xml                                      |  13 +
 .../plugin/SettableConfigUpdater.java           |   2 +-
 .../plugin/fallback/FallbackHiveAuthorizer.java | 253 +++++++++++++++++++
 .../fallback/FallbackHiveAuthorizerFactory.java |  36 +++
 .../clientnegative/fallbackauth_addjar.q        |   4 +
 .../clientnegative/fallbackauth_compile.q       |   9 +
 .../clientnegative/fallbackauth_create_func1.q  |   5 +
 .../clientnegative/fallbackauth_create_func2.q  |   6 +
 .../queries/clientnegative/fallbackauth_dfs.q   |   4 +
 .../fallbackauth_disallow_transform.q           |   6 +
 .../queries/clientnegative/fallbackauth_load.q  |  15 ++
 .../fallbackauth_set_invalidconf.q              |   8 +
 .../clientnegative/fallbackauth_addjar.q.out    |   1 +
 .../clientnegative/fallbackauth_compile.q.out   |   1 +
 .../fallbackauth_create_func1.q.out             |   1 +
 .../fallbackauth_create_func2.q.out             |   1 +
 .../clientnegative/fallbackauth_dfs.q.out       |   1 +
 .../fallbackauth_disallow_transform.q.out       |  16 ++
 .../clientnegative/fallbackauth_load.q.out      |   9 +
 .../fallbackauth_set_invalidconf.q.out          |   7 +
 20 files changed, 397 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/pom.xml
----------------------------------------------------------------------
diff --git a/ql/pom.xml b/ql/pom.xml
index d73deba..8c3e55e 100644
--- a/ql/pom.xml
+++ b/ql/pom.xml
@@ -904,6 +904,19 @@
               <classifier>core</classifier>
             </configuration>
           </execution>
+          <execution>
+            <id>fallbackauthorizer-jar</id>
+            <phase>package</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+            <configuration>
+              <classifier>fallbackauthorizer</classifier>
+              <includes>
+                <include>org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/*.class</include>
+              </includes>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
       <plugin>

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/SettableConfigUpdater.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/SettableConfigUpdater.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/SettableConfigUpdater.java
index 12be41c..861fcde 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/SettableConfigUpdater.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/SettableConfigUpdater.java
@@ -63,7 +63,7 @@ public class SettableConfigUpdater {
     // if admin has already customized this list, honor that
     String curBlackList = hiveConf.getVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST);
     if (curBlackList == null || curBlackList.trim().isEmpty()) {
-      hiveConf.setVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST, "reflect,reflect2,java_method");
+      hiveConf.setVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST, "reflect,reflect2,java_method,in_file");
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizer.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizer.java
new file mode 100644
index 0000000..10cf4d4
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizer.java
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.security.authorization.plugin.fallback;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.AbstractHiveAuthorizer;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.DisallowTransformHook;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzSessionContext;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrincipal;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilege;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeInfo;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveRoleGrant;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.SettableConfigUpdater;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.Operation2Privilege;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLAuthorizationUtils;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLPrivTypeGrant;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class FallbackHiveAuthorizer extends AbstractHiveAuthorizer {
+  private static final Log LOG = LogFactory.getLog(FallbackHiveAuthorizer.class);
+
+  private final HiveAuthzSessionContext sessionCtx;
+  private final HiveAuthenticationProvider authenticator;
+  private String[] admins = null;
+
+  FallbackHiveAuthorizer(HiveConf hiveConf, HiveAuthenticationProvider hiveAuthenticator,
+                                HiveAuthzSessionContext ctx) {
+    this.authenticator = hiveAuthenticator;
+    this.sessionCtx = applyTestSettings(ctx, hiveConf);
+    String adminString = hiveConf.getVar(HiveConf.ConfVars.USERS_IN_ADMIN_ROLE);
+    if (adminString != null) {
+      admins = hiveConf.getVar(HiveConf.ConfVars.USERS_IN_ADMIN_ROLE).split(",");
+    }
+  }
+
+  /**
+   * Change the session context based on configuration to aid in testing of sql
+   * std auth
+   *
+   * @param ctx
+   * @param conf
+   * @return
+   */
+  static HiveAuthzSessionContext applyTestSettings(HiveAuthzSessionContext ctx, HiveConf conf) {
+    if (conf.getBoolVar(HiveConf.ConfVars.HIVE_TEST_AUTHORIZATION_SQLSTD_HS2_MODE)
+            && ctx.getClientType() == HiveAuthzSessionContext.CLIENT_TYPE.HIVECLI) {
+      // create new session ctx object with HS2 as client type
+      HiveAuthzSessionContext.Builder ctxBuilder = new HiveAuthzSessionContext.Builder(ctx);
+      ctxBuilder.setClientType(HiveAuthzSessionContext.CLIENT_TYPE.HIVESERVER2);
+      return ctxBuilder.build();
+    }
+    return ctx;
+  }
+
+  @Override
+  public VERSION getVersion() {
+    return VERSION.V1;
+  }
+
+  @Override
+  public void grantPrivileges(List<HivePrincipal> hivePrincipals, List<HivePrivilege> hivePrivileges,
+                              HivePrivilegeObject hivePrivObject, HivePrincipal grantorPrincipal, boolean
+                                        grantOption) throws HiveAuthzPluginException {
+    throw new HiveAuthzPluginException("grantPrivileges not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void revokePrivileges(List<HivePrincipal> hivePrincipals, List<HivePrivilege> hivePrivileges,
+                               HivePrivilegeObject hivePrivObject, HivePrincipal grantorPrincipal, boolean
+                                         grantOption) throws HiveAuthzPluginException {
+    throw new HiveAuthzPluginException("revokePrivileges not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void createRole(String roleName, HivePrincipal adminGrantor) throws HiveAuthzPluginException {
+    throw new HiveAuthzPluginException("createRole not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void dropRole(String roleName) throws HiveAuthzPluginException, HiveAccessControlException {
+    throw new HiveAuthzPluginException("dropRole not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public List<HiveRoleGrant> getPrincipalGrantInfoForRole(String roleName) throws HiveAuthzPluginException,
+          HiveAccessControlException {
+    throw new HiveAuthzPluginException("getPrincipalGrantInfoForRole not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public List<HiveRoleGrant> getRoleGrantInfoForPrincipal(HivePrincipal principal) throws HiveAuthzPluginException,
+          HiveAccessControlException {
+    throw new HiveAuthzPluginException("getRoleGrantInfoForPrincipal not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void grantRole(List<HivePrincipal> hivePrincipals, List<String> roles, boolean grantOption, HivePrincipal
+          grantorPrinc) throws HiveAuthzPluginException, HiveAccessControlException {
+    throw new HiveAuthzPluginException("grantRole not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void revokeRole(List<HivePrincipal> hivePrincipals, List<String> roles, boolean grantOption, HivePrincipal
+          grantorPrinc) throws HiveAuthzPluginException, HiveAccessControlException {
+    throw new HiveAuthzPluginException("revokeRole not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void checkPrivileges(HiveOperationType hiveOpType, List<HivePrivilegeObject> inputHObjs,
+                              List<HivePrivilegeObject> outputHObjs, HiveAuthzContext context) throws
+          HiveAuthzPluginException, HiveAccessControlException {
+    String userName = authenticator.getUserName();
+    // check privileges on input and output objects
+    List<String> deniedMessages = new ArrayList<>();
+    checkPrivileges(hiveOpType, inputHObjs, userName, Operation2Privilege.IOType.INPUT, deniedMessages);
+    checkPrivileges(hiveOpType, outputHObjs, userName, Operation2Privilege.IOType.OUTPUT, deniedMessages);
+
+    SQLAuthorizationUtils.assertNoDeniedPermissions(new HivePrincipal(userName,
+            HivePrincipal.HivePrincipalType.USER), hiveOpType, deniedMessages);
+  }
+
+  // Adapted from SQLStdHiveAuthorizationValidator, only check privileges for LOAD/ADD/DFS/COMPILE and admin privileges
+  private void checkPrivileges(HiveOperationType hiveOpType, List<HivePrivilegeObject> hiveObjects,
+                               String userName, Operation2Privilege.IOType ioType, List<String> deniedMessages) {
+
+    if (hiveObjects == null) {
+      return;
+    }
+    if (admins != null && Arrays.stream(admins).parallel().anyMatch(n -> n.equals(userName))) {
+      return; // Skip rest of checks if user is admin
+    }
+
+    // Special-casing for ADMIN-level operations that do not require object checking.
+    if (Operation2Privilege.isAdminPrivOperation(hiveOpType)) {
+      // Require ADMIN privilege
+      deniedMessages.add(SQLPrivTypeGrant.ADMIN_PRIV.toString() + " on " + ioType);
+      return; // Ignore object, fail if not admin, succeed if admin.
+    }
+
+    boolean needAdmin = false;
+    for (HivePrivilegeObject hiveObj : hiveObjects) {
+      // If involving local file system
+      if (hiveObj.getType() == HivePrivilegeObject.HivePrivilegeObjectType.LOCAL_URI) {
+        needAdmin = true;
+        break;
+      }
+    }
+    if (!needAdmin) {
+      switch (hiveOpType) {
+        case ADD:
+        case DFS:
+        case COMPILE:
+          needAdmin = true;
+          break;
+        default:
+          break;
+      }
+    }
+    if (needAdmin) {
+      deniedMessages.add("ADMIN");
+    }
+  }
+
+  @Override
+  public List<HivePrivilegeObject> filterListCmdObjects(List<HivePrivilegeObject> listObjs, HiveAuthzContext context) {
+    return listObjs;
+  }
+
+  @Override
+  public List<String> getAllRoles() throws HiveAuthzPluginException {
+    throw new HiveAuthzPluginException("getAllRoles not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public List<HivePrivilegeInfo> showPrivileges(HivePrincipal principal, HivePrivilegeObject privObj) throws
+          HiveAuthzPluginException {
+    throw new HiveAuthzPluginException("showPrivileges not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void setCurrentRole(String roleName) throws HiveAuthzPluginException {
+    throw new HiveAuthzPluginException("setCurrentRole not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public List<String> getCurrentRoleNames() throws HiveAuthzPluginException {
+    throw new HiveAuthzPluginException("getCurrentRoleNames not implemented in FallbackHiveAuthorizer");
+  }
+
+  @Override
+  public void applyAuthorizationConfigPolicy(HiveConf hiveConf) throws HiveAuthzPluginException {
+    // from SQLStdHiveAccessController.applyAuthorizationConfigPolicy()
+    if (sessionCtx.getClientType() == HiveAuthzSessionContext.CLIENT_TYPE.HIVESERVER2
+            && hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED)) {
+
+      // Configure PREEXECHOOKS with DisallowTransformHook to disallow transform queries
+      String hooks = hiveConf.getVar(HiveConf.ConfVars.PREEXECHOOKS).trim();
+      if (hooks.isEmpty()) {
+        hooks = DisallowTransformHook.class.getName();
+      } else {
+        hooks = hooks + "," + DisallowTransformHook.class.getName();
+      }
+      LOG.debug("Configuring hooks : " + hooks);
+      hiveConf.setVar(HiveConf.ConfVars.PREEXECHOOKS, hooks);
+
+      SettableConfigUpdater.setHiveConfWhiteList(hiveConf);
+      String curBlackList = hiveConf.getVar(HiveConf.ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST);
+      if (curBlackList != null && curBlackList.trim().equals("reflect,reflect2,java_method")) {
+        hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST, "reflect,reflect2,java_method,in_file");
+      }
+
+    }
+  }
+
+  @Override
+  public List<HivePrivilegeObject> applyRowFilterAndColumnMasking(HiveAuthzContext context, List<HivePrivilegeObject>
+          privObjs) throws SemanticException {
+    return privObjs;
+  }
+
+  @Override
+  public boolean needTransform() {
+    return false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizerFactory.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizerFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizerFactory.java
new file mode 100644
index 0000000..4dae8d3
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/fallback/FallbackHiveAuthorizerFactory.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.security.authorization.plugin.fallback;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizer;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizerFactory;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzSessionContext;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveMetastoreClientFactory;
+
+public class FallbackHiveAuthorizerFactory implements HiveAuthorizerFactory {
+  @Override
+  public HiveAuthorizer createHiveAuthorizer(HiveMetastoreClientFactory metastoreClientFactory,
+                                             HiveConf conf, HiveAuthenticationProvider authenticator,
+                                             HiveAuthzSessionContext ctx) {
+    return new FallbackHiveAuthorizer(conf, authenticator, ctx);
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_addjar.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_addjar.q b/ql/src/test/queries/clientnegative/fallbackauth_addjar.q
new file mode 100644
index 0000000..c91d28f
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_addjar.q
@@ -0,0 +1,4 @@
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+add jar dummy.jar

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_compile.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_compile.q b/ql/src/test/queries/clientnegative/fallbackauth_compile.q
new file mode 100644
index 0000000..bf62264
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_compile.q
@@ -0,0 +1,9 @@
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+compile `import org.apache.hadoop.hive.ql.exec.UDF \;
+public class Pyth extends UDF {
+  public double evaluate(double a, double b){
+    return Math.sqrt((a*a) + (b*b)) \;
+  }
+} ` AS GROOVY NAMED Pyth.groovy;

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_create_func1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_create_func1.q b/ql/src/test/queries/clientnegative/fallbackauth_create_func1.q
new file mode 100644
index 0000000..7d4fd42
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_create_func1.q
@@ -0,0 +1,5 @@
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+-- permanent function creation should fail for non-admin roles
+create function perm_fn as 'org.apache.hadoop.hive.ql.udf.UDFAscii';

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_create_func2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_create_func2.q b/ql/src/test/queries/clientnegative/fallbackauth_create_func2.q
new file mode 100644
index 0000000..fc371d9
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_create_func2.q
@@ -0,0 +1,6 @@
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+-- temp function creation should fail for non-admin roles
+create temporary function temp_fn as 'org.apache.hadoop.hive.ql.udf.UDFAscii';
+

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_dfs.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_dfs.q b/ql/src/test/queries/clientnegative/fallbackauth_dfs.q
new file mode 100644
index 0000000..da0ac80
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_dfs.q
@@ -0,0 +1,4 @@
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+dfs -ls;

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_disallow_transform.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_disallow_transform.q b/ql/src/test/queries/clientnegative/fallbackauth_disallow_transform.q
new file mode 100644
index 0000000..eb9f680
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_disallow_transform.q
@@ -0,0 +1,6 @@
+set hive.test.authz.sstd.hs2.mode=true;
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+create table t1(i int);
+SELECT TRANSFORM (*) USING 'cat' AS (key, value) FROM t1;

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_load.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_load.q b/ql/src/test/queries/clientnegative/fallbackauth_load.q
new file mode 100644
index 0000000..10db24c
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_load.q
@@ -0,0 +1,15 @@
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+!cp ../../data/files/kv1.txt .;
+
+create table fallbackauthload(c1 string, c2 string);
+
+!chmod 777 kv1.txt;
+load data local inpath 'kv1.txt' into table fallbackauthload;
+
+!chmod 755 kv1.txt;
+load data local inpath 'kv1.txt' into table fallbackauthload;
+
+!rm kv1.txt;
+drop table fallbackauthload;

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/queries/clientnegative/fallbackauth_set_invalidconf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientnegative/fallbackauth_set_invalidconf.q b/ql/src/test/queries/clientnegative/fallbackauth_set_invalidconf.q
new file mode 100644
index 0000000..4ebf276
--- /dev/null
+++ b/ql/src/test/queries/clientnegative/fallbackauth_set_invalidconf.q
@@ -0,0 +1,8 @@
+set hive.test.authz.sstd.hs2.mode=true;
+set hive.security.authorization.enabled=true;
+set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.fallback.FallbackHiveAuthorizerFactory;
+
+-- run a sql query to initialize authorization, then try setting a allowed config and then a disallowed config param
+use default;
+set hive.optimize.listbucketing=true;
+set hive.security.authorization.enabled=true;

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_addjar.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_addjar.q.out b/ql/src/test/results/clientnegative/fallbackauth_addjar.q.out
new file mode 100644
index 0000000..2aae669
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_addjar.q.out
@@ -0,0 +1 @@
+Query returned non-zero code: 1, cause: Permission denied: Principal [name=hive_test_user, type=USER] does not have following privileges for operation ADD [ADMIN]

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_compile.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_compile.q.out b/ql/src/test/results/clientnegative/fallbackauth_compile.q.out
new file mode 100644
index 0000000..5699efe
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_compile.q.out
@@ -0,0 +1 @@
+Query returned non-zero code: 1, cause: Permission denied: Principal [name=hive_test_user, type=USER] does not have following privileges for operation COMPILE [ADMIN]

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_create_func1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_create_func1.q.out b/ql/src/test/results/clientnegative/fallbackauth_create_func1.q.out
new file mode 100644
index 0000000..b2532eb
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_create_func1.q.out
@@ -0,0 +1 @@
+FAILED: HiveAccessControlException Permission denied: Principal [name=hive_test_user, type=USER] does not have following privileges for operation CREATEFUNCTION [ADMIN PRIVILEGE on INPUT, ADMIN PRIVILEGE on OUTPUT]

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_create_func2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_create_func2.q.out b/ql/src/test/results/clientnegative/fallbackauth_create_func2.q.out
new file mode 100644
index 0000000..b2532eb
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_create_func2.q.out
@@ -0,0 +1 @@
+FAILED: HiveAccessControlException Permission denied: Principal [name=hive_test_user, type=USER] does not have following privileges for operation CREATEFUNCTION [ADMIN PRIVILEGE on INPUT, ADMIN PRIVILEGE on OUTPUT]

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_dfs.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_dfs.q.out b/ql/src/test/results/clientnegative/fallbackauth_dfs.q.out
new file mode 100644
index 0000000..9f4a71b
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_dfs.q.out
@@ -0,0 +1 @@
+Query returned non-zero code: 1, cause: Permission denied: Principal [name=hive_test_user, type=USER] does not have following privileges for operation DFS [ADMIN]

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_disallow_transform.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_disallow_transform.q.out b/ql/src/test/results/clientnegative/fallbackauth_disallow_transform.q.out
new file mode 100644
index 0000000..1ac04db
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_disallow_transform.q.out
@@ -0,0 +1,16 @@
+PREHOOK: query: create table t1(i int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t1
+POSTHOOK: query: create table t1(i int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t1
+PREHOOK: query: SELECT TRANSFORM (*) USING 'cat' AS (key, value) FROM t1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t1
+#### A masked pattern was here ####
+FAILED: Hive Internal Error: org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException(Query with transform clause is disallowed in current configuration.)
+org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException: Query with transform clause is disallowed in current configuration.
+#### A masked pattern was here ####
+

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_load.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_load.q.out b/ql/src/test/results/clientnegative/fallbackauth_load.q.out
new file mode 100644
index 0000000..d2bcafc
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_load.q.out
@@ -0,0 +1,9 @@
+PREHOOK: query: create table fallbackauthload(c1 string, c2 string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@fallbackauthload
+POSTHOOK: query: create table fallbackauthload(c1 string, c2 string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@fallbackauthload
+FAILED: HiveAccessControlException Permission denied: Principal [name=hive_test_user, type=USER] does not have following privileges for operation LOAD [ADMIN]

http://git-wip-us.apache.org/repos/asf/hive/blob/1a1d6ca1/ql/src/test/results/clientnegative/fallbackauth_set_invalidconf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/fallbackauth_set_invalidconf.q.out b/ql/src/test/results/clientnegative/fallbackauth_set_invalidconf.q.out
new file mode 100644
index 0000000..dd6092b
--- /dev/null
+++ b/ql/src/test/results/clientnegative/fallbackauth_set_invalidconf.q.out
@@ -0,0 +1,7 @@
+PREHOOK: query: use default
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:default
+POSTHOOK: query: use default
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:default
+Query returned non-zero code: 1, cause: Cannot modify hive.security.authorization.enabled at runtime. It is not in list of params that are allowed to be modified at runtime


[59/75] [abbrv] hive git commit: HIVE-20772 : record per-task CPU counters in LLAP (Sergey Shelukhin, reviewed by Prasanth Jayachandran)

Posted by se...@apache.org.
HIVE-20772 : record per-task CPU counters in LLAP (Sergey Shelukhin, reviewed by Prasanth Jayachandran)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/72349bb3
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/72349bb3
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/72349bb3

Branch: refs/heads/master-tez092
Commit: 72349bb33988656ad43afdc0c7556532ee0dadbc
Parents: 0d4d03f
Author: sergey <se...@apache.org>
Authored: Tue Oct 23 15:16:17 2018 -0700
Committer: sergey <se...@apache.org>
Committed: Tue Oct 23 15:16:17 2018 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/llap/LlapUtil.java   | 17 ++++++++
 .../hive/llap/counters/LlapIOCounters.java      |  4 +-
 .../hive/llap/cache/LowLevelCacheCounters.java  |  3 +-
 .../llap/counters/QueryFragmentCounters.java    | 10 ++++-
 .../daemon/impl/StatsRecordingThreadPool.java   | 42 +++++++++++++++----
 .../hive/llap/io/api/impl/LlapRecordReader.java |  2 +-
 .../llap/io/decode/EncodedDataConsumer.java     | 43 +++++++++++++++++++-
 .../llap/io/decode/OrcEncodedDataConsumer.java  |  6 +--
 .../llap/io/encoded/OrcEncodedDataReader.java   | 10 ++---
 .../llap/io/encoded/SerDeEncodedDataReader.java |  2 +-
 10 files changed, 115 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-common/src/java/org/apache/hadoop/hive/llap/LlapUtil.java
----------------------------------------------------------------------
diff --git a/llap-common/src/java/org/apache/hadoop/hive/llap/LlapUtil.java b/llap-common/src/java/org/apache/hadoop/hive/llap/LlapUtil.java
index 50c0e22..82776ab 100644
--- a/llap-common/src/java/org/apache/hadoop/hive/llap/LlapUtil.java
+++ b/llap-common/src/java/org/apache/hadoop/hive/llap/LlapUtil.java
@@ -14,6 +14,8 @@
 package org.apache.hadoop.hive.llap;
 
 import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadMXBean;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
@@ -366,4 +368,19 @@ public class LlapUtil {
     return p.startsWith(BASE_PREFIX) || p.startsWith(DELTA_PREFIX) || p.startsWith(BUCKET_PREFIX)
         || p.startsWith(UNION_SUDBIR_PREFIX) || p.startsWith(DELETE_DELTA_PREFIX);
   }
+
+
+  public static ThreadMXBean initThreadMxBean() {
+    ThreadMXBean mxBean = ManagementFactory.getThreadMXBean();
+    if (mxBean != null) {
+      if (!mxBean.isCurrentThreadCpuTimeSupported()) {
+        LOG.warn("Thread CPU monitoring is not supported");
+        return null;
+      } else if (!mxBean.isThreadCpuTimeEnabled()) {
+        LOG.warn("Thread CPU monitoring is not enabled");
+        return null;
+      }
+    }
+    return mxBean;
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-common/src/java/org/apache/hadoop/hive/llap/counters/LlapIOCounters.java
----------------------------------------------------------------------
diff --git a/llap-common/src/java/org/apache/hadoop/hive/llap/counters/LlapIOCounters.java b/llap-common/src/java/org/apache/hadoop/hive/llap/counters/LlapIOCounters.java
index 059d5b9..d27193f 100644
--- a/llap-common/src/java/org/apache/hadoop/hive/llap/counters/LlapIOCounters.java
+++ b/llap-common/src/java/org/apache/hadoop/hive/llap/counters/LlapIOCounters.java
@@ -36,7 +36,9 @@ public enum LlapIOCounters {
   TOTAL_IO_TIME_NS(false),
   DECODE_TIME_NS(false),
   HDFS_TIME_NS(false),
-  CONSUMER_TIME_NS(false);
+  CONSUMER_TIME_NS(false),
+  IO_CPU_NS(false),
+  IO_USER_NS(false);
 
   // flag to indicate if these counters are subject to change across different test runs
   private boolean testSafe;

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/cache/LowLevelCacheCounters.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/cache/LowLevelCacheCounters.java b/llap-server/src/java/org/apache/hadoop/hive/llap/cache/LowLevelCacheCounters.java
index 91df036..c2aca5a 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/cache/LowLevelCacheCounters.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/cache/LowLevelCacheCounters.java
@@ -21,6 +21,7 @@ public interface LowLevelCacheCounters {
   void recordCacheHit(long bytesHit);
   void recordCacheMiss(long bytesMissed);
   void recordAllocBytes(long bytesWasted, long bytesAllocated);
-  void recordHdfsTime(long timeUs);
+  void recordHdfsTime(long timeNs);
+  void recordThreadTimes(long cpuNs, long userNs);
   long startTimeCounter();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/counters/QueryFragmentCounters.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/counters/QueryFragmentCounters.java b/llap-server/src/java/org/apache/hadoop/hive/llap/counters/QueryFragmentCounters.java
index be4dfad..f5f2982 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/counters/QueryFragmentCounters.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/counters/QueryFragmentCounters.java
@@ -71,7 +71,7 @@ public class QueryFragmentCounters implements LowLevelCacheCounters {
     return (doUseTimeCounters ? System.nanoTime() : 0);
   }
 
-  public void incrTimeCounter(LlapIOCounters counter, long startTime) {
+  public void incrWallClockCounter(LlapIOCounters counter, long startTime) {
     if (!doUseTimeCounters) return;
     long delta = System.nanoTime() - startTime;
     fixedCounters.addAndGet(counter.ordinal(), delta);
@@ -109,7 +109,13 @@ public class QueryFragmentCounters implements LowLevelCacheCounters {
 
   @Override
   public void recordHdfsTime(long startTime) {
-    incrTimeCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
+    incrWallClockCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
+  }
+
+  @Override
+  public void recordThreadTimes(long cpuNs, long userNs) {
+    incrCounter(LlapIOCounters.IO_CPU_NS, cpuNs);
+    incrCounter(LlapIOCounters.IO_USER_NS, userNs);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/StatsRecordingThreadPool.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/StatsRecordingThreadPool.java b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/StatsRecordingThreadPool.java
index 27462e1..873bdc7 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/StatsRecordingThreadPool.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/StatsRecordingThreadPool.java
@@ -17,7 +17,10 @@
  */
 package org.apache.hadoop.hive.llap.daemon.impl;
 
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadMXBean;
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Stack;
@@ -31,8 +34,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hive.llap.LlapUtil;
+import org.apache.hadoop.hive.llap.counters.LlapIOCounters;
 import org.apache.hadoop.hive.llap.io.encoded.TezCounterSource;
-import org.apache.log4j.NDC;
 import org.apache.tez.common.CallableWithNdc;
 import org.apache.tez.common.counters.FileSystemCounter;
 import org.apache.tez.common.counters.TezCounters;
@@ -50,6 +53,7 @@ public class StatsRecordingThreadPool extends ThreadPoolExecutor {
   private static final Logger LOG = LoggerFactory.getLogger(StatsRecordingThreadPool.class);
   // uncaught exception handler that will be set for all threads before execution
   private Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
+  private final ThreadMXBean mxBean;
 
   public StatsRecordingThreadPool(final int corePoolSize, final int maximumPoolSize,
       final long keepAliveTime,
@@ -66,11 +70,12 @@ public class StatsRecordingThreadPool extends ThreadPoolExecutor {
       final ThreadFactory threadFactory, Thread.UncaughtExceptionHandler handler) {
     super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
     this.uncaughtExceptionHandler = handler;
+    this.mxBean = LlapUtil.initThreadMxBean();
   }
 
   @Override
   protected <T> RunnableFuture<T> newTaskFor(final Callable<T> callable) {
-    return new FutureTask(new WrappedCallable(callable, uncaughtExceptionHandler));
+    return new FutureTask(new WrappedCallable(callable, uncaughtExceptionHandler, mxBean));
   }
 
   public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler) {
@@ -86,11 +91,13 @@ public class StatsRecordingThreadPool extends ThreadPoolExecutor {
   private static class WrappedCallable<V> implements Callable<V> {
     private Callable<V> actualCallable;
     private Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
+    private ThreadMXBean mxBean;
 
     WrappedCallable(final Callable<V> callable,
-        final Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
+        final Thread.UncaughtExceptionHandler uncaughtExceptionHandler, ThreadMXBean mxBean) {
       this.actualCallable = callable;
       this.uncaughtExceptionHandler = uncaughtExceptionHandler;
+      this.mxBean = mxBean;
     }
 
     @Override
@@ -104,12 +111,18 @@ public class StatsRecordingThreadPool extends ThreadPoolExecutor {
 
       // clone thread local file system statistics
       List<LlapUtil.StatisticsData> statsBefore = LlapUtil.cloneThreadLocalFileSystemStatistics();
-
+      long cpuTime = mxBean == null ? -1 : mxBean.getCurrentThreadCpuTime(),
+          userTime = mxBean == null ? -1 : mxBean.getCurrentThreadUserTime();
       setupMDCFromNDC(actualCallable);
       try {
         return actualCallable.call();
       } finally {
-        updateFileSystemCounters(statsBefore, actualCallable);
+        if (mxBean != null) {
+          cpuTime = mxBean.getCurrentThreadCpuTime() - cpuTime;
+          userTime = mxBean.getCurrentThreadUserTime() - userTime;
+        }
+        updateCounters(statsBefore, actualCallable, cpuTime, userTime);
+
         MDC.clear();
       }
     }
@@ -148,8 +161,17 @@ public class StatsRecordingThreadPool extends ThreadPoolExecutor {
       }
     }
 
-    private void updateFileSystemCounters(final List<LlapUtil.StatisticsData> statsBefore,
-        final Callable<V> actualCallable) {
+    /**
+     * LLAP IO related counters.
+     */
+    public enum LlapExecutorCounters {
+      EXECUTOR_CPU_NS,
+      EXECUTOR_USER_NS;
+
+    }
+
+    private void updateCounters(final List<LlapUtil.StatisticsData> statsBefore,
+        final Callable<V> actualCallable, long cpuTime, long userTime) {
       Thread thread = Thread.currentThread();
       TezCounters tezCounters = null;
       // add tez counters for task execution and llap io
@@ -160,9 +182,15 @@ public class StatsRecordingThreadPool extends ThreadPoolExecutor {
       } else if (actualCallable instanceof TezCounterSource) {
         // Other counter sources (currently used in LLAP IO).
         tezCounters = ((TezCounterSource) actualCallable).getTezCounters();
+      } else {
+        LOG.warn("Unexpected callable {}; cannot get counters", actualCallable);
       }
 
       if (tezCounters != null) {
+        if (cpuTime >= 0 && userTime >= 0) {
+          tezCounters.findCounter(LlapExecutorCounters.EXECUTOR_CPU_NS).increment(cpuTime);
+          tezCounters.findCounter(LlapExecutorCounters.EXECUTOR_USER_NS).increment(userTime);
+        }
         if (statsBefore != null) {
           // if there are multiple stats for the same scheme (from different NameNode), this
           // method will squash them together

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/io/api/impl/LlapRecordReader.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/io/api/impl/LlapRecordReader.java b/llap-server/src/java/org/apache/hadoop/hive/llap/io/api/impl/LlapRecordReader.java
index 27a5b0f..9ef7af4 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/io/api/impl/LlapRecordReader.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/io/api/impl/LlapRecordReader.java
@@ -338,7 +338,7 @@ class LlapRecordReader
       if (wasFirst) {
         firstReturnTime = counters.startTimeCounter();
       }
-      counters.incrTimeCounter(LlapIOCounters.CONSUMER_TIME_NS, firstReturnTime);
+      counters.incrWallClockCounter(LlapIOCounters.CONSUMER_TIME_NS, firstReturnTime);
       return false;
     }
     if (isAcidScan) {

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/EncodedDataConsumer.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/EncodedDataConsumer.java b/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/EncodedDataConsumer.java
index d5c2d48..f2d2832 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/EncodedDataConsumer.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/EncodedDataConsumer.java
@@ -17,19 +17,26 @@
  */
 package org.apache.hadoop.hive.llap.io.decode;
 
+import java.lang.management.ThreadMXBean;
 import java.util.concurrent.Callable;
 
 import org.apache.hadoop.hive.common.Pool;
 import org.apache.hadoop.hive.common.io.encoded.EncodedColumnBatch;
 import org.apache.hadoop.hive.llap.ConsumerFeedback;
 import org.apache.hadoop.hive.llap.DebugUtils;
+import org.apache.hadoop.hive.llap.LlapUtil;
+import org.apache.hadoop.hive.llap.counters.QueryFragmentCounters;
 import org.apache.hadoop.hive.llap.io.api.impl.ColumnVectorBatch;
 import org.apache.hadoop.hive.llap.io.api.impl.LlapIoImpl;
+import org.apache.hadoop.hive.llap.io.encoded.TezCounterSource;
 import org.apache.hadoop.hive.llap.metrics.LlapDaemonIOMetrics;
 import org.apache.hadoop.hive.ql.io.orc.encoded.Consumer;
 import org.apache.hadoop.hive.ql.io.orc.encoded.IoTrace;
 import org.apache.hive.common.util.FixedSizedObjectPool;
 import org.apache.orc.TypeDescription;
+import org.apache.tez.common.counters.FileSystemCounter;
+import org.apache.tez.common.counters.TezCounters;
+import org.apache.tez.runtime.task.TaskRunner2Callable;
 
 public abstract class EncodedDataConsumer<BatchKey, BatchType extends EncodedColumnBatch<BatchKey>>
   implements Consumer<BatchType>, ReadPipeline {
@@ -41,11 +48,14 @@ public abstract class EncodedDataConsumer<BatchKey, BatchType extends EncodedCol
   // Note that the pool is per EDC - within EDC, CVBs are expected to have the same schema.
   private static final int CVB_POOL_SIZE = 128;
   protected final FixedSizedObjectPool<ColumnVectorBatch> cvbPool;
+  protected final QueryFragmentCounters counters;
+  private final ThreadMXBean mxBean;
 
   public EncodedDataConsumer(Consumer<ColumnVectorBatch> consumer, final int colCount,
-      LlapDaemonIOMetrics ioMetrics) {
+      LlapDaemonIOMetrics ioMetrics, QueryFragmentCounters counters) {
     this.downstreamConsumer = consumer;
     this.ioMetrics = ioMetrics;
+    this.mxBean = LlapUtil.initThreadMxBean();
     cvbPool = new FixedSizedObjectPool<ColumnVectorBatch>(CVB_POOL_SIZE,
         new Pool.PoolObjectHelper<ColumnVectorBatch>() {
           @Override
@@ -57,12 +67,41 @@ public abstract class EncodedDataConsumer<BatchKey, BatchType extends EncodedCol
             // Don't reset anything, we are reusing column vectors.
           }
         });
+    this.counters = counters;
+  }
+
+  // Implementing TCS is needed for StatsRecordingThreadPool.
+  private class CpuRecordingCallable implements Callable<Void>, TezCounterSource {
+    private final Callable<Void> readCallable;
+
+    public CpuRecordingCallable(Callable<Void> readCallable) {
+      this.readCallable = readCallable;
+    }
+
+    @Override
+    public Void call() throws Exception {
+      long cpuTime = mxBean.getCurrentThreadCpuTime(),
+          userTime = mxBean.getCurrentThreadUserTime();
+      try {
+        return readCallable.call();
+      } finally {
+        counters.recordThreadTimes(mxBean.getCurrentThreadCpuTime() - cpuTime,
+            mxBean.getCurrentThreadUserTime() - userTime);
+      }
+    }
+
+    @Override
+    public TezCounters getTezCounters() {
+      return (readCallable instanceof TezCounterSource)
+          ? ((TezCounterSource) readCallable).getTezCounters() : null;
+    }
+
   }
 
   public void init(ConsumerFeedback<BatchType> upstreamFeedback,
       Callable<Void> readCallable) {
     this.upstreamFeedback = upstreamFeedback;
-    this.readCallable = readCallable;
+    this.readCallable = mxBean == null ? readCallable : new CpuRecordingCallable(readCallable);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/OrcEncodedDataConsumer.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/OrcEncodedDataConsumer.java b/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/OrcEncodedDataConsumer.java
index 40248a3..83931c2 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/OrcEncodedDataConsumer.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/OrcEncodedDataConsumer.java
@@ -69,7 +69,6 @@ public class OrcEncodedDataConsumer
   private CompressionCodec codec;
   private List<ConsumerStripeMetadata> stripes;
   private final boolean skipCorrupt; // TODO: get rid of this
-  private final QueryFragmentCounters counters;
   private SchemaEvolution evolution;
   private IoTrace trace;
   private final Includes includes;
@@ -79,11 +78,10 @@ public class OrcEncodedDataConsumer
   public OrcEncodedDataConsumer(
     Consumer<ColumnVectorBatch> consumer, Includes includes, boolean skipCorrupt,
     QueryFragmentCounters counters, LlapDaemonIOMetrics ioMetrics) {
-    super(consumer, includes.getPhysicalColumnIds().size(), ioMetrics);
+    super(consumer, includes.getPhysicalColumnIds().size(), ioMetrics, counters);
     this.includes = includes;
     // TODO: get rid of this
     this.skipCorrupt = skipCorrupt;
-    this.counters = counters;
   }
 
   public void setUseDecimal64ColumnVectors(final boolean useDecimal64ColumnVectors) {
@@ -209,7 +207,7 @@ public class OrcEncodedDataConsumer
         counters.incrCounter(LlapIOCounters.ROWS_EMITTED, batchSize);
       }
       LlapIoImpl.ORC_LOGGER.debug("Done with decode");
-      counters.incrTimeCounter(LlapIOCounters.DECODE_TIME_NS, startTime);
+      counters.incrWallClockCounter(LlapIOCounters.DECODE_TIME_NS, startTime);
       counters.incrCounter(LlapIOCounters.NUM_VECTOR_BATCHES, maxBatchesRG);
       counters.incrCounter(LlapIOCounters.NUM_DECODED_BATCHES);
     } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/OrcEncodedDataReader.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/OrcEncodedDataReader.java b/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/OrcEncodedDataReader.java
index 4f5b0a9..74cee64 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/OrcEncodedDataReader.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/OrcEncodedDataReader.java
@@ -443,7 +443,7 @@ public class OrcEncodedDataReader extends CallableWithNdc<Void>
   }
 
   private void recordReaderTime(long startTime) {
-    counters.incrTimeCounter(LlapIOCounters.TOTAL_IO_TIME_NS, startTime);
+    counters.incrWallClockCounter(LlapIOCounters.TOTAL_IO_TIME_NS, startTime);
   }
 
   private void validateFileMetadata() throws IOException {
@@ -519,7 +519,7 @@ public class OrcEncodedDataReader extends CallableWithNdc<Void>
       }
     }
     orcReader = EncodedOrcFile.createReader(path, opts);
-    counters.incrTimeCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
+    counters.incrWallClockCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
   }
 
   /**
@@ -677,7 +677,7 @@ public class OrcEncodedDataReader extends CallableWithNdc<Void>
     DiskRangeList footerRange = rawDataReader.readFileData(
         new DiskRangeList(offset, offset + si.getFooterLength()), 0, false);
     // LOG.error("Got " + RecordReaderUtils.stringifyDiskRanges(footerRange));
-    counters.incrTimeCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
+    counters.incrWallClockCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
     assert footerRange.next == null; // Can only happens w/zcr for a single input buffer.
     if (hasCache) {
       LlapBufferOrBuffers cacheBuf = metadataCache.putStripeTail(
@@ -716,7 +716,7 @@ public class OrcEncodedDataReader extends CallableWithNdc<Void>
       if (!isRawDataReaderOpen && isOpen) {
         long startTime = counters.startTimeCounter();
         rawDataReader.open();
-        counters.incrTimeCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
+        counters.incrWallClockCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
       }
       return;
     }
@@ -734,7 +734,7 @@ public class OrcEncodedDataReader extends CallableWithNdc<Void>
       rawDataReader.open();
       isRawDataReaderOpen = true;
     }
-    counters.incrTimeCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
+    counters.incrWallClockCounter(LlapIOCounters.HDFS_TIME_NS, startTime);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/72349bb3/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/SerDeEncodedDataReader.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/SerDeEncodedDataReader.java b/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/SerDeEncodedDataReader.java
index 658bc7d..a5671e9 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/SerDeEncodedDataReader.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/io/encoded/SerDeEncodedDataReader.java
@@ -1688,7 +1688,7 @@ public class SerDeEncodedDataReader extends CallableWithNdc<Void>
   }
 
   private void recordReaderTime(long startTime) {
-    counters.incrTimeCounter(LlapIOCounters.TOTAL_IO_TIME_NS, startTime);
+    counters.incrWallClockCounter(LlapIOCounters.TOTAL_IO_TIME_NS, startTime);
   }
 
   private boolean processStop() {


[38/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out
new file mode 100644
index 0000000..50474bc
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query85.q.out
@@ -0,0 +1,219 @@
+PREHOOK: query: explain cbo
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
+ from web_sales, web_returns, web_page, customer_demographics cd1,
+      customer_demographics cd2, customer_address, date_dim, reason 
+ where ws_web_page_sk = wp_web_page_sk
+   and ws_item_sk = wr_item_sk
+   and ws_order_number = wr_order_number
+   and ws_sold_date_sk = d_date_sk and d_year = 1998
+   and cd1.cd_demo_sk = wr_refunded_cdemo_sk 
+   and cd2.cd_demo_sk = wr_returning_cdemo_sk
+   and ca_address_sk = wr_refunded_addr_sk
+   and r_reason_sk = wr_reason_sk
+   and
+   (
+    (
+     cd1.cd_marital_status = 'M'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = '4 yr Degree'
+     and 
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 100.00 and 150.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'D'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Primary' 
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 50.00 and 100.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'U'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Advanced Degree'
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 150.00 and 200.00
+    )
+   )
+   and
+   (
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('KY', 'GA', 'NM')
+     and ws_net_profit between 100 and 200  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('MT', 'OR', 'IN')
+     and ws_net_profit between 150 and 300  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('WI', 'MO', 'WV')
+     and ws_net_profit between 50 and 250  
+    )
+   )
+group by r_reason_desc
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@reason
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
+ from web_sales, web_returns, web_page, customer_demographics cd1,
+      customer_demographics cd2, customer_address, date_dim, reason 
+ where ws_web_page_sk = wp_web_page_sk
+   and ws_item_sk = wr_item_sk
+   and ws_order_number = wr_order_number
+   and ws_sold_date_sk = d_date_sk and d_year = 1998
+   and cd1.cd_demo_sk = wr_refunded_cdemo_sk 
+   and cd2.cd_demo_sk = wr_returning_cdemo_sk
+   and ca_address_sk = wr_refunded_addr_sk
+   and r_reason_sk = wr_reason_sk
+   and
+   (
+    (
+     cd1.cd_marital_status = 'M'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = '4 yr Degree'
+     and 
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 100.00 and 150.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'D'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Primary' 
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 50.00 and 100.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'U'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Advanced Degree'
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 150.00 and 200.00
+    )
+   )
+   and
+   (
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('KY', 'GA', 'NM')
+     and ws_net_profit between 100 and 200  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('MT', 'OR', 'IN')
+     and ws_net_profit between 150 and 300  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('WI', 'MO', 'WV')
+     and ws_net_profit between 50 and 250  
+    )
+   )
+group by r_reason_desc
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@reason
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(_o__c0=[$0], _o__c1=[$1], _o__c2=[$2], _o__c3=[$3])
+  HiveSortLimit(sort0=[$7], sort1=[$4], sort2=[$5], sort3=[$6], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+    HiveProject(_o__c0=[substr($0, 1, 20)], _o__c1=[/(CAST($1):DOUBLE, $2)], _o__c2=[/($3, $4)], _o__c3=[/($5, $6)], (tok_function avg (tok_table_or_col ws_quantity))=[/(CAST($1):DOUBLE, $2)], (tok_function avg (tok_table_or_col wr_refunded_cash))=[/($3, $4)], (tok_function avg (tok_table_or_col wr_fee))=[/($5, $6)], (tok_function substr (tok_table_or_col r_reason_desc) 1 20)=[substr($0, 1, 20)])
+      HiveAggregate(group=[{7}], agg#0=[sum($26)], agg#1=[count($26)], agg#2=[sum($21)], agg#3=[count($21)], agg#4=[sum($20)], agg#5=[count($20)])
+        HiveJoin(condition=[AND(AND(=($0, $17), =($4, $1)), =($5, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
+            HiveFilter(condition=[AND(IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+          HiveJoin(condition=[AND(=($0, $12), OR(AND(=($1, _UTF-16LE'M'), =($2, _UTF-16LE'4 yr Degree'), BETWEEN(false, $24, 100, 150)), AND(=($1, _UTF-16LE'D'), =($2, _UTF-16LE'Primary'), BETWEEN(false, $24, 50, 100)), AND(=($1, _UTF-16LE'U'), =($2, _UTF-16LE'Advanced Degree'), BETWEEN(false, $24, 150, 200))))], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
+              HiveFilter(condition=[AND(IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+            HiveJoin(condition=[=($0, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(r_reason_sk=[$0], r_reason_desc=[$2])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, reason]], table:alias=[reason])
+              HiveJoin(condition=[=($14, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER])
+                  HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveJoin(condition=[=($14, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(wp_web_page_sk=[$0])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, web_page]], table:alias=[web_page])
+                  HiveJoin(condition=[AND(=($0, $5), OR(AND(IN($1, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM'), BETWEEN(false, $17, 100, 200)), AND(IN($1, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN'), BETWEEN(false, $17, 150, 300)), AND(IN($1, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), BETWEEN(false, $17, 50, 250))))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_country=[CAST(_UTF-16LE'United States'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[AND(=($9, $0), =($11, $5))], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(wr_item_sk=[$2], wr_refunded_cdemo_sk=[$4], wr_refunded_addr_sk=[$6], wr_returning_cdemo_sk=[$8], wr_reason_sk=[$12], wr_order_number=[$13], wr_fee=[$18], wr_refunded_cash=[$20])
+                        HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($13), IS NOT NULL($4), IS NOT NULL($8), IS NOT NULL($6), IS NOT NULL($12))])
+                          HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_web_page_sk=[$12], ws_order_number=[$17], ws_quantity=[$18], ws_sales_price=[$21], ws_net_profit=[$33])
+                        HiveFilter(condition=[AND(OR(BETWEEN(false, $21, 100, 150), BETWEEN(false, $21, 50, 100), BETWEEN(false, $21, 150, 200)), OR(BETWEEN(false, $33, 100, 200), BETWEEN(false, $33, 150, 300), BETWEEN(false, $33, 50, 250)), IS NOT NULL($3), IS NOT NULL($17), IS NOT NULL($12), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query86.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query86.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query86.q.out
new file mode 100644
index 0000000..0832a63
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query86.q.out
@@ -0,0 +1,77 @@
+PREHOOK: query: explain cbo
+select   
+    sum(ws_net_paid) as total_sum
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ws_net_paid) desc) as rank_within_parent
+ from
+    web_sales
+   ,date_dim       d1
+   ,item
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ws_sold_date_sk
+ and i_item_sk  = ws_item_sk
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc,
+   case when lochierarchy = 0 then i_category end,
+   rank_within_parent
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select   
+    sum(ws_net_paid) as total_sum
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ws_net_paid) desc) as rank_within_parent
+ from
+    web_sales
+   ,date_dim       d1
+   ,item
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ws_sold_date_sk
+ and i_item_sk  = ws_item_sk
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc,
+   case when lochierarchy = 0 then i_category end,
+   rank_within_parent
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(total_sum=[$0], i_category=[$1], i_class=[$2], lochierarchy=[$3], rank_within_parent=[$4])
+  HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(total_sum=[$2], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($3, 1), grouping($3, 0))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($3, 1), grouping($3, 0)), CASE(=(grouping($3, 0), 0), $0, null) ORDER BY $2 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok_table_or_col i_category))=[CASE(=(+(grouping($3, 1), grouping($3, 0)), 0), $0, null)])
+      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], GROUPING__ID=[$3])
+        HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], GROUPING__ID=[GROUPING__ID()])
+          HiveProject($f0=[$2], $f1=[$1], $f2=[$5])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_class=[$10], i_category=[$12])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_net_paid=[$29])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                  HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query87.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query87.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query87.q.out
new file mode 100644
index 0000000..35f319d
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query87.q.out
@@ -0,0 +1,114 @@
+PREHOOK: query: explain cbo
+select count(*) 
+from ((select distinct c_last_name, c_first_name, d_date
+       from store_sales, date_dim, customer
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from catalog_sales, date_dim, customer
+       where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+         and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from web_sales, date_dim, customer
+       where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+         and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+) cool_cust
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select count(*) 
+from ((select distinct c_last_name, c_first_name, d_date
+       from store_sales, date_dim, customer
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from catalog_sales, date_dim, customer
+       where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+         and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from web_sales, date_dim, customer
+       where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+         and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+) cool_cust
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveAggregate(group=[{}], agg#0=[count()])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+    HiveFilter(condition=[AND(>($3, 0), =(*($3, 2), $4))])
+      HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[sum($4)])
+        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f4=[$4], $f5=[*($3, $4)])
+          HiveUnion(all=[true])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[2], $f4=[$3])
+              HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                  HiveFilter(condition=[AND(>($3, 0), =(*($3, 2), $4))])
+                    HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[sum($4)])
+                      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f4=[$4], $f5=[*($3, $4)])
+                        HiveUnion(all=[true])
+                          HiveProject($f0=[$1], $f1=[$0], $f2=[$2], $f3=[2], $f4=[$3])
+                            HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                              HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                                HiveAggregate(group=[{1, 2, 6}])
+                                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                                      HiveFilter(condition=[IS NOT NULL($0)])
+                                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                          HiveProject($f0=[$1], $f1=[$0], $f2=[$2], $f3=[1], $f4=[$3])
+                            HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                              HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                                HiveAggregate(group=[{1, 2, 6}])
+                                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                                      HiveFilter(condition=[IS NOT NULL($0)])
+                                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3])
+                                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject($f0=[$1], $f1=[$0], $f2=[$2], $f3=[1], $f4=[$3])
+              HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                  HiveAggregate(group=[{1, 2, 6}])
+                    HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                            HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                        HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                          HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query88.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query88.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query88.q.out
new file mode 100644
index 0000000..1f86e3a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query88.q.out
@@ -0,0 +1,347 @@
+Warning: Shuffle Join MERGEJOIN[599][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[600][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[601][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[602][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 9' is a cross product
+Warning: Shuffle Join MERGEJOIN[603][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 10' is a cross product
+Warning: Shuffle Join MERGEJOIN[604][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6]] in Stage 'Reducer 11' is a cross product
+Warning: Shuffle Join MERGEJOIN[605][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7]] in Stage 'Reducer 12' is a cross product
+PREHOOK: query: explain cbo
+select  *
+from
+ (select count(*) h8_30_to_9
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk   
+     and ss_hdemo_sk = household_demographics.hd_demo_sk 
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 8
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
+     and store.s_store_name = 'ese') s1,
+ (select count(*) h9_to_9_30 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 9 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s2,
+ (select count(*) h9_30_to_10 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 9
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s3,
+ (select count(*) h10_to_10_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s4,
+ (select count(*) h10_30_to_11
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s5,
+ (select count(*) h11_to_11_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 11
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s6,
+ (select count(*) h11_30_to_12
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 11
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s7,
+ (select count(*) h12_to_12_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 12
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s8
+PREHOOK: type: QUERY
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from
+ (select count(*) h8_30_to_9
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk   
+     and ss_hdemo_sk = household_demographics.hd_demo_sk 
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 8
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
+     and store.s_store_name = 'ese') s1,
+ (select count(*) h9_to_9_30 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 9 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s2,
+ (select count(*) h9_30_to_10 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 9
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s3,
+ (select count(*) h10_to_10_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s4,
+ (select count(*) h10_30_to_11
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s5,
+ (select count(*) h11_to_11_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 11
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s6,
+ (select count(*) h11_30_to_12
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 11
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s7,
+ (select count(*) h12_to_12_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 12
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s8
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject($f0=[$0], $f00=[$7], $f01=[$6], $f02=[$5], $f03=[$4], $f04=[$3], $f05=[$2], $f06=[$1])
+  HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f0=[$0])
+                  HiveAggregate(group=[{}], agg#0=[count()])
+                    HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                            HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                            HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                        HiveProject(t_time_sk=[$0], t_hour=[CAST(8):INTEGER], t_minute=[$4])
+                          HiveFilter(condition=[AND(=($3, 8), >=($4, 30), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                      HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                        HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+                HiveProject($f0=[$0])
+                  HiveAggregate(group=[{}], agg#0=[count()])
+                    HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                            HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                            HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                        HiveProject(t_time_sk=[$0], t_hour=[CAST(12):INTEGER], t_minute=[$4])
+                          HiveFilter(condition=[AND(=($3, 12), <($4, 30), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                      HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                        HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject($f0=[$0])
+                HiveAggregate(group=[{}], agg#0=[count()])
+                  HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                          HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                          HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                      HiveProject(t_time_sk=[$0], t_hour=[CAST(11):INTEGER], t_minute=[$4])
+                        HiveFilter(condition=[AND(=($3, 11), >=($4, 30), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                    HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                      HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+            HiveProject($f0=[$0])
+              HiveAggregate(group=[{}], agg#0=[count()])
+                HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                        HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                        HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                    HiveProject(t_time_sk=[$0], t_hour=[CAST(11):INTEGER], t_minute=[$4])
+                      HiveFilter(condition=[AND(=($3, 11), <($4, 30), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                  HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                    HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveProject($f0=[$0])
+            HiveAggregate(group=[{}], agg#0=[count()])
+              HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                      HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                      HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                  HiveProject(t_time_sk=[$0], t_hour=[CAST(10):INTEGER], t_minute=[$4])
+                    HiveFilter(condition=[AND(=($3, 10), >=($4, 30), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                  HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+        HiveProject($f0=[$0])
+          HiveAggregate(group=[{}], agg#0=[count()])
+            HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                    HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                    HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(t_time_sk=[$0], t_hour=[CAST(10):INTEGER], t_minute=[$4])
+                  HiveFilter(condition=[AND(=($3, 10), <($4, 30), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+              HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store]], table:alias=[store])
+      HiveProject($f0=[$0])
+        HiveAggregate(group=[{}], agg#0=[count()])
+          HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                  HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+              HiveProject(t_time_sk=[$0], t_hour=[CAST(9):INTEGER], t_minute=[$4])
+                HiveFilter(condition=[AND(=($3, 9), >=($4, 30), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+              HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, store]], table:alias=[store])
+    HiveProject($f0=[$0])
+      HiveAggregate(group=[{}], agg#0=[count()])
+        HiveJoin(condition=[=($2, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_time_sk=[$1], ss_hdemo_sk=[$5], ss_store_sk=[$7])
+                HiveFilter(condition=[AND(IS NOT NULL($5), IS NOT NULL($1), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                HiveFilter(condition=[AND(IN($3, 3, 0, 1), <=($4, 5), OR(AND(=($3, 3), IS NOT NULL($4)), AND(=($3, 0), <=($4, 2)), AND(=($3, 1), <=($4, 3))), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+            HiveProject(t_time_sk=[$0], t_hour=[CAST(9):INTEGER], t_minute=[$4])
+              HiveFilter(condition=[AND(=($3, 9), <($4, 30), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+          HiveProject(s_store_sk=[$0], s_store_name=[CAST(_UTF-16LE'ese'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+            HiveFilter(condition=[AND(=($5, _UTF-16LE'ese'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out
new file mode 100644
index 0000000..72f22b6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query89.q.out
@@ -0,0 +1,88 @@
+PREHOOK: query: explain cbo
+select  *
+from(
+select i_category, i_class, i_brand,
+       s_store_name, s_company_name,
+       d_moy,
+       sum(ss_sales_price) sum_sales,
+       avg(sum(ss_sales_price)) over
+         (partition by i_category, i_brand, s_store_name, s_company_name)
+         avg_monthly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+      ss_sold_date_sk = d_date_sk and
+      ss_store_sk = s_store_sk and
+      d_year in (2000) and
+        ((i_category in ('Home','Books','Electronics') and
+          i_class in ('wallpaper','parenting','musical')
+         )
+      or (i_category in ('Shoes','Jewelry','Men') and
+          i_class in ('womens','birdal','pants') 
+        ))
+group by i_category, i_class, i_brand,
+         s_store_name, s_company_name, d_moy) tmp1
+where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
+order by sum_sales - avg_monthly_sales, s_store_name
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from(
+select i_category, i_class, i_brand,
+       s_store_name, s_company_name,
+       d_moy,
+       sum(ss_sales_price) sum_sales,
+       avg(sum(ss_sales_price)) over
+         (partition by i_category, i_brand, s_store_name, s_company_name)
+         avg_monthly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+      ss_sold_date_sk = d_date_sk and
+      ss_store_sk = s_store_sk and
+      d_year in (2000) and
+        ((i_category in ('Home','Books','Electronics') and
+          i_class in ('wallpaper','parenting','musical')
+         )
+      or (i_category in ('Shoes','Jewelry','Men') and
+          i_class in ('womens','birdal','pants') 
+        ))
+group by i_category, i_class, i_brand,
+         s_store_name, s_company_name, d_moy) tmp1
+where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
+order by sum_sales - avg_monthly_sales, s_store_name
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], s_store_name=[$3], s_company_name=[$4], d_moy=[$5], sum_sales=[$6], avg_monthly_sales=[$7])
+  HiveSortLimit(sort0=[$8], sort1=[$3], dir0=[ASC], dir1=[ASC], fetch=[100])
+    HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], s_store_name=[$3], s_company_name=[$4], d_moy=[$5], sum_sales=[$6], avg_monthly_sales=[$7], (- (tok_table_or_col sum_sales) (tok_table_or_col avg_monthly_sales))=[-($6, $7)])
+      HiveFilter(condition=[CASE(<>($7, 0), >(/(ABS(-($6, $7)), $7), 0.1), null)])
+        HiveProject((tok_table_or_col i_category)=[$2], (tok_table_or_col i_class)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[avg($6) OVER (PARTITION BY $2, $0, $4, $5 ORDER BY $2 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $5 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+          HiveProject(i_brand=[$0], i_class=[$1], i_category=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+            HiveAggregate(group=[{5, 6, 7, 10, 12, 13}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12])
+                      HiveFilter(condition=[AND(IN($10, _UTF-16LE'wallpaper', _UTF-16LE'parenting', _UTF-16LE'musical', _UTF-16LE'womens', _UTF-16LE'birdal', _UTF-16LE'pants'), IN($12, _UTF-16LE'Home', _UTF-16LE'Books', _UTF-16LE'Electronics', _UTF-16LE'Shoes', _UTF-16LE'Jewelry', _UTF-16LE'Men'), OR(AND(IN($12, _UTF-16LE'Home', _UTF-16LE'Books', _UTF-16LE'Electronics'), IN($10, _UTF-16LE'wallpaper', _UTF-16LE'parenting', _UTF-16LE'musical')), AND(IN($12, _UTF-16LE'Shoes', _UTF-16LE'Jewelry', _UTF-16LE'Men'), IN($10, _UTF-16LE'womens', _UTF-16LE'birdal', _UTF-16LE'pants'))), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[$8])
+                    HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query9.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query9.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query9.q.out
new file mode 100644
index 0000000..3ec1916
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query9.q.out
@@ -0,0 +1,200 @@
+Warning: Shuffle Join MERGEJOIN[171][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 2' is a cross product
+Warning: Shuffle Join MERGEJOIN[172][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 3' is a cross product
+Warning: Shuffle Join MERGEJOIN[173][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[174][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[175][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[176][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[177][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[178][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8]] in Stage 'Reducer 9' is a cross product
+Warning: Shuffle Join MERGEJOIN[179][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9]] in Stage 'Reducer 10' is a cross product
+Warning: Shuffle Join MERGEJOIN[180][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10]] in Stage 'Reducer 11' is a cross product
+Warning: Shuffle Join MERGEJOIN[181][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11]] in Stage 'Reducer 12' is a cross product
+Warning: Shuffle Join MERGEJOIN[182][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12]] in Stage 'Reducer 13' is a cross product
+Warning: Shuffle Join MERGEJOIN[183][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13]] in Stage 'Reducer 14' is a cross product
+Warning: Shuffle Join MERGEJOIN[184][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14]] in Stage 'Reducer 15' is a cross product
+Warning: Shuffle Join MERGEJOIN[185][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5, $hdt$_6, $hdt$_7, $hdt$_8, $hdt$_9, $hdt$_10, $hdt$_11, $hdt$_12, $hdt$_13, $hdt$_14, $hdt$_15]] in Stage 'Reducer 16' is a cross product
+PREHOOK: query: explain cbo
+select case when (select count(*) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@reason
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select case when (select count(*) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@reason
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(bucket1=[CASE(>($1, 409437), $2, $3)], bucket2=[CASE(>($4, 4595804), $5, $6)], bucket3=[CASE(>($7, 7887297), $8, $9)], bucket4=[CASE(>($10, 10872978), $11, $12)], bucket5=[CASE(>($13, 43571537), $14, $15)])
+  HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+    HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                              HiveJoin(condition=[true], joinType=[left], algorithm=[none], cost=[not available])
+                                HiveProject(r_reason_sk=[CAST(1):INTEGER])
+                                  HiveFilter(condition=[=($0, 1)])
+                                    HiveTableScan(table=[[default, reason]], table:alias=[reason])
+                                HiveProject($f0=[$0])
+                                  HiveAggregate(group=[{}], agg#0=[count()])
+                                    HiveFilter(condition=[BETWEEN(false, $10, 1, 20)])
+                                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                              HiveProject($f0=[/($0, $1)])
+                                HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                                  HiveFilter(condition=[BETWEEN(false, $10, 1, 20)])
+                                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject($f0=[/($0, $1)])
+                              HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+                                HiveFilter(condition=[BETWEEN(false, $10, 1, 20)])
+                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{}], agg#0=[count()])
+                              HiveFilter(condition=[BETWEEN(false, $10, 21, 40)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject($f0=[/($0, $1)])
+                          HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                            HiveFilter(condition=[BETWEEN(false, $10, 21, 40)])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject($f0=[/($0, $1)])
+                        HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+                          HiveFilter(condition=[BETWEEN(false, $10, 21, 40)])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject($f0=[$0])
+                      HiveAggregate(group=[{}], agg#0=[count()])
+                        HiveFilter(condition=[BETWEEN(false, $10, 41, 60)])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject($f0=[/($0, $1)])
+                    HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                      HiveFilter(condition=[BETWEEN(false, $10, 41, 60)])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+                    HiveFilter(condition=[BETWEEN(false, $10, 41, 60)])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject($f0=[$0])
+                HiveAggregate(group=[{}], agg#0=[count()])
+                  HiveFilter(condition=[BETWEEN(false, $10, 61, 80)])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject($f0=[/($0, $1)])
+              HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+                HiveFilter(condition=[BETWEEN(false, $10, 61, 80)])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject($f0=[/($0, $1)])
+            HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+              HiveFilter(condition=[BETWEEN(false, $10, 61, 80)])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+        HiveProject($f0=[$0])
+          HiveAggregate(group=[{}], agg#0=[count()])
+            HiveFilter(condition=[BETWEEN(false, $10, 81, 100)])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+      HiveProject($f0=[/($0, $1)])
+        HiveAggregate(group=[{}], agg#0=[sum($17)], agg#1=[count($17)])
+          HiveFilter(condition=[BETWEEN(false, $10, 81, 100)])
+            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+    HiveProject($f0=[/($0, $1)])
+      HiveAggregate(group=[{}], agg#0=[sum($21)], agg#1=[count($21)])
+        HiveFilter(condition=[BETWEEN(false, $10, 81, 100)])
+          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query90.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query90.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query90.q.out
new file mode 100644
index 0000000..c1567c7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query90.q.out
@@ -0,0 +1,92 @@
+Warning: Shuffle Join MERGEJOIN[152][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
+PREHOOK: query: explain cbo
+select  cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio
+ from ( select count(*) amc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 6 and 6+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) at,
+      ( select count(*) pmc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 14 and 14+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) pt
+ order by am_pm_ratio
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio
+ from ( select count(*) amc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 6 and 6+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) at,
+      ( select count(*) pmc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 14 and 14+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) pt
+ order by am_pm_ratio
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(am_pm_ratio=[/(CAST($0):DECIMAL(15, 4), CAST($1):DECIMAL(15, 4))])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject($f0=[$0])
+        HiveAggregate(group=[{}], agg#0=[count()])
+          HiveJoin(condition=[=($1, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_time_sk=[$1], ws_ship_hdemo_sk=[$10], ws_web_page_sk=[$12])
+                  HiveFilter(condition=[AND(IS NOT NULL($10), IS NOT NULL($1), IS NOT NULL($12))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(wp_web_page_sk=[$0], wp_char_count=[$10])
+                  HiveFilter(condition=[AND(BETWEEN(false, $10, 5000, 5200), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, web_page]], table:alias=[web_page])
+              HiveProject(t_time_sk=[$0], t_hour=[$3])
+                HiveFilter(condition=[AND(BETWEEN(false, $3, 6, 7), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(hd_demo_sk=[$0], hd_dep_count=[CAST(8):INTEGER])
+              HiveFilter(condition=[AND(=($3, 8), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+      HiveProject($f0=[$0])
+        HiveAggregate(group=[{}], agg#0=[count()])
+          HiveJoin(condition=[=($1, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_time_sk=[$1], ws_ship_hdemo_sk=[$10], ws_web_page_sk=[$12])
+                  HiveFilter(condition=[AND(IS NOT NULL($10), IS NOT NULL($1), IS NOT NULL($12))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(wp_web_page_sk=[$0], wp_char_count=[$10])
+                  HiveFilter(condition=[AND(BETWEEN(false, $10, 5000, 5200), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, web_page]], table:alias=[web_page])
+              HiveProject(t_time_sk=[$0], t_hour=[$3])
+                HiveFilter(condition=[AND(BETWEEN(false, $3, 14, 15), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+            HiveProject(hd_demo_sk=[$0], hd_dep_count=[CAST(8):INTEGER])
+              HiveFilter(condition=[AND(=($3, 8), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out
new file mode 100644
index 0000000..6b58ccc
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query91.q.out
@@ -0,0 +1,110 @@
+PREHOOK: query: explain cbo
+select  
+        cc_call_center_id Call_Center,
+        cc_name Call_Center_Name,
+        cc_manager Manager,
+        sum(cr_net_loss) Returns_Loss
+from
+        call_center,
+        catalog_returns,
+        date_dim,
+        customer,
+        customer_address,
+        customer_demographics,
+        household_demographics
+where
+        cr_call_center_sk       = cc_call_center_sk
+and     cr_returned_date_sk     = d_date_sk
+and     cr_returning_customer_sk= c_customer_sk
+and     cd_demo_sk              = c_current_cdemo_sk
+and     hd_demo_sk              = c_current_hdemo_sk
+and     ca_address_sk           = c_current_addr_sk
+and     d_year                  = 1999 
+and     d_moy                   = 11
+and     ( (cd_marital_status       = 'M' and cd_education_status     = 'Unknown')
+        or(cd_marital_status       = 'W' and cd_education_status     = 'Advanced Degree'))
+and     hd_buy_potential like '0-500%'
+and     ca_gmt_offset           = -7
+group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status
+order by sum(cr_net_loss) desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+        cc_call_center_id Call_Center,
+        cc_name Call_Center_Name,
+        cc_manager Manager,
+        sum(cr_net_loss) Returns_Loss
+from
+        call_center,
+        catalog_returns,
+        date_dim,
+        customer,
+        customer_address,
+        customer_demographics,
+        household_demographics
+where
+        cr_call_center_sk       = cc_call_center_sk
+and     cr_returned_date_sk     = d_date_sk
+and     cr_returning_customer_sk= c_customer_sk
+and     cd_demo_sk              = c_current_cdemo_sk
+and     hd_demo_sk              = c_current_hdemo_sk
+and     ca_address_sk           = c_current_addr_sk
+and     d_year                  = 1999 
+and     d_moy                   = 11
+and     ( (cd_marital_status       = 'M' and cd_education_status     = 'Unknown')
+        or(cd_marital_status       = 'W' and cd_education_status     = 'Advanced Degree'))
+and     hd_buy_potential like '0-500%'
+and     ca_gmt_offset           = -7
+group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status
+order by sum(cr_net_loss) desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(call_center=[$0], call_center_name=[$1], manager=[$2], returns_loss=[$3])
+  HiveSortLimit(sort0=[$4], dir0=[DESC-nulls-last])
+    HiveProject(call_center=[$2], call_center_name=[$3], manager=[$4], returns_loss=[$5], (tok_function sum (tok_table_or_col cr_net_loss))=[$5])
+      HiveAggregate(group=[{7, 8, 17, 18, 19}], agg#0=[sum($12)])
+        HiveJoin(condition=[=($20, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($10, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-7):DECIMAL(5, 2)])
+                HiveFilter(condition=[AND(=($11, -7), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($4, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4), IS NOT NULL($2), IS NOT NULL($3))])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
+                  HiveFilter(condition=[AND(IN($3, _UTF-16LE'Unknown', _UTF-16LE'Advanced Degree'), IN($2, _UTF-16LE'M', _UTF-16LE'W'), IN(ROW($2, $3), ROW(_UTF-16LE'M', _UTF-16LE'Unknown'), ROW(_UTF-16LE'W', _UTF-16LE'Advanced Degree')), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+            HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$1], cr_call_center_sk=[$2], cr_net_loss=[$3], d_date_sk=[$4], d_year=[$5], d_moy=[$6], cc_call_center_sk=[$7], cc_call_center_id=[$8], cc_name=[$9], cc_manager=[$10])
+              HiveJoin(condition=[=($2, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cr_returned_date_sk=[$0], cr_returning_customer_sk=[$7], cr_call_center_sk=[$11], cr_net_loss=[$26])
+                    HiveFilter(condition=[AND(IS NOT NULL($11), IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(11):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 1999), =($8, 11), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(cc_call_center_sk=[$0], cc_call_center_id=[$1], cc_name=[$6], cc_manager=[$11])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, call_center]], table:alias=[call_center])
+          HiveProject(hd_demo_sk=[$0], hd_buy_potential=[$2])
+            HiveFilter(condition=[AND(LIKE($2, _UTF-16LE'0-500%'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query92.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query92.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query92.q.out
new file mode 100644
index 0000000..5a0e1da
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query92.q.out
@@ -0,0 +1,94 @@
+PREHOOK: query: explain cbo
+select  
+   sum(ws_ext_discount_amt)  as `Excess Discount Amount` 
+from 
+    web_sales 
+   ,item 
+   ,date_dim
+where
+i_manufact_id = 269
+and i_item_sk = ws_item_sk 
+and d_date between '1998-03-18' and 
+        (cast('1998-03-18' as date) + 90 days)
+and d_date_sk = ws_sold_date_sk 
+and ws_ext_discount_amt  
+     > ( 
+         SELECT 
+            1.3 * avg(ws_ext_discount_amt) 
+         FROM 
+            web_sales 
+           ,date_dim
+         WHERE 
+              ws_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 = ws_sold_date_sk 
+      ) 
+order by sum(ws_ext_discount_amt)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   sum(ws_ext_discount_amt)  as `Excess Discount Amount` 
+from 
+    web_sales 
+   ,item 
+   ,date_dim
+where
+i_manufact_id = 269
+and i_item_sk = ws_item_sk 
+and d_date between '1998-03-18' and 
+        (cast('1998-03-18' as date) + 90 days)
+and d_date_sk = ws_sold_date_sk 
+and ws_ext_discount_amt  
+     > ( 
+         SELECT 
+            1.3 * avg(ws_ext_discount_amt) 
+         FROM 
+            web_sales 
+           ,date_dim
+         WHERE 
+              ws_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 = ws_sold_date_sk 
+      ) 
+order by sum(ws_ext_discount_amt)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(excess discount amount=[$0])
+  HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+    HiveProject(excess discount amount=[$0], (tok_function sum (tok_table_or_col ws_ext_discount_amt))=[$0])
+      HiveAggregate(group=[{}], agg#0=[sum($2)])
+        HiveJoin(condition=[AND(>($2, CAST(*(1.3, $6)):DECIMAL(14, 7)), =($7, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_discount_amt=[$22])
+              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+            HiveProject(d_date_sk=[$0], d_date=[$2])
+              HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(ws_item_sk=[$0], $f1=[$1], i_item_sk=[$2], i_manufact_id=[$3])
+            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ws_item_sk=[$0], $f1=[/($1, $2)])
+                HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_discount_amt=[$22])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_date=[$2])
+                      HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(i_item_sk=[$0], i_manufact_id=[CAST(269):INTEGER])
+                HiveFilter(condition=[AND(=($13, 269), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+


[47/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out
new file mode 100644
index 0000000..b226905
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query10.q.out
@@ -0,0 +1,178 @@
+PREHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2002 and
+                d_moy between 4 and 4+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 ANd 4+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 and 4+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2002 and
+                d_moy between 4 and 4+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 ANd 4+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2002 and
+                  d_moy between 4 and 4+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$4], sort4=[$6], sort5=[$8], sort6=[$10], sort7=[$12], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], fetch=[100])
+  HiveProject(cd_gender=[$0], cd_marital_status=[$1], cd_education_status=[$2], cnt1=[$8], cd_purchase_estimate=[$3], cnt2=[$8], cd_credit_rating=[$4], cnt3=[$8], cd_dep_count=[$5], cnt4=[$8], cd_dep_employed_count=[$6], cnt5=[$8], cd_dep_college_count=[$7], cnt6=[$8])
+    HiveAggregate(group=[{6, 7, 8, 9, 10, 11, 12, 13}], agg#0=[count()])
+      HiveFilter(condition=[OR(IS NOT NULL($15), IS NOT NULL($17))])
+        HiveJoin(condition=[=($0, $16)], joinType=[left], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $14)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveSemiJoin(condition=[=($0, $14)], joinType=[inner])
+              HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, customer]], table:alias=[c])
+                  HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                    HiveFilter(condition=[AND(IN($7, _UTF-16LE'Walker County', _UTF-16LE'Richland County', _UTF-16LE'Gaines County', _UTF-16LE'Douglas County', _UTF-16LE'Dona Ana County'), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
+                HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_education_status=[$3], cd_purchase_estimate=[$4], cd_credit_rating=[$5], cd_dep_count=[$6], cd_dep_employed_count=[$7], cd_dep_college_count=[$8])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+              HiveProject(ss_customer_sk0=[$1])
+                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER], d_moy=[$8])
+                    HiveFilter(condition=[AND(=($6, 2002), BETWEEN(false, $8, 4, 7), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(ws_bill_customer_sk0=[$0], $f1=[true])
+              HiveAggregate(group=[{1}])
+                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                    HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER], d_moy=[$8])
+                    HiveFilter(condition=[AND(=($6, 2002), BETWEEN(false, $8, 4, 7), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(cs_ship_customer_sk0=[$0], $f1=[true])
+            HiveAggregate(group=[{1}])
+              HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_ship_customer_sk=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER], d_moy=[$8])
+                  HiveFilter(condition=[AND(=($6, 2002), BETWEEN(false, $8, 4, 7), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out
new file mode 100644
index 0000000..e09f7ec
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query11.q.out
@@ -0,0 +1,223 @@
+PREHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year 
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.c_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.dyear = 2001
+         and t_s_secyear.dyear = 2001+1
+         and t_w_firstyear.dyear = 2001
+         and t_w_secyear.dyear = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+             > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by t_s_secyear.c_preferred_cust_flag
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year 
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.c_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.dyear = 2001
+         and t_s_secyear.dyear = 2001+1
+         and t_w_firstyear.dyear = 2001
+         and t_w_secyear.dyear = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+             > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by t_s_secyear.c_preferred_cust_flag
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(c_preferred_cust_flag=[$1])
+    HiveJoin(condition=[AND(=($0, $5), CASE(CAST(IS NOT NULL($6)):BOOLEAN, CASE(CAST(IS NOT NULL($8)):BOOLEAN, >(/($4, $8), /($2, $6)), >(null, /($2, $6))), CASE(CAST(IS NOT NULL($8)):BOOLEAN, >(/($4, $8), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject($f0=[$0], $f4=[$3], $f9=[$7])
+        HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+          HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f9=[-($11, $10)])
+            HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_ext_discount_amt=[$14], ss_ext_list_price=[$17])
+                  HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                  HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveJoin(condition=[=($2, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject($f0=[$0], $f8=[$7])
+            HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+              HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[-($11, $10)])
+                HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_ext_discount_amt=[$22], ws_ext_list_price=[$25])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                      HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject($f0=[$0], $f9=[$7])
+            HiveFilter(condition=[>($7, 0)])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f9=[-($11, $10)])
+                  HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_ext_discount_amt=[$14], ss_ext_list_price=[$17])
+                        HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject($f0=[$0], $f8=[$7])
+          HiveFilter(condition=[>($7, 0)])
+            HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+              HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[-($11, $10)])
+                HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_ext_discount_amt=[$22], ws_ext_list_price=[$25])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                      HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out
new file mode 100644
index 0000000..dbfe6e7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query12.q.out
@@ -0,0 +1,89 @@
+PREHOOK: query: explain cbo
+select  i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ws_ext_sales_price) as itemrevenue 
+      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	web_sales
+    	,item 
+    	,date_dim
+where 
+	ws_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ws_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ws_ext_sales_price) as itemrevenue 
+      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	web_sales
+    	,item 
+    	,date_dim
+where 
+	ws_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ws_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_item_desc=[$0], i_category=[$1], i_class=[$2], i_current_price=[$3], itemrevenue=[$4], revenueratio=[$5])
+  HiveSortLimit(sort0=[$1], sort1=[$2], sort2=[$6], sort3=[$0], sort4=[$5], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+    HiveProject(i_item_desc=[$1], i_category=[$4], i_class=[$3], i_current_price=[$2], itemrevenue=[$5], revenueratio=[/(*($5, CAST(100):DECIMAL(10, 0)), sum($5) OVER (PARTITION BY $3 ORDER BY $3 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING))], (tok_table_or_col i_item_id)=[$0])
+      HiveAggregate(group=[{1, 2, 3, 4, 5}], agg#0=[sum($8)])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_class=[$10], i_category=[$12])
+            HiveFilter(condition=[AND(IN($12, _UTF-16LE'Jewelry', _UTF-16LE'Sports', _UTF-16LE'Books'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_ext_sales_price=[$23])
+              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+            HiveProject(d_date_sk=[$0], d_date=[$2])
+              HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-01-12 00:00:00, 2001-02-11 00:00:00), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out
new file mode 100644
index 0000000..ccad088
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query13.q.out
@@ -0,0 +1,141 @@
+PREHOOK: query: explain cbo
+select avg(ss_quantity)
+       ,avg(ss_ext_sales_price)
+       ,avg(ss_ext_wholesale_cost)
+       ,sum(ss_ext_wholesale_cost)
+ from store_sales
+     ,store
+     ,customer_demographics
+     ,household_demographics
+     ,customer_address
+     ,date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 2001
+ and((ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'M'
+  and cd_education_status = '4 yr Degree'
+  and ss_sales_price between 100.00 and 150.00
+  and hd_dep_count = 3   
+     )or
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'D'
+  and cd_education_status = 'Primary'
+  and ss_sales_price between 50.00 and 100.00   
+  and hd_dep_count = 1
+     ) or 
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'U'
+  and cd_education_status = 'Advanced Degree'
+  and ss_sales_price between 150.00 and 200.00 
+  and hd_dep_count = 1  
+     ))
+ and((ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 100 and 200  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 300  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 250  
+     ))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select avg(ss_quantity)
+       ,avg(ss_ext_sales_price)
+       ,avg(ss_ext_wholesale_cost)
+       ,sum(ss_ext_wholesale_cost)
+ from store_sales
+     ,store
+     ,customer_demographics
+     ,household_demographics
+     ,customer_address
+     ,date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 2001
+ and((ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'M'
+  and cd_education_status = '4 yr Degree'
+  and ss_sales_price between 100.00 and 150.00
+  and hd_dep_count = 3   
+     )or
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'D'
+  and cd_education_status = 'Primary'
+  and ss_sales_price between 50.00 and 100.00   
+  and hd_dep_count = 1
+     ) or 
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'U'
+  and cd_education_status = 'Advanced Degree'
+  and ss_sales_price between 150.00 and 200.00 
+  and hd_dep_count = 1  
+     ))
+ and((ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 100 and 200  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 300  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 250  
+     ))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject($f0=[/(CAST($0):DOUBLE, $1)], $f1=[/($2, $3)], $f2=[/($4, $5)], $f3=[CAST($4):DECIMAL(17, 2)])
+  HiveAggregate(group=[{}], agg#0=[sum($16)], agg#1=[count($16)], agg#2=[sum($18)], agg#3=[count($18)], agg#4=[sum($19)], agg#5=[count($19)])
+    HiveJoin(condition=[AND(=($0, $12), OR(AND(=($1, _UTF-16LE'M'), =($2, _UTF-16LE'4 yr Degree'), BETWEEN(false, $17, 100, 150), =($7, 3)), AND(=($1, _UTF-16LE'D'), =($2, _UTF-16LE'Primary'), BETWEEN(false, $17, 50, 100), =($7, 1)), AND(=($1, _UTF-16LE'U'), =($2, _UTF-16LE'Advanced Degree'), BETWEEN(false, $17, 150, 200), =($7, 1))))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2], cd_education_status=[$3])
+        HiveFilter(condition=[AND(IN($2, _UTF-16LE'M', _UTF-16LE'D', _UTF-16LE'U'), IN($3, _UTF-16LE'4 yr Degree', _UTF-16LE'Primary', _UTF-16LE'Advanced Degree'), IS NOT NULL($0))])
+          HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+      HiveJoin(condition=[AND(=($11, $0), OR(AND(IN($1, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM'), BETWEEN(false, $17, 100, 200)), AND(IN($1, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN'), BETWEEN(false, $17, 150, 300)), AND(IN($1, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), BETWEEN(false, $17, 50, 250))))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_country=[CAST(_UTF-16LE'United States'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+          HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'), IS NOT NULL($0))])
+            HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+        HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3])
+            HiveFilter(condition=[AND(IN($3, 3, 1), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+              HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(s_store_sk=[$0])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(ss_sold_date_sk=[$0], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_quantity=[$10], ss_sales_price=[$13], ss_ext_sales_price=[$15], ss_ext_wholesale_cost=[$16], ss_net_profit=[$22])
+                HiveFilter(condition=[AND(OR(BETWEEN(false, $13, 100, 150), BETWEEN(false, $13, 50, 100), BETWEEN(false, $13, 150, 200)), OR(BETWEEN(false, $22, 100, 200), BETWEEN(false, $22, 150, 300), BETWEEN(false, $22, 50, 250)), IS NOT NULL($7), IS NOT NULL($4), IS NOT NULL($5), IS NOT NULL($6), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query14.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query14.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query14.q.out
new file mode 100644
index 0000000..9bb4f2e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query14.q.out
@@ -0,0 +1,618 @@
+Warning: Shuffle Join MERGEJOIN[1446][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[1458][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[1448][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 13' is a cross product
+Warning: Shuffle Join MERGEJOIN[1471][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 14' is a cross product
+Warning: Shuffle Join MERGEJOIN[1450][tables = [$hdt$_2, $hdt$_3]] in Stage 'Reducer 18' is a cross product
+Warning: Shuffle Join MERGEJOIN[1484][tables = [$hdt$_2, $hdt$_3, $hdt$_1]] in Stage 'Reducer 19' is a cross product
+PREHOOK: query: explain cbo
+with  cross_items as
+ (select i_item_sk ss_item_sk
+ from item,
+ (select iss.i_brand_id brand_id
+     ,iss.i_class_id class_id
+     ,iss.i_category_id category_id
+ from store_sales
+     ,item iss
+     ,date_dim d1
+ where ss_item_sk = iss.i_item_sk
+   and ss_sold_date_sk = d1.d_date_sk
+   and d1.d_year between 1999 AND 1999 + 2
+ intersect 
+ select ics.i_brand_id
+     ,ics.i_class_id
+     ,ics.i_category_id
+ from catalog_sales
+     ,item ics
+     ,date_dim d2
+ where cs_item_sk = ics.i_item_sk
+   and cs_sold_date_sk = d2.d_date_sk
+   and d2.d_year between 1999 AND 1999 + 2
+ intersect
+ select iws.i_brand_id
+     ,iws.i_class_id
+     ,iws.i_category_id
+ from web_sales
+     ,item iws
+     ,date_dim d3
+ where ws_item_sk = iws.i_item_sk
+   and ws_sold_date_sk = d3.d_date_sk
+   and d3.d_year between 1999 AND 1999 + 2) x
+ where i_brand_id = brand_id
+      and i_class_id = class_id
+      and i_category_id = category_id
+),
+ avg_sales as
+ (select avg(quantity*list_price) average_sales
+  from (select ss_quantity quantity
+             ,ss_list_price list_price
+       from store_sales
+           ,date_dim
+       where ss_sold_date_sk = d_date_sk
+         and d_year between 1999 and 2001 
+       union all 
+       select cs_quantity quantity 
+             ,cs_list_price list_price
+       from catalog_sales
+           ,date_dim
+       where cs_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2 
+       union all
+       select ws_quantity quantity
+             ,ws_list_price list_price
+       from web_sales
+           ,date_dim
+       where ws_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2) x)
+  select  channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
+ from(
+       select 'store' channel, i_brand_id,i_class_id
+             ,i_category_id,sum(ss_quantity*ss_list_price) sales
+             , count(*) number_sales
+       from store_sales
+           ,item
+           ,date_dim
+       where ss_item_sk in (select ss_item_sk from cross_items)
+         and ss_item_sk = i_item_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
+       from catalog_sales
+           ,item
+           ,date_dim
+       where cs_item_sk in (select ss_item_sk from cross_items)
+         and cs_item_sk = i_item_sk
+         and cs_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
+       from web_sales
+           ,item
+           ,date_dim
+       where ws_item_sk in (select ss_item_sk from cross_items)
+         and ws_item_sk = i_item_sk
+         and ws_sold_date_sk = d_date_sk
+         and d_year = 1998+2
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
+ ) y
+ group by rollup (channel, i_brand_id,i_class_id,i_category_id)
+ order by channel,i_brand_id,i_class_id,i_category_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with  cross_items as
+ (select i_item_sk ss_item_sk
+ from item,
+ (select iss.i_brand_id brand_id
+     ,iss.i_class_id class_id
+     ,iss.i_category_id category_id
+ from store_sales
+     ,item iss
+     ,date_dim d1
+ where ss_item_sk = iss.i_item_sk
+   and ss_sold_date_sk = d1.d_date_sk
+   and d1.d_year between 1999 AND 1999 + 2
+ intersect 
+ select ics.i_brand_id
+     ,ics.i_class_id
+     ,ics.i_category_id
+ from catalog_sales
+     ,item ics
+     ,date_dim d2
+ where cs_item_sk = ics.i_item_sk
+   and cs_sold_date_sk = d2.d_date_sk
+   and d2.d_year between 1999 AND 1999 + 2
+ intersect
+ select iws.i_brand_id
+     ,iws.i_class_id
+     ,iws.i_category_id
+ from web_sales
+     ,item iws
+     ,date_dim d3
+ where ws_item_sk = iws.i_item_sk
+   and ws_sold_date_sk = d3.d_date_sk
+   and d3.d_year between 1999 AND 1999 + 2) x
+ where i_brand_id = brand_id
+      and i_class_id = class_id
+      and i_category_id = category_id
+),
+ avg_sales as
+ (select avg(quantity*list_price) average_sales
+  from (select ss_quantity quantity
+             ,ss_list_price list_price
+       from store_sales
+           ,date_dim
+       where ss_sold_date_sk = d_date_sk
+         and d_year between 1999 and 2001 
+       union all 
+       select cs_quantity quantity 
+             ,cs_list_price list_price
+       from catalog_sales
+           ,date_dim
+       where cs_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2 
+       union all
+       select ws_quantity quantity
+             ,ws_list_price list_price
+       from web_sales
+           ,date_dim
+       where ws_sold_date_sk = d_date_sk
+         and d_year between 1998 and 1998 + 2) x)
+  select  channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
+ from(
+       select 'store' channel, i_brand_id,i_class_id
+             ,i_category_id,sum(ss_quantity*ss_list_price) sales
+             , count(*) number_sales
+       from store_sales
+           ,item
+           ,date_dim
+       where ss_item_sk in (select ss_item_sk from cross_items)
+         and ss_item_sk = i_item_sk
+         and ss_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
+       from catalog_sales
+           ,item
+           ,date_dim
+       where cs_item_sk in (select ss_item_sk from cross_items)
+         and cs_item_sk = i_item_sk
+         and cs_sold_date_sk = d_date_sk
+         and d_year = 1998+2 
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
+       union all
+       select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
+       from web_sales
+           ,item
+           ,date_dim
+       where ws_item_sk in (select ss_item_sk from cross_items)
+         and ws_item_sk = i_item_sk
+         and ws_sold_date_sk = d_date_sk
+         and d_year = 1998+2
+         and d_moy = 11
+       group by i_brand_id,i_class_id,i_category_id
+       having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
+ ) y
+ group by rollup (channel, i_brand_id,i_class_id,i_category_id)
+ order by channel,i_brand_id,i_class_id,i_category_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject(channel=[$0], i_brand_id=[$1], i_class_id=[$2], i_category_id=[$3], $f4=[$4], $f5=[$5])
+    HiveAggregate(group=[{0, 1, 2, 3}], groups=[[{0, 1, 2, 3}, {0, 1, 2}, {0, 1}, {0}, {}]], agg#0=[sum($4)], agg#1=[sum($5)])
+      HiveProject(channel=[$0], i_brand_id=[$1], i_class_id=[$2], i_category_id=[$3], sales=[$4], number_sales=[$5])
+        HiveUnion(all=[true])
+          HiveProject(channel=[_UTF-16LE'store'], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], sales=[$3], number_sales=[$4])
+            HiveJoin(condition=[>($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[count()])
+                  HiveProject($f0=[$2], $f1=[$3], $f2=[$4], $f3=[*(CAST($7):DECIMAL(10, 0), $8)])
+                    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0])
+                        HiveAggregate(group=[{0}])
+                          HiveJoin(condition=[AND(AND(=($1, $4), =($2, $5)), =($3, $6))], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                              HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, item]], table:alias=[item])
+                            HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                              HiveFilter(condition=[=($3, 3)])
+                                HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+                                  HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                    HiveUnion(all=[true])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                                HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[iss])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15])
+                                                HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[ics])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3])
+                                                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[iws])
+                      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_quantity=[$10], ss_list_price=[$12])
+                            HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(11):INTEGER])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 11), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{}], agg#0=[count($0)])
+                              HiveProject(quantity=[$0], list_price=[$1])
+                                HiveUnion(all=[true])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[count($0)])
+                    HiveProject($f0=[*(CAST($0):DECIMAL(10, 0), $1)])
+                      HiveUnion(all=[true])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'catalog'], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], sales=[$3], number_sales=[$4])
+            HiveJoin(condition=[>($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[count()])
+                  HiveProject($f0=[$2], $f1=[$3], $f2=[$4], $f3=[*(CAST($7):DECIMAL(10, 0), $8)])
+                    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0])
+                        HiveAggregate(group=[{0}])
+                          HiveJoin(condition=[AND(AND(=($1, $4), =($2, $5)), =($3, $6))], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                              HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, item]], table:alias=[item])
+                            HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                              HiveFilter(condition=[=($3, 3)])
+                                HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+                                  HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                    HiveUnion(all=[true])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                                HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[iss])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15])
+                                                HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[ics])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3])
+                                                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[iws])
+                      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_quantity=[$18], cs_list_price=[$20])
+                            HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(11):INTEGER])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 11), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{}], agg#0=[count($0)])
+                              HiveProject(quantity=[$0], list_price=[$1])
+                                HiveUnion(all=[true])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[count($0)])
+                    HiveProject($f0=[*(CAST($0):DECIMAL(10, 0), $1)])
+                      HiveUnion(all=[true])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(channel=[_UTF-16LE'web'], i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], sales=[$3], number_sales=[$4])
+            HiveJoin(condition=[>($3, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4])
+                HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($3)], agg#1=[count()])
+                  HiveProject($f0=[$2], $f1=[$3], $f2=[$4], $f3=[*(CAST($7):DECIMAL(10, 0), $8)])
+                    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0])
+                        HiveAggregate(group=[{0}])
+                          HiveJoin(condition=[AND(AND(=($1, $4), =($2, $5)), =($3, $6))], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                              HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, item]], table:alias=[item])
+                            HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                              HiveFilter(condition=[=($3, 3)])
+                                HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+                                  HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                    HiveUnion(all=[true])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2])
+                                                HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[iss])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15])
+                                                HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[ics])
+                                      HiveProject(i_brand_id=[$0], i_class_id=[$1], i_category_id=[$2], $f3=[$3])
+                                        HiveAggregate(group=[{5, 6, 7}], agg#0=[count()])
+                                          HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                                            HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                                              HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3])
+                                                HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                              HiveProject(d_date_sk=[$0], d_year=[$6])
+                                                HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                                  HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                                            HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($9), IS NOT NULL($11))])
+                                                HiveTableScan(table=[[default, item]], table:alias=[iws])
+                      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_class_id=[$9], i_category_id=[$11])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_quantity=[$18], ws_list_price=[$20])
+                            HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_moy=[CAST(11):INTEGER])
+                            HiveFilter(condition=[AND(=($6, 2000), =($8, 11), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cnt=[$0])
+                  HiveFilter(condition=[<=(sq_count_check($0), 1)])
+                    HiveProject(cnt=[$0])
+                      HiveAggregate(group=[{}], cnt=[COUNT()])
+                        HiveProject
+                          HiveProject($f0=[$0])
+                            HiveAggregate(group=[{}], agg#0=[count($0)])
+                              HiveProject(quantity=[$0], list_price=[$1])
+                                HiveUnion(all=[true])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                                  HiveProject(quantity=[$1], list_price=[$2])
+                                    HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                                      HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                                        HiveFilter(condition=[IS NOT NULL($0)])
+                                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                                      HiveProject(d_date_sk=[$0], d_year=[$6])
+                                        HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject($f0=[/($0, $1)])
+                  HiveAggregate(group=[{}], agg#0=[sum($0)], agg#1=[count($0)])
+                    HiveProject($f0=[*(CAST($0):DECIMAL(10, 0), $1)])
+                      HiveUnion(all=[true])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_quantity=[$10], ss_list_price=[$12])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1999, 2001), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_quantity=[$18], cs_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                        HiveProject(quantity=[$1], list_price=[$2])
+                          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_quantity=[$18], ws_list_price=[$20])
+                              HiveFilter(condition=[IS NOT NULL($0)])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0], d_year=[$6])
+                              HiveFilter(condition=[AND(BETWEEN(false, $6, 1998, 2000), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out
new file mode 100644
index 0000000..02ad7c2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query15.q.out
@@ -0,0 +1,69 @@
+PREHOOK: query: explain cbo
+select  ca_zip
+       ,sum(cs_sales_price)
+ from catalog_sales
+     ,customer
+     ,customer_address
+     ,date_dim
+ where cs_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
+                                   '85392', '85460', '80348', '81792')
+ 	      or ca_state in ('CA','WA','GA')
+ 	      or cs_sales_price > 500)
+ 	and cs_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip
+ order by ca_zip
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  ca_zip
+       ,sum(cs_sales_price)
+ from catalog_sales
+     ,customer
+     ,customer_address
+     ,date_dim
+ where cs_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
+                                   '85392', '85460', '80348', '81792')
+ 	      or ca_state in ('CA','WA','GA')
+ 	      or cs_sales_price > 500)
+ 	and cs_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip
+ order by ca_zip
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(ca_zip=[$0], $f1=[$1])
+    HiveAggregate(group=[{4}], agg#0=[sum($7)])
+      HiveJoin(condition=[AND(=($6, $0), OR(IN(substr($4, 1, 5), _UTF-16LE'85669', _UTF-16LE'86197', _UTF-16LE'88274', _UTF-16LE'83405', _UTF-16LE'86475', _UTF-16LE'85392', _UTF-16LE'85460', _UTF-16LE'80348', _UTF-16LE'81792'), >($7, 500), IN($3, _UTF-16LE'CA', _UTF-16LE'WA', _UTF-16LE'GA')))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+          HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_zip=[$9])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+        HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$1], cs_sales_price=[$2], d_date_sk=[$3], d_year=[$4], d_qoy=[$5])
+          HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_sales_price=[$21])
+              HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+            HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(2):INTEGER])
+              HiveFilter(condition=[AND(=($10, 2), =($6, 2000), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[51/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b8299551
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b8299551
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b8299551

Branch: refs/heads/master-tez092
Commit: b829955177907acc3dc64efca0bc812b1420d793
Parents: 7b9540e
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Tue Oct 9 12:12:27 2018 -0700
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Sun Oct 21 19:09:45 2018 -0700

----------------------------------------------------------------------
 data/conf/perf-reg/spark/hive-site.xml          |    7 +-
 data/conf/perf-reg/tez/hive-site.xml            |   17 +-
 data/scripts/q_perf_test_init.sql               |   96 +-
 data/scripts/q_perf_test_init_constraints.sql   |  771 +++++++
 .../hadoop/hive/cli/TestTezPerfCliDriver.java   |    2 +-
 .../cli/TestTezPerfConstraintsCliDriver.java    |   73 +
 .../test/resources/testconfiguration.properties |   99 +-
 .../hadoop/hive/cli/control/CliConfigs.java     |   17 +-
 .../java/org/apache/hadoop/hive/ql/Context.java |    9 +
 .../apache/hadoop/hive/ql/exec/ExplainTask.java |   16 +-
 .../apache/hadoop/hive/ql/hooks/ATSHook.java    |    3 +-
 .../hive/ql/hooks/HiveProtoLoggingHook.java     |    3 +-
 .../ql/optimizer/calcite/HiveRelOptUtil.java    |  238 ++
 .../calcite/rules/HiveJoinConstraintsRule.java  |  228 +-
 .../hadoop/hive/ql/parse/CalcitePlanner.java    |   10 +-
 .../hive/ql/parse/ExplainConfiguration.java     |   18 +
 .../hive/ql/parse/ExplainSemanticAnalyzer.java  |   12 +-
 .../org/apache/hadoop/hive/ql/parse/HiveLexer.g |    1 +
 .../apache/hadoop/hive/ql/parse/HiveParser.g    |    1 +
 .../hadoop/hive/ql/parse/IdentifiersParser.g    |    2 +-
 .../apache/hadoop/hive/ql/plan/ExplainWork.java |   17 +-
 .../parse/TestUpdateDeleteSemanticAnalyzer.java |    2 +-
 .../queries/clientpositive/perf/cbo_query1.q    |   27 +
 .../queries/clientpositive/perf/cbo_query10.q   |   61 +
 .../queries/clientpositive/perf/cbo_query11.q   |   77 +
 .../queries/clientpositive/perf/cbo_query12.q   |   35 +
 .../queries/clientpositive/perf/cbo_query13.q   |   54 +
 .../queries/clientpositive/perf/cbo_query14.q   |  104 +
 .../queries/clientpositive/perf/cbo_query15.q   |   22 +
 .../queries/clientpositive/perf/cbo_query16.q   |   33 +
 .../queries/clientpositive/perf/cbo_query17.q   |   47 +
 .../queries/clientpositive/perf/cbo_query18.q   |   36 +
 .../queries/clientpositive/perf/cbo_query19.q   |   27 +
 .../queries/clientpositive/perf/cbo_query2.q    |   62 +
 .../queries/clientpositive/perf/cbo_query20.q   |   31 +
 .../queries/clientpositive/perf/cbo_query21.q   |   32 +
 .../queries/clientpositive/perf/cbo_query22.q   |   24 +
 .../queries/clientpositive/perf/cbo_query23.q   |   52 +
 .../queries/clientpositive/perf/cbo_query24.q   |   51 +
 .../queries/clientpositive/perf/cbo_query25.q   |   50 +
 .../queries/clientpositive/perf/cbo_query26.q   |   23 +
 .../queries/clientpositive/perf/cbo_query27.q   |   25 +
 .../queries/clientpositive/perf/cbo_query28.q   |   59 +
 .../queries/clientpositive/perf/cbo_query29.q   |   49 +
 .../queries/clientpositive/perf/cbo_query3.q    |   23 +
 .../queries/clientpositive/perf/cbo_query30.q   |   33 +
 .../queries/clientpositive/perf/cbo_query31.q   |   54 +
 .../queries/clientpositive/perf/cbo_query32.q   |   30 +
 .../queries/clientpositive/perf/cbo_query33.q   |   77 +
 .../queries/clientpositive/perf/cbo_query34.q   |   33 +
 .../queries/clientpositive/perf/cbo_query35.q   |   59 +
 .../queries/clientpositive/perf/cbo_query36.q   |   32 +
 .../queries/clientpositive/perf/cbo_query37.q   |   19 +
 .../queries/clientpositive/perf/cbo_query38.q   |   25 +
 .../queries/clientpositive/perf/cbo_query39.q   |   56 +
 .../queries/clientpositive/perf/cbo_query4.q    |  111 +
 .../queries/clientpositive/perf/cbo_query40.q   |   30 +
 .../queries/clientpositive/perf/cbo_query42.q   |   24 +
 .../queries/clientpositive/perf/cbo_query43.q   |   21 +
 .../queries/clientpositive/perf/cbo_query44.q   |   37 +
 .../queries/clientpositive/perf/cbo_query45.q   |   22 +
 .../queries/clientpositive/perf/cbo_query46.q   |   37 +
 .../queries/clientpositive/perf/cbo_query47.q   |   53 +
 .../queries/clientpositive/perf/cbo_query48.q   |   69 +
 .../queries/clientpositive/perf/cbo_query49.q   |  129 ++
 .../queries/clientpositive/perf/cbo_query5.q    |  130 ++
 .../queries/clientpositive/perf/cbo_query50.q   |   61 +
 .../queries/clientpositive/perf/cbo_query51.q   |   47 +
 .../queries/clientpositive/perf/cbo_query52.q   |   24 +
 .../queries/clientpositive/perf/cbo_query53.q   |   30 +
 .../queries/clientpositive/perf/cbo_query54.q   |   58 +
 .../queries/clientpositive/perf/cbo_query55.q   |   16 +
 .../queries/clientpositive/perf/cbo_query56.q   |   70 +
 .../queries/clientpositive/perf/cbo_query57.q   |   50 +
 .../queries/clientpositive/perf/cbo_query58.q   |   67 +
 .../queries/clientpositive/perf/cbo_query59.q   |   46 +
 .../queries/clientpositive/perf/cbo_query6.q    |   30 +
 .../queries/clientpositive/perf/cbo_query60.q   |   80 +
 .../queries/clientpositive/perf/cbo_query61.q   |   46 +
 .../queries/clientpositive/perf/cbo_query63.q   |   31 +
 .../queries/clientpositive/perf/cbo_query64.q   |  121 +
 .../queries/clientpositive/perf/cbo_query65.q   |   31 +
 .../queries/clientpositive/perf/cbo_query66.q   |  224 ++
 .../queries/clientpositive/perf/cbo_query67.q   |   46 +
 .../queries/clientpositive/perf/cbo_query68.q   |   44 +
 .../queries/clientpositive/perf/cbo_query69.q   |   49 +
 .../queries/clientpositive/perf/cbo_query7.q    |   23 +
 .../queries/clientpositive/perf/cbo_query70.q   |   40 +
 .../queries/clientpositive/perf/cbo_query71.q   |   42 +
 .../queries/clientpositive/perf/cbo_query72.q   |   33 +
 .../queries/clientpositive/perf/cbo_query73.q   |   30 +
 .../queries/clientpositive/perf/cbo_query74.q   |   63 +
 .../queries/clientpositive/perf/cbo_query75.q   |   72 +
 .../queries/clientpositive/perf/cbo_query76.q   |   26 +
 .../queries/clientpositive/perf/cbo_query77.q   |  109 +
 .../queries/clientpositive/perf/cbo_query78.q   |   60 +
 .../queries/clientpositive/perf/cbo_query79.q   |   25 +
 .../queries/clientpositive/perf/cbo_query8.q    |  110 +
 .../queries/clientpositive/perf/cbo_query80.q   |   98 +
 .../queries/clientpositive/perf/cbo_query81.q   |   33 +
 .../queries/clientpositive/perf/cbo_query82.q   |   19 +
 .../queries/clientpositive/perf/cbo_query83.q   |   69 +
 .../queries/clientpositive/perf/cbo_query84.q   |   23 +
 .../queries/clientpositive/perf/cbo_query85.q   |   86 +
 .../queries/clientpositive/perf/cbo_query86.q   |   28 +
 .../queries/clientpositive/perf/cbo_query87.q   |   25 +
 .../queries/clientpositive/perf/cbo_query88.q   |   96 +
 .../queries/clientpositive/perf/cbo_query89.q   |   30 +
 .../queries/clientpositive/perf/cbo_query9.q    |   53 +
 .../queries/clientpositive/perf/cbo_query90.q   |   24 +
 .../queries/clientpositive/perf/cbo_query91.q   |   33 +
 .../queries/clientpositive/perf/cbo_query92.q   |   32 +
 .../queries/clientpositive/perf/cbo_query93.q   |   20 +
 .../queries/clientpositive/perf/cbo_query94.q   |   31 +
 .../queries/clientpositive/perf/cbo_query95.q   |   34 +
 .../queries/clientpositive/perf/cbo_query96.q   |   18 +
 .../queries/clientpositive/perf/cbo_query97.q   |   27 +
 .../queries/clientpositive/perf/cbo_query98.q   |   34 +
 .../queries/clientpositive/perf/cbo_query99.q   |   37 +
 .../clientpositive/perf/tez/cbo_query1.q.out    |   91 +
 .../clientpositive/perf/tez/cbo_query10.q.out   |  178 ++
 .../clientpositive/perf/tez/cbo_query11.q.out   |  223 ++
 .../clientpositive/perf/tez/cbo_query12.q.out   |   89 +
 .../clientpositive/perf/tez/cbo_query13.q.out   |  141 ++
 .../clientpositive/perf/tez/cbo_query14.q.out   |  618 ++++++
 .../clientpositive/perf/tez/cbo_query15.q.out   |   69 +
 .../clientpositive/perf/tez/cbo_query16.q.out   |  104 +
 .../clientpositive/perf/tez/cbo_query17.q.out   |  141 ++
 .../clientpositive/perf/tez/cbo_query18.q.out   |  114 +
 .../clientpositive/perf/tez/cbo_query19.q.out   |   92 +
 .../clientpositive/perf/tez/cbo_query2.q.out    |  170 ++
 .../clientpositive/perf/tez/cbo_query20.q.out   |   81 +
 .../clientpositive/perf/tez/cbo_query21.q.out   |   90 +
 .../clientpositive/perf/tez/cbo_query22.q.out   |   72 +
 .../clientpositive/perf/tez/cbo_query23.q.out   |  281 +++
 .../clientpositive/perf/tez/cbo_query24.q.out   |  171 ++
 .../clientpositive/perf/tez/cbo_query25.q.out   |  146 ++
 .../clientpositive/perf/tez/cbo_query26.q.out   |   76 +
 .../clientpositive/perf/tez/cbo_query27.q.out   |   81 +
 .../clientpositive/perf/tez/cbo_query28.q.out   |  146 ++
 .../clientpositive/perf/tez/cbo_query29.q.out   |  144 ++
 .../clientpositive/perf/tez/cbo_query3.q.out    |   64 +
 .../clientpositive/perf/tez/cbo_query30.q.out   |  112 +
 .../clientpositive/perf/tez/cbo_query31.q.out   |  199 ++
 .../clientpositive/perf/tez/cbo_query32.q.out   |   89 +
 .../clientpositive/perf/tez/cbo_query33.q.out   |  238 ++
 .../clientpositive/perf/tez/cbo_query34.q.out   |   99 +
 .../clientpositive/perf/tez/cbo_query35.q.out   |  175 ++
 .../clientpositive/perf/tez/cbo_query36.q.out   |   91 +
 .../clientpositive/perf/tez/cbo_query37.q.out   |   63 +
 .../clientpositive/perf/tez/cbo_query38.q.out   |  111 +
 .../clientpositive/perf/tez/cbo_query39.q.out   |  168 ++
 .../clientpositive/perf/tez/cbo_query4.q.out    |  324 +++
 .../clientpositive/perf/tez/cbo_query40.q.out   |   91 +
 .../clientpositive/perf/tez/cbo_query42.q.out   |   68 +
 .../clientpositive/perf/tez/cbo_query43.q.out   |   61 +
 .../clientpositive/perf/tez/cbo_query44.q.out   |  115 +
 .../clientpositive/perf/tez/cbo_query45.q.out   |   89 +
 .../clientpositive/perf/tez/cbo_query46.q.out   |  115 +
 .../clientpositive/perf/tez/cbo_query47.q.out   |  177 ++
 .../clientpositive/perf/tez/cbo_query48.q.out   |  164 ++
 .../clientpositive/perf/tez/cbo_query49.q.out   |  330 +++
 .../clientpositive/perf/tez/cbo_query5.q.out    |  342 +++
 .../clientpositive/perf/tez/cbo_query50.q.out   |  151 ++
 .../clientpositive/perf/tez/cbo_query51.q.out   |  125 ++
 .../clientpositive/perf/tez/cbo_query52.q.out   |   67 +
 .../clientpositive/perf/tez/cbo_query53.q.out   |   87 +
 .../clientpositive/perf/tez/cbo_query54.q.out   |  213 ++
 .../clientpositive/perf/tez/cbo_query55.q.out   |   51 +
 .../clientpositive/perf/tez/cbo_query56.q.out   |  224 ++
 .../clientpositive/perf/tez/cbo_query57.q.out   |  171 ++
 .../clientpositive/perf/tez/cbo_query58.q.out   |  240 ++
 .../clientpositive/perf/tez/cbo_query59.q.out   |  136 ++
 .../clientpositive/perf/tez/cbo_query6.q.out    |  109 +
 .../clientpositive/perf/tez/cbo_query60.q.out   |  244 +++
 .../clientpositive/perf/tez/cbo_query61.q.out   |  164 ++
 .../clientpositive/perf/tez/cbo_query63.q.out   |   89 +
 .../clientpositive/perf/tez/cbo_query64.q.out   |  438 ++++
 .../clientpositive/perf/tez/cbo_query65.q.out   |   99 +
 .../clientpositive/perf/tez/cbo_query66.q.out   |  508 +++++
 .../clientpositive/perf/tez/cbo_query67.q.out   |  120 +
 .../clientpositive/perf/tez/cbo_query68.q.out   |  129 ++
 .../clientpositive/perf/tez/cbo_query69.q.out   |  156 ++
 .../clientpositive/perf/tez/cbo_query7.q.out    |   76 +
 .../clientpositive/perf/tez/cbo_query70.q.out   |  119 +
 .../clientpositive/perf/tez/cbo_query71.q.out   |  130 ++
 .../clientpositive/perf/tez/cbo_query72.q.out   |  130 ++
 .../clientpositive/perf/tez/cbo_query73.q.out   |   93 +
 .../clientpositive/perf/tez/cbo_query74.q.out   |  191 ++
 .../clientpositive/perf/tez/cbo_query75.q.out   |  278 +++
 .../clientpositive/perf/tez/cbo_query76.q.out   |  101 +
 .../clientpositive/perf/tez/cbo_query77.q.out   |  316 +++
 .../clientpositive/perf/tez/cbo_query78.q.out   |  183 ++
 .../clientpositive/perf/tez/cbo_query79.q.out   |   82 +
 .../clientpositive/perf/tez/cbo_query8.q.out    |  266 +++
 .../clientpositive/perf/tez/cbo_query80.q.out   |  301 +++
 .../clientpositive/perf/tez/cbo_query81.q.out   |  113 +
 .../clientpositive/perf/tez/cbo_query82.q.out   |   63 +
 .../clientpositive/perf/tez/cbo_query83.q.out   |  222 ++
 .../clientpositive/perf/tez/cbo_query84.q.out   |   84 +
 .../clientpositive/perf/tez/cbo_query85.q.out   |  219 ++
 .../clientpositive/perf/tez/cbo_query86.q.out   |   77 +
 .../clientpositive/perf/tez/cbo_query87.q.out   |  114 +
 .../clientpositive/perf/tez/cbo_query88.q.out   |  347 +++
 .../clientpositive/perf/tez/cbo_query89.q.out   |   88 +
 .../clientpositive/perf/tez/cbo_query9.q.out    |  200 ++
 .../clientpositive/perf/tez/cbo_query90.q.out   |   92 +
 .../clientpositive/perf/tez/cbo_query91.q.out   |  110 +
 .../clientpositive/perf/tez/cbo_query92.q.out   |   94 +
 .../clientpositive/perf/tez/cbo_query93.q.out   |   59 +
 .../clientpositive/perf/tez/cbo_query94.q.out   |  100 +
 .../clientpositive/perf/tez/cbo_query95.q.out   |  120 +
 .../clientpositive/perf/tez/cbo_query96.q.out   |   61 +
 .../clientpositive/perf/tez/cbo_query97.q.out   |   81 +
 .../clientpositive/perf/tez/cbo_query98.q.out   |   87 +
 .../clientpositive/perf/tez/cbo_query99.q.out   |  106 +
 .../perf/tez/constraints/cbo_query1.q.out       |   90 +
 .../perf/tez/constraints/cbo_query10.q.out      |  177 ++
 .../perf/tez/constraints/cbo_query11.q.out      |  215 ++
 .../perf/tez/constraints/cbo_query12.q.out      |   89 +
 .../perf/tez/constraints/cbo_query13.q.out      |  137 ++
 .../perf/tez/constraints/cbo_query14.q.out      |  612 ++++++
 .../perf/tez/constraints/cbo_query15.q.out      |   68 +
 .../perf/tez/constraints/cbo_query16.q.out      |  102 +
 .../perf/tez/constraints/cbo_query17.q.out      |  139 ++
 .../perf/tez/constraints/cbo_query18.q.out      |  111 +
 .../perf/tez/constraints/cbo_query19.q.out      |   90 +
 .../perf/tez/constraints/cbo_query2.q.out       |  170 ++
 .../perf/tez/constraints/cbo_query20.q.out      |   81 +
 .../perf/tez/constraints/cbo_query21.q.out      |   88 +
 .../perf/tez/constraints/cbo_query22.q.out      |   66 +
 .../perf/tez/constraints/cbo_query23.q.out      |  245 +++
 .../perf/tez/constraints/cbo_query24.q.out      |  168 ++
 .../perf/tez/constraints/cbo_query25.q.out      |  144 ++
 .../perf/tez/constraints/cbo_query26.q.out      |   75 +
 .../perf/tez/constraints/cbo_query27.q.out      |   80 +
 .../perf/tez/constraints/cbo_query28.q.out      |  146 ++
 .../perf/tez/constraints/cbo_query29.q.out      |  142 ++
 .../perf/tez/constraints/cbo_query3.q.out       |   64 +
 .../perf/tez/constraints/cbo_query30.q.out      |  112 +
 .../perf/tez/constraints/cbo_query31.q.out      |  199 ++
 .../perf/tez/constraints/cbo_query32.q.out      |   89 +
 .../perf/tez/constraints/cbo_query33.q.out      |  238 ++
 .../perf/tez/constraints/cbo_query34.q.out      |   98 +
 .../perf/tez/constraints/cbo_query35.q.out      |  173 ++
 .../perf/tez/constraints/cbo_query36.q.out      |   90 +
 .../perf/tez/constraints/cbo_query37.q.out      |   62 +
 .../perf/tez/constraints/cbo_query38.q.out      |  108 +
 .../perf/tez/constraints/cbo_query39.q.out      |  156 ++
 .../perf/tez/constraints/cbo_query4.q.out       |  312 +++
 .../perf/tez/constraints/cbo_query40.q.out      |   89 +
 .../perf/tez/constraints/cbo_query42.q.out      |   68 +
 .../perf/tez/constraints/cbo_query43.q.out      |   61 +
 .../perf/tez/constraints/cbo_query44.q.out      |  113 +
 .../perf/tez/constraints/cbo_query45.q.out      |   81 +
 .../perf/tez/constraints/cbo_query46.q.out      |  113 +
 .../perf/tez/constraints/cbo_query47.q.out      |  177 ++
 .../perf/tez/constraints/cbo_query48.q.out      |  160 ++
 .../perf/tez/constraints/cbo_query49.q.out      |  330 +++
 .../perf/tez/constraints/cbo_query5.q.out       |  339 +++
 .../perf/tez/constraints/cbo_query50.q.out      |  146 ++
 .../perf/tez/constraints/cbo_query51.q.out      |  125 ++
 .../perf/tez/constraints/cbo_query52.q.out      |   67 +
 .../perf/tez/constraints/cbo_query53.q.out      |   83 +
 .../perf/tez/constraints/cbo_query54.q.out      |  212 ++
 .../perf/tez/constraints/cbo_query55.q.out      |   51 +
 .../perf/tez/constraints/cbo_query56.q.out      |  221 ++
 .../perf/tez/constraints/cbo_query57.q.out      |  171 ++
 .../perf/tez/constraints/cbo_query58.q.out      |  237 ++
 .../perf/tez/constraints/cbo_query59.q.out      |  134 ++
 .../perf/tez/constraints/cbo_query6.q.out       |  108 +
 .../perf/tez/constraints/cbo_query60.q.out      |  241 ++
 .../perf/tez/constraints/cbo_query61.q.out      |  164 ++
 .../perf/tez/constraints/cbo_query63.q.out      |   85 +
 .../perf/tez/constraints/cbo_query64.q.out      |  390 ++++
 .../perf/tez/constraints/cbo_query65.q.out      |   97 +
 .../perf/tez/constraints/cbo_query66.q.out      |  506 +++++
 .../perf/tez/constraints/cbo_query67.q.out      |  118 +
 .../perf/tez/constraints/cbo_query68.q.out      |  127 ++
 .../perf/tez/constraints/cbo_query69.q.out      |  155 ++
 .../perf/tez/constraints/cbo_query7.q.out       |   75 +
 .../perf/tez/constraints/cbo_query70.q.out      |  119 +
 .../perf/tez/constraints/cbo_query71.q.out      |  130 ++
 .../perf/tez/constraints/cbo_query72.q.out      |  125 ++
 .../perf/tez/constraints/cbo_query73.q.out      |   92 +
 .../perf/tez/constraints/cbo_query74.q.out      |  187 ++
 .../perf/tez/constraints/cbo_query75.q.out      |  272 +++
 .../perf/tez/constraints/cbo_query76.q.out      |   95 +
 .../perf/tez/constraints/cbo_query77.q.out      |  304 +++
 .../perf/tez/constraints/cbo_query78.q.out      |  183 ++
 .../perf/tez/constraints/cbo_query79.q.out      |   81 +
 .../perf/tez/constraints/cbo_query8.q.out       |  266 +++
 .../perf/tez/constraints/cbo_query80.q.out      |  295 +++
 .../perf/tez/constraints/cbo_query81.q.out      |  113 +
 .../perf/tez/constraints/cbo_query82.q.out      |   62 +
 .../perf/tez/constraints/cbo_query83.q.out      |  219 ++
 .../perf/tez/constraints/cbo_query84.q.out      |   83 +
 .../perf/tez/constraints/cbo_query85.q.out      |  214 ++
 .../perf/tez/constraints/cbo_query86.q.out      |   76 +
 .../perf/tez/constraints/cbo_query87.q.out      |  111 +
 .../perf/tez/constraints/cbo_query88.q.out      |  347 +++
 .../perf/tez/constraints/cbo_query89.q.out      |   87 +
 .../perf/tez/constraints/cbo_query9.q.out       |  200 ++
 .../perf/tez/constraints/cbo_query90.q.out      |   92 +
 .../perf/tez/constraints/cbo_query91.q.out      |  109 +
 .../perf/tez/constraints/cbo_query92.q.out      |   94 +
 .../perf/tez/constraints/cbo_query93.q.out      |   58 +
 .../perf/tez/constraints/cbo_query94.q.out      |   98 +
 .../perf/tez/constraints/cbo_query95.q.out      |  112 +
 .../perf/tez/constraints/cbo_query96.q.out      |   61 +
 .../perf/tez/constraints/cbo_query97.q.out      |   81 +
 .../perf/tez/constraints/cbo_query98.q.out      |   87 +
 .../perf/tez/constraints/cbo_query99.q.out      |  102 +
 .../perf/tez/constraints/query1.q.out           |  177 ++
 .../perf/tez/constraints/query10.q.out          |  379 ++++
 .../perf/tez/constraints/query11.q.out          |  427 ++++
 .../perf/tez/constraints/query12.q.out          |  169 ++
 .../perf/tez/constraints/query13.q.out          |  255 +++
 .../perf/tez/constraints/query14.q.out          | 1400 ++++++++++++
 .../perf/tez/constraints/query15.q.out          |  142 ++
 .../perf/tez/constraints/query16.q.out          |  244 +++
 .../perf/tez/constraints/query17.q.out          |  319 +++
 .../perf/tez/constraints/query18.q.out          |  239 ++
 .../perf/tez/constraints/query19.q.out          |  196 ++
 .../perf/tez/constraints/query2.q.out           |  228 ++
 .../perf/tez/constraints/query20.q.out          |  161 ++
 .../perf/tez/constraints/query21.q.out          |  145 ++
 .../perf/tez/constraints/query22.q.out          |  112 +
 .../perf/tez/constraints/query23.q.out          |  540 +++++
 .../perf/tez/constraints/query24.q.out          |  343 +++
 .../perf/tez/constraints/query25.q.out          |  321 +++
 .../perf/tez/constraints/query26.q.out          |  171 ++
 .../perf/tez/constraints/query27.q.out          |  189 ++
 .../perf/tez/constraints/query28.q.out          |  296 +++
 .../perf/tez/constraints/query29.q.out          |  328 +++
 .../perf/tez/constraints/query3.q.out           |  135 ++
 .../perf/tez/constraints/query30.q.out          |  221 ++
 .../perf/tez/constraints/query31.q.out          |  492 +++++
 .../perf/tez/constraints/query32.q.out          |  210 ++
 .../perf/tez/constraints/query33.q.out          |  450 ++++
 .../perf/tez/constraints/query34.q.out          |  203 ++
 .../perf/tez/constraints/query35.q.out          |  361 +++
 .../perf/tez/constraints/query36.q.out          |  182 ++
 .../perf/tez/constraints/query37.q.out          |  146 ++
 .../perf/tez/constraints/query38.q.out          |  261 +++
 .../perf/tez/constraints/query39.q.out          |  236 ++
 .../perf/tez/constraints/query4.q.out           |  623 ++++++
 .../perf/tez/constraints/query40.q.out          |  183 ++
 .../perf/tez/constraints/query42.q.out          |  139 ++
 .../perf/tez/constraints/query43.q.out          |  135 ++
 .../perf/tez/constraints/query44.q.out          |  193 ++
 .../perf/tez/constraints/query45.q.out          |  183 ++
 .../perf/tez/constraints/query46.q.out          |  240 ++
 .../perf/tez/constraints/query47.q.out          |  266 +++
 .../perf/tez/constraints/query48.q.out          |  252 +++
 .../perf/tez/constraints/query49.q.out          |  555 +++++
 .../perf/tez/constraints/query5.q.out           |  531 +++++
 .../perf/tez/constraints/query50.q.out          |  242 ++
 .../perf/tez/constraints/query51.q.out          |  222 ++
 .../perf/tez/constraints/query52.q.out          |  139 ++
 .../perf/tez/constraints/query53.q.out          |  161 ++
 .../perf/tez/constraints/query54.q.out          |  439 ++++
 .../perf/tez/constraints/query55.q.out          |  123 ++
 .../perf/tez/constraints/query56.q.out          |  470 ++++
 .../perf/tez/constraints/query57.q.out          |  260 +++
 .../perf/tez/constraints/query58.q.out          |  397 ++++
 .../perf/tez/constraints/query59.q.out          |  234 ++
 .../perf/tez/constraints/query6.q.out           |  236 ++
 .../perf/tez/constraints/query60.q.out          |  496 +++++
 .../perf/tez/constraints/query61.q.out          |  388 ++++
 .../perf/tez/constraints/query63.q.out          |  163 ++
 .../perf/tez/constraints/query64.q.out          |  758 +++++++
 .../perf/tez/constraints/query65.q.out          |  220 ++
 .../perf/tez/constraints/query66.q.out          |  702 ++++++
 .../perf/tez/constraints/query67.q.out          |  196 ++
 .../perf/tez/constraints/query68.q.out          |  254 +++
 .../perf/tez/constraints/query69.q.out          |  359 +++
 .../perf/tez/constraints/query7.q.out           |  171 ++
 .../perf/tez/constraints/query70.q.out          |  216 ++
 .../perf/tez/constraints/query71.q.out          |  297 +++
 .../perf/tez/constraints/query72.q.out          |  297 +++
 .../perf/tez/constraints/query73.q.out          |  197 ++
 .../perf/tez/constraints/query74.q.out          |  397 ++++
 .../perf/tez/constraints/query75.q.out          |  662 ++++++
 .../perf/tez/constraints/query76.q.out          |  197 ++
 .../perf/tez/constraints/query77.q.out          |  504 +++++
 .../perf/tez/constraints/query78.q.out          |  345 +++
 .../perf/tez/constraints/query79.q.out          |  175 ++
 .../perf/tez/constraints/query8.q.out           |  397 ++++
 .../perf/tez/constraints/query80.q.out          |  609 ++++++
 .../perf/tez/constraints/query81.q.out          |  220 ++
 .../perf/tez/constraints/query82.q.out          |  146 ++
 .../perf/tez/constraints/query83.q.out          |  338 +++
 .../perf/tez/constraints/query84.q.out          |  153 ++
 .../perf/tez/constraints/query85.q.out          |  320 +++
 .../perf/tez/constraints/query86.q.out          |  145 ++
 .../perf/tez/constraints/query87.q.out          |  288 +++
 .../perf/tez/constraints/query88.q.out          |  946 ++++++++
 .../perf/tez/constraints/query89.q.out          |  178 ++
 .../perf/tez/constraints/query9.q.out           |  450 ++++
 .../perf/tez/constraints/query90.q.out          |  263 +++
 .../perf/tez/constraints/query91.q.out          |  196 ++
 .../perf/tez/constraints/query92.q.out          |  221 ++
 .../perf/tez/constraints/query93.q.out          |  131 ++
 .../perf/tez/constraints/query94.q.out          |  240 ++
 .../perf/tez/constraints/query95.q.out          |  271 +++
 .../perf/tez/constraints/query96.q.out          |  155 ++
 .../perf/tez/constraints/query97.q.out          |  166 ++
 .../perf/tez/constraints/query98.q.out          |  165 ++
 .../perf/tez/constraints/query99.q.out          |  195 ++
 .../clientpositive/perf/tez/query1.q.out        |   70 +-
 .../clientpositive/perf/tez/query10.q.out       |  390 ++--
 .../clientpositive/perf/tez/query11.q.out       |  502 +++--
 .../clientpositive/perf/tez/query12.q.out       |   46 +-
 .../clientpositive/perf/tez/query13.q.out       |  182 +-
 .../clientpositive/perf/tez/query14.q.out       | 2062 +++++++++---------
 .../clientpositive/perf/tez/query15.q.out       |   54 +-
 .../clientpositive/perf/tez/query16.q.out       |  175 +-
 .../clientpositive/perf/tez/query17.q.out       |  263 ++-
 .../clientpositive/perf/tez/query18.q.out       |  208 +-
 .../clientpositive/perf/tez/query19.q.out       |  182 +-
 .../clientpositive/perf/tez/query2.q.out        |  201 +-
 .../clientpositive/perf/tez/query20.q.out       |   46 +-
 .../clientpositive/perf/tez/query21.q.out       |   44 +-
 .../clientpositive/perf/tez/query22.q.out       |   42 +-
 .../clientpositive/perf/tez/query23.q.out       |  735 +++----
 .../clientpositive/perf/tez/query24.q.out       |  332 ++-
 .../clientpositive/perf/tez/query25.q.out       |  251 ++-
 .../clientpositive/perf/tez/query26.q.out       |  112 +-
 .../clientpositive/perf/tez/query27.q.out       |   96 +-
 .../clientpositive/perf/tez/query28.q.out       |  296 +--
 .../clientpositive/perf/tez/query29.q.out       |  276 +--
 .../clientpositive/perf/tez/query3.q.out        |   40 +-
 .../clientpositive/perf/tez/query30.q.out       |   84 +-
 .../clientpositive/perf/tez/query31.q.out       |  702 +++---
 .../clientpositive/perf/tez/query32.q.out       |  159 +-
 .../clientpositive/perf/tez/query33.q.out       |  400 ++--
 .../clientpositive/perf/tez/query34.q.out       |  178 +-
 .../clientpositive/perf/tez/query35.q.out       |  376 ++--
 .../clientpositive/perf/tez/query36.q.out       |   90 +-
 .../clientpositive/perf/tez/query37.q.out       |  156 +-
 .../clientpositive/perf/tez/query38.q.out       |  190 +-
 .../clientpositive/perf/tez/query39.q.out       |   70 +-
 .../clientpositive/perf/tez/query4.q.out        |  762 ++++---
 .../clientpositive/perf/tez/query40.q.out       |   94 +-
 .../clientpositive/perf/tez/query42.q.out       |   42 +-
 .../clientpositive/perf/tez/query43.q.out       |   44 +-
 .../clientpositive/perf/tez/query44.q.out       |   68 +-
 .../clientpositive/perf/tez/query45.q.out       |  174 +-
 .../clientpositive/perf/tez/query46.q.out       |  212 +-
 .../clientpositive/perf/tez/query47.q.out       |  276 ++-
 .../clientpositive/perf/tez/query48.q.out       |  148 +-
 .../clientpositive/perf/tez/query49.q.out       |  158 +-
 .../clientpositive/perf/tez/query5.q.out        |  302 +--
 .../clientpositive/perf/tez/query50.q.out       |  126 +-
 .../clientpositive/perf/tez/query51.q.out       |   62 +-
 .../clientpositive/perf/tez/query52.q.out       |   42 +-
 .../clientpositive/perf/tez/query53.q.out       |   86 +-
 .../clientpositive/perf/tez/query54.q.out       |  356 ++-
 .../clientpositive/perf/tez/query55.q.out       |   42 +-
 .../clientpositive/perf/tez/query56.q.out       |  140 +-
 .../clientpositive/perf/tez/query57.q.out       |  276 ++-
 .../clientpositive/perf/tez/query58.q.out       |  430 ++--
 .../clientpositive/perf/tez/query59.q.out       |  209 +-
 .../clientpositive/perf/tez/query6.q.out        |  288 ++-
 .../clientpositive/perf/tez/query60.q.out       |  146 +-
 .../clientpositive/perf/tez/query61.q.out       |  180 +-
 .../clientpositive/perf/tez/query63.q.out       |   86 +-
 .../clientpositive/perf/tez/query64.q.out       |  961 ++++----
 .../clientpositive/perf/tez/query65.q.out       |  291 ++-
 .../clientpositive/perf/tez/query66.q.out       |  182 +-
 .../clientpositive/perf/tez/query67.q.out       |  110 +-
 .../clientpositive/perf/tez/query68.q.out       |  212 +-
 .../clientpositive/perf/tez/query69.q.out       |  396 ++--
 .../clientpositive/perf/tez/query7.q.out        |  112 +-
 .../clientpositive/perf/tez/query70.q.out       |  210 +-
 .../clientpositive/perf/tez/query71.q.out       |   98 +-
 .../clientpositive/perf/tez/query72.q.out       |  290 ++-
 .../clientpositive/perf/tez/query73.q.out       |  178 +-
 .../clientpositive/perf/tez/query74.q.out       |  488 ++---
 .../clientpositive/perf/tez/query75.q.out       |  212 +-
 .../clientpositive/perf/tez/query76.q.out       |  237 +-
 .../clientpositive/perf/tez/query77.q.out       |  286 ++-
 .../clientpositive/perf/tez/query78.q.out       |  112 +-
 .../clientpositive/perf/tez/query79.q.out       |  164 +-
 .../clientpositive/perf/tez/query8.q.out        |   96 +-
 .../clientpositive/perf/tez/query80.q.out       |  328 ++-
 .../clientpositive/perf/tez/query81.q.out       |   86 +-
 .../clientpositive/perf/tez/query82.q.out       |  156 +-
 .../clientpositive/perf/tez/query83.q.out       |  286 +--
 .../clientpositive/perf/tez/query84.q.out       |  140 +-
 .../clientpositive/perf/tez/query85.q.out       |  158 +-
 .../clientpositive/perf/tez/query86.q.out       |   78 +-
 .../clientpositive/perf/tez/query87.q.out       |  216 +-
 .../clientpositive/perf/tez/query88.q.out       | 1384 ++++++------
 .../clientpositive/perf/tez/query89.q.out       |   90 +-
 .../clientpositive/perf/tez/query9.q.out        |  132 +-
 .../clientpositive/perf/tez/query90.q.out       |   76 +-
 .../clientpositive/perf/tez/query91.q.out       |   76 +-
 .../clientpositive/perf/tez/query92.q.out       |  165 +-
 .../clientpositive/perf/tez/query93.q.out       |   50 +-
 .../clientpositive/perf/tez/query94.q.out       |  175 +-
 .../clientpositive/perf/tez/query95.q.out       |  412 ++--
 .../clientpositive/perf/tez/query96.q.out       |   50 +-
 .../clientpositive/perf/tez/query97.q.out       |   44 +-
 .../clientpositive/perf/tez/query98.q.out       |   44 +-
 .../clientpositive/perf/tez/query99.q.out       |  126 +-
 507 files changed, 75315 insertions(+), 12182 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/data/conf/perf-reg/spark/hive-site.xml
----------------------------------------------------------------------
diff --git a/data/conf/perf-reg/spark/hive-site.xml b/data/conf/perf-reg/spark/hive-site.xml
index e52a2f9..9a17197 100644
--- a/data/conf/perf-reg/spark/hive-site.xml
+++ b/data/conf/perf-reg/spark/hive-site.xml
@@ -144,11 +144,16 @@
 
 <property>
   <name>hive.support.concurrency</name>
-  <value>false</value>
+  <value>true</value>
   <description>Whether hive supports concurrency or not. A zookeeper instance must be up and running for the default hive lock manager to support read-write locks.</description>
 </property>
 
 <property>
+  <name>hive.txn.manager</name>
+  <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
+</property>
+
+<property>
   <name>fs.pfile.impl</name>
   <value>org.apache.hadoop.fs.ProxyLocalFileSystem</value>
   <description>A proxy for local file system used for cross file system testing</description>

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/data/conf/perf-reg/tez/hive-site.xml
----------------------------------------------------------------------
diff --git a/data/conf/perf-reg/tez/hive-site.xml b/data/conf/perf-reg/tez/hive-site.xml
index 78a5481..7d38be0 100644
--- a/data/conf/perf-reg/tez/hive-site.xml
+++ b/data/conf/perf-reg/tez/hive-site.xml
@@ -168,11 +168,16 @@
 
 <property>
   <name>hive.support.concurrency</name>
-  <value>false</value>
+  <value>true</value>
   <description>Whether hive supports concurrency or not. A zookeeper instance must be up and running for the default hive lock manager to support read-write locks.</description>
 </property>
 
 <property>
+  <name>hive.txn.manager</name>
+  <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
+</property>
+
+<property>
   <name>fs.pfile.impl</name>
   <value>org.apache.hadoop.fs.ProxyLocalFileSystem</value>
   <description>A proxy for local file system used for cross file system testing</description>
@@ -292,4 +297,14 @@
   <value>99</value>
 </property>
 
+<property>
+  <name>hive.merge.nway.joins</name>
+  <value>false</value>
+</property>
+
+<property>
+  <name>hive.stats.fetch.column.stats</name>
+  <value>true</value>
+</property>
+
 </configuration>

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/data/scripts/q_perf_test_init.sql
----------------------------------------------------------------------
diff --git a/data/scripts/q_perf_test_init.sql b/data/scripts/q_perf_test_init.sql
index d27215b..020e2d0 100644
--- a/data/scripts/q_perf_test_init.sql
+++ b/data/scripts/q_perf_test_init.sql
@@ -1,5 +1,5 @@
 drop table if exists call_center;
-create external table call_center
+create table call_center
 (
     cc_call_center_sk        int,
     cc_call_center_id        string,
@@ -34,10 +34,10 @@ create external table call_center
     cc_tax_percentage        decimal(5,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 drop table if exists catalog_page;
-create external table catalog_page
+create table catalog_page
 (
     cp_catalog_page_sk       int,
     cp_catalog_page_id       string,
@@ -50,11 +50,11 @@ create external table catalog_page
     cp_type                  string
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists catalog_returns;
-create external table catalog_returns
+create table catalog_returns
 (
     cr_returned_date_sk        int,
     cr_returned_time_sk        int,
@@ -85,11 +85,11 @@ create external table catalog_returns
     cr_net_loss                decimal(7,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists catalog_sales;
-create external table catalog_sales
+create table catalog_sales
 (
     cs_sold_date_sk            int,
     cs_sold_time_sk            int,
@@ -127,11 +127,11 @@ create external table catalog_sales
     cs_net_profit              decimal(7,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists customer;
-create external table customer
+create table customer
 (
     c_customer_sk             int,
     c_customer_id             string,
@@ -153,11 +153,11 @@ create external table customer
     c_last_review_date        string
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists customer_address;
-create external table customer_address
+create table customer_address
 (
     ca_address_sk             int,
     ca_address_id             string,
@@ -174,11 +174,11 @@ create external table customer_address
     ca_location_type          string
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists customer_demographics;
-create external table customer_demographics
+create table customer_demographics
 (
     cd_demo_sk                int,
     cd_gender                 string,
@@ -191,11 +191,11 @@ create external table customer_demographics
     cd_dep_college_count      int 
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists date_dim;
-create external table date_dim
+create table date_dim
 (
     d_date_sk                 int,
     d_date_id                 string,
@@ -227,11 +227,11 @@ create external table date_dim
     d_current_year            string 
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists household_demographics;
-create external table household_demographics
+create table household_demographics
 (
     hd_demo_sk                int,
     hd_income_band_sk         int,
@@ -240,22 +240,22 @@ create external table household_demographics
     hd_vehicle_count          int
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists income_band;
-create external table income_band
+create table income_band
 (
     ib_income_band_sk        int,
     ib_lower_bound           int,
     ib_upper_bound           int
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists inventory;
-create external table inventory
+create table inventory
 (
     inv_date_sk                int,
     inv_item_sk                int,
@@ -263,11 +263,11 @@ create external table inventory
     inv_quantity_on_hand       int
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists item;
-create external table item
+create table item
 (
     i_item_sk                 int,
     i_item_id                 string,
@@ -293,11 +293,11 @@ create external table item
     i_product_name            string
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists promotion;
-create external table promotion
+create table promotion
 (
     p_promo_sk                int,
     p_promo_id                string,
@@ -320,22 +320,22 @@ create external table promotion
     p_discount_active         string 
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists reason;
-create external table reason
+create table reason
 (
     r_reason_sk         int,
     r_reason_id         string,
     r_reason_desc       string
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists ship_mode;
-create external table ship_mode
+create table ship_mode
 (
     sm_ship_mode_sk           int,
     sm_ship_mode_id           string,
@@ -345,11 +345,11 @@ create external table ship_mode
     sm_contract               string
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists store;
-create external table store
+create table store
 (
     s_store_sk                int,
     s_store_id                string,
@@ -382,11 +382,11 @@ create external table store
     s_tax_precentage          decimal(5,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists store_returns;
-create external table store_returns
+create table store_returns
 (
     sr_returned_date_sk      int,
     sr_return_time_sk        int,
@@ -410,11 +410,11 @@ create external table store_returns
     sr_net_loss              decimal(7,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists store_sales;
-create external table store_sales
+create table store_sales
 (
     ss_sold_date_sk           int,
     ss_sold_time_sk           int,
@@ -441,11 +441,11 @@ create external table store_sales
     ss_net_profit             decimal(7,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists time_dim;
-create external table time_dim
+create table time_dim
 (
     t_time_sk                 int,
     t_time_id                 string,
@@ -459,11 +459,11 @@ create external table time_dim
     t_meal_time               string
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists warehouse;
-create external table warehouse
+create table warehouse
 (
     w_warehouse_sk            int,
     w_warehouse_id            string,
@@ -481,11 +481,11 @@ create external table warehouse
     w_gmt_offset              decimal(5,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists web_page;
-create external table web_page
+create table web_page
 (
     wp_web_page_sk           int,
     wp_web_page_id           string,
@@ -503,11 +503,11 @@ create external table web_page
     wp_max_ad_count          int
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists web_returns;
-create external table web_returns
+create table web_returns
 (
     wr_returned_date_sk        int,
     wr_returned_time_sk        int,
@@ -535,11 +535,11 @@ create external table web_returns
     wr_net_loss                decimal(7,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists web_sales;
-create external table web_sales
+create table web_sales
 (
     ws_sold_date_sk           int,
     ws_sold_time_sk           int,
@@ -577,11 +577,11 @@ create external table web_sales
     ws_net_profit             decimal(7,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 
 drop table if exists web_site;
-create external table web_site
+create table web_site
 (
     web_site_sk             int,
     web_site_id             string,
@@ -611,6 +611,6 @@ create external table web_site
     web_tax_percentage      decimal(5,2)
 )
 row format delimited fields terminated by '\t'
-STORED AS ORC tblproperties ("orc.compress"="ZLIB");
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
 
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/data/scripts/q_perf_test_init_constraints.sql
----------------------------------------------------------------------
diff --git a/data/scripts/q_perf_test_init_constraints.sql b/data/scripts/q_perf_test_init_constraints.sql
new file mode 100644
index 0000000..3b3f503
--- /dev/null
+++ b/data/scripts/q_perf_test_init_constraints.sql
@@ -0,0 +1,771 @@
+drop table if exists call_center;
+create table call_center
+(
+    cc_call_center_sk        int,
+    cc_call_center_id        string,
+    cc_rec_start_date        string,
+    cc_rec_end_date          string,
+    cc_closed_date_sk        int,
+    cc_open_date_sk          int,
+    cc_name                  string,
+    cc_class                 string,
+    cc_employees             int,
+    cc_sq_ft                 int,
+    cc_hours                 string,
+    cc_manager               string,
+    cc_mkt_id                int,
+    cc_mkt_class             string,
+    cc_mkt_desc              string,
+    cc_market_manager        string,
+    cc_division              int,
+    cc_division_name         string,
+    cc_company               int,
+    cc_company_name          string,
+    cc_street_number         string,
+    cc_street_name           string,
+    cc_street_type           string,
+    cc_suite_number          string,
+    cc_city                  string,
+    cc_county                string,
+    cc_state                 string,
+    cc_zip                   string,
+    cc_country               string,
+    cc_gmt_offset            decimal(5,2),
+    cc_tax_percentage        decimal(5,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+drop table if exists catalog_page;
+create table catalog_page
+(
+    cp_catalog_page_sk       int,
+    cp_catalog_page_id       string,
+    cp_start_date_sk         int,
+    cp_end_date_sk           int,
+    cp_department            string,
+    cp_catalog_number        int,
+    cp_catalog_page_number   int,
+    cp_description           string,
+    cp_type                  string
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists catalog_returns;
+create table catalog_returns
+(
+    cr_returned_date_sk        int,
+    cr_returned_time_sk        int,
+    cr_item_sk                 int,
+    cr_refunded_customer_sk    int,
+    cr_refunded_cdemo_sk       int,
+    cr_refunded_hdemo_sk       int,
+    cr_refunded_addr_sk        int,
+    cr_returning_customer_sk   int,
+    cr_returning_cdemo_sk      int,
+    cr_returning_hdemo_sk      int,
+    cr_returning_addr_sk       int,
+    cr_call_center_sk          int,
+    cr_catalog_page_sk         int,
+    cr_ship_mode_sk            int,
+    cr_warehouse_sk            int,
+    cr_reason_sk               int,
+    cr_order_number            int,
+    cr_return_quantity         int,
+    cr_return_amount           decimal(7,2),
+    cr_return_tax              decimal(7,2),
+    cr_return_amt_inc_tax      decimal(7,2),
+    cr_fee                     decimal(7,2),
+    cr_return_ship_cost        decimal(7,2),
+    cr_refunded_cash           decimal(7,2),
+    cr_reversed_charge         decimal(7,2),
+    cr_store_credit            decimal(7,2),
+    cr_net_loss                decimal(7,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists catalog_sales;
+create table catalog_sales
+(
+    cs_sold_date_sk            int,
+    cs_sold_time_sk            int,
+    cs_ship_date_sk            int,
+    cs_bill_customer_sk        int,
+    cs_bill_cdemo_sk           int,
+    cs_bill_hdemo_sk           int,
+    cs_bill_addr_sk            int,
+    cs_ship_customer_sk        int,
+    cs_ship_cdemo_sk           int,
+    cs_ship_hdemo_sk           int,
+    cs_ship_addr_sk            int,
+    cs_call_center_sk          int,
+    cs_catalog_page_sk         int,
+    cs_ship_mode_sk            int,
+    cs_warehouse_sk            int,
+    cs_item_sk                 int,
+    cs_promo_sk                int,
+    cs_order_number            int,
+    cs_quantity                int,
+    cs_wholesale_cost          decimal(7,2),
+    cs_list_price              decimal(7,2),
+    cs_sales_price             decimal(7,2),
+    cs_ext_discount_amt        decimal(7,2),
+    cs_ext_sales_price         decimal(7,2),
+    cs_ext_wholesale_cost      decimal(7,2),
+    cs_ext_list_price          decimal(7,2),
+    cs_ext_tax                 decimal(7,2),
+    cs_coupon_amt              decimal(7,2),
+    cs_ext_ship_cost           decimal(7,2),
+    cs_net_paid                decimal(7,2),
+    cs_net_paid_inc_tax        decimal(7,2),
+    cs_net_paid_inc_ship       decimal(7,2),
+    cs_net_paid_inc_ship_tax   decimal(7,2),
+    cs_net_profit              decimal(7,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists customer;
+create table customer
+(
+    c_customer_sk             int,
+    c_customer_id             string,
+    c_current_cdemo_sk        int,
+    c_current_hdemo_sk        int,
+    c_current_addr_sk         int,
+    c_first_shipto_date_sk    int,
+    c_first_sales_date_sk     int,
+    c_salutation              string,
+    c_first_name              string,
+    c_last_name               string,
+    c_preferred_cust_flag     string,
+    c_birth_day               int,
+    c_birth_month             int,
+    c_birth_year              int,
+    c_birth_country           string,
+    c_login                   string,
+    c_email_address           string,
+    c_last_review_date        string
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists customer_address;
+create table customer_address
+(
+    ca_address_sk             int,
+    ca_address_id             string,
+    ca_street_number          string,
+    ca_street_name            string,
+    ca_street_type            string,
+    ca_suite_number           string,
+    ca_city                   string,
+    ca_county                 string,
+    ca_state                  string,
+    ca_zip                    string,
+    ca_country                string,
+    ca_gmt_offset             decimal(5,2),
+    ca_location_type          string
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists customer_demographics;
+create table customer_demographics
+(
+    cd_demo_sk                int,
+    cd_gender                 string,
+    cd_marital_status         string,
+    cd_education_status       string,
+    cd_purchase_estimate      int,
+    cd_credit_rating          string,
+    cd_dep_count              int,
+    cd_dep_employed_count     int,
+    cd_dep_college_count      int 
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists date_dim;
+create table date_dim
+(
+    d_date_sk                 int,
+    d_date_id                 string,
+    d_date                    string,
+    d_month_seq               int,
+    d_week_seq                int,
+    d_quarter_seq             int,
+    d_year                    int,
+    d_dow                     int,
+    d_moy                     int,
+    d_dom                     int,
+    d_qoy                     int,
+    d_fy_year                 int,
+    d_fy_quarter_seq          int,
+    d_fy_week_seq             int,
+    d_day_name                string,
+    d_quarter_name            string,
+    d_holiday                 string,
+    d_weekend                 string,
+    d_following_holiday       string,
+    d_first_dom               int,
+    d_last_dom                int,
+    d_same_day_ly             int,
+    d_same_day_lq             int,
+    d_current_day             string,
+    d_current_week            string,
+    d_current_month           string,
+    d_current_quarter         string,
+    d_current_year            string 
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists household_demographics;
+create table household_demographics
+(
+    hd_demo_sk                int,
+    hd_income_band_sk         int,
+    hd_buy_potential          string,
+    hd_dep_count              int,
+    hd_vehicle_count          int
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists income_band;
+create table income_band
+(
+    ib_income_band_sk        int,
+    ib_lower_bound           int,
+    ib_upper_bound           int
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists inventory;
+create table inventory
+(
+    inv_date_sk                int,
+    inv_item_sk                int,
+    inv_warehouse_sk           int,
+    inv_quantity_on_hand       int
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists item;
+create table item
+(
+    i_item_sk                 int,
+    i_item_id                 string,
+    i_rec_start_date          string,
+    i_rec_end_date            string,
+    i_item_desc               string,
+    i_current_price           decimal(7,2),
+    i_wholesale_cost          decimal(7,2),
+    i_brand_id                int,
+    i_brand                   string,
+    i_class_id                int,
+    i_class                   string,
+    i_category_id             int,
+    i_category                string,
+    i_manufact_id             int,
+    i_manufact                string,
+    i_size                    string,
+    i_formulation             string,
+    i_color                   string,
+    i_units                   string,
+    i_container               string,
+    i_manager_id              int,
+    i_product_name            string
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists promotion;
+create table promotion
+(
+    p_promo_sk                int,
+    p_promo_id                string,
+    p_start_date_sk           int,
+    p_end_date_sk             int,
+    p_item_sk                 int,
+    p_cost                    decimal(15,2),
+    p_response_target         int,
+    p_promo_name              string,
+    p_channel_dmail           string,
+    p_channel_email           string,
+    p_channel_catalog         string,
+    p_channel_tv              string,
+    p_channel_radio           string,
+    p_channel_press           string,
+    p_channel_event           string,
+    p_channel_demo            string,
+    p_channel_details         string,
+    p_purpose                 string,
+    p_discount_active         string 
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists reason;
+create table reason
+(
+    r_reason_sk         int,
+    r_reason_id         string,
+    r_reason_desc       string
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists ship_mode;
+create table ship_mode
+(
+    sm_ship_mode_sk           int,
+    sm_ship_mode_id           string,
+    sm_type                   string,
+    sm_code                   string,
+    sm_carrier                string,
+    sm_contract               string
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists store;
+create table store
+(
+    s_store_sk                int,
+    s_store_id                string,
+    s_rec_start_date          string,
+    s_rec_end_date            string,
+    s_closed_date_sk          int,
+    s_store_name              string,
+    s_number_employees        int,
+    s_floor_space             int,
+    s_hours                   string,
+    s_manager                 string,
+    s_market_id               int,
+    s_geography_class         string,
+    s_market_desc             string,
+    s_market_manager          string,
+    s_division_id             int,
+    s_division_name           string,
+    s_company_id              int,
+    s_company_name            string,
+    s_street_number           string,
+    s_street_name             string,
+    s_street_type             string,
+    s_suite_number            string,
+    s_city                    string,
+    s_county                  string,
+    s_state                   string,
+    s_zip                     string,
+    s_country                 string,
+    s_gmt_offset              decimal(5,2),
+    s_tax_precentage          decimal(5,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists store_returns;
+create table store_returns
+(
+    sr_returned_date_sk      int,
+    sr_return_time_sk        int,
+    sr_item_sk               int,
+    sr_customer_sk           int,
+    sr_cdemo_sk              int,
+    sr_hdemo_sk              int,
+    sr_addr_sk               int,
+    sr_store_sk              int,
+    sr_reason_sk             int,
+    sr_ticket_number         int,
+    sr_return_quantity       int,
+    sr_return_amt            decimal(7,2),
+    sr_return_tax            decimal(7,2),
+    sr_return_amt_inc_tax    decimal(7,2),
+    sr_fee                   decimal(7,2),
+    sr_return_ship_cost      decimal(7,2),
+    sr_refunded_cash         decimal(7,2),
+    sr_reversed_charge       decimal(7,2),
+    sr_store_credit          decimal(7,2),
+    sr_net_loss              decimal(7,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists store_sales;
+create table store_sales
+(
+    ss_sold_date_sk           int,
+    ss_sold_time_sk           int,
+    ss_item_sk                int,
+    ss_customer_sk            int,
+    ss_cdemo_sk               int,
+    ss_hdemo_sk               int,
+    ss_addr_sk                int,
+    ss_store_sk               int,
+    ss_promo_sk               int,
+    ss_ticket_number          int,
+    ss_quantity               int,
+    ss_wholesale_cost         decimal(7,2),
+    ss_list_price             decimal(7,2),
+    ss_sales_price            decimal(7,2),
+    ss_ext_discount_amt       decimal(7,2),
+    ss_ext_sales_price        decimal(7,2),
+    ss_ext_wholesale_cost     decimal(7,2),
+    ss_ext_list_price         decimal(7,2),
+    ss_ext_tax                decimal(7,2),
+    ss_coupon_amt             decimal(7,2),
+    ss_net_paid               decimal(7,2),
+    ss_net_paid_inc_tax       decimal(7,2),
+    ss_net_profit             decimal(7,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists time_dim;
+create table time_dim
+(
+    t_time_sk                 int,
+    t_time_id                 string,
+    t_time                    int,
+    t_hour                    int,
+    t_minute                  int,
+    t_second                  int,
+    t_am_pm                   string,
+    t_shift                   string,
+    t_sub_shift               string,
+    t_meal_time               string
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists warehouse;
+create table warehouse
+(
+    w_warehouse_sk            int,
+    w_warehouse_id            string,
+    w_warehouse_name          string,
+    w_warehouse_sq_ft         int,
+    w_street_number           string,
+    w_street_name             string,
+    w_street_type             string,
+    w_suite_number            string,
+    w_city                    string,
+    w_county                  string,
+    w_state                   string,
+    w_zip                     string,
+    w_country                 string,
+    w_gmt_offset              decimal(5,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists web_page;
+create table web_page
+(
+    wp_web_page_sk           int,
+    wp_web_page_id           string,
+    wp_rec_start_date        string,
+    wp_rec_end_date          string,
+    wp_creation_date_sk      int,
+    wp_access_date_sk        int,
+    wp_autogen_flag          string,
+    wp_customer_sk           int,
+    wp_url                   string,
+    wp_type                  string,
+    wp_char_count            int,
+    wp_link_count            int,
+    wp_image_count           int,
+    wp_max_ad_count          int
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists web_returns;
+create table web_returns
+(
+    wr_returned_date_sk        int,
+    wr_returned_time_sk        int,
+    wr_item_sk                 int,
+    wr_refunded_customer_sk    int,
+    wr_refunded_cdemo_sk       int,
+    wr_refunded_hdemo_sk       int,
+    wr_refunded_addr_sk        int,
+    wr_returning_customer_sk   int,
+    wr_returning_cdemo_sk      int,
+    wr_returning_hdemo_sk      int,
+    wr_returning_addr_sk       int,
+    wr_web_page_sk             int,
+    wr_reason_sk               int,
+    wr_order_number            int,
+    wr_return_quantity         int,
+    wr_return_amt              decimal(7,2),
+    wr_return_tax              decimal(7,2),
+    wr_return_amt_inc_tax      decimal(7,2),
+    wr_fee                     decimal(7,2),
+    wr_return_ship_cost        decimal(7,2),
+    wr_refunded_cash           decimal(7,2),
+    wr_reversed_charge         decimal(7,2),
+    wr_account_credit          decimal(7,2),
+    wr_net_loss                decimal(7,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists web_sales;
+create table web_sales
+(
+    ws_sold_date_sk           int,
+    ws_sold_time_sk           int,
+    ws_ship_date_sk           int,
+    ws_item_sk                int,
+    ws_bill_customer_sk       int,
+    ws_bill_cdemo_sk          int,
+    ws_bill_hdemo_sk          int,
+    ws_bill_addr_sk           int,
+    ws_ship_customer_sk       int,
+    ws_ship_cdemo_sk          int,
+    ws_ship_hdemo_sk          int,
+    ws_ship_addr_sk           int,
+    ws_web_page_sk            int,
+    ws_web_site_sk            int,
+    ws_ship_mode_sk           int,
+    ws_warehouse_sk           int,
+    ws_promo_sk               int,
+    ws_order_number           int,
+    ws_quantity               int,
+    ws_wholesale_cost         decimal(7,2),
+    ws_list_price             decimal(7,2),
+    ws_sales_price            decimal(7,2),
+    ws_ext_discount_amt       decimal(7,2),
+    ws_ext_sales_price        decimal(7,2),
+    ws_ext_wholesale_cost     decimal(7,2),
+    ws_ext_list_price         decimal(7,2),
+    ws_ext_tax                decimal(7,2),
+    ws_coupon_amt             decimal(7,2),
+    ws_ext_ship_cost          decimal(7,2),
+    ws_net_paid               decimal(7,2),
+    ws_net_paid_inc_tax       decimal(7,2),
+    ws_net_paid_inc_ship      decimal(7,2),
+    ws_net_paid_inc_ship_tax  decimal(7,2),
+    ws_net_profit             decimal(7,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+drop table if exists web_site;
+create table web_site
+(
+    web_site_sk             int,
+    web_site_id             string,
+    web_rec_start_date      string,
+    web_rec_end_date        string,
+    web_name                string,
+    web_open_date_sk        int,
+    web_close_date_sk       int,
+    web_class               string,
+    web_manager             string,
+    web_mkt_id              int,
+    web_mkt_class           string,
+    web_mkt_desc            string,
+    web_market_manager      string,
+    web_company_id          int,
+    web_company_name        string,
+    web_street_number       string,
+    web_street_name         string,
+    web_street_type         string,
+    web_suite_number        string,
+    web_city                string,
+    web_county              string,
+    web_state               string,
+    web_zip                 string,
+    web_country             string,
+    web_gmt_offset          decimal(5,2),
+    web_tax_percentage      decimal(5,2)
+)
+row format delimited fields terminated by '\t'
+STORED AS ORC tblproperties ("transactional"="true", "orc.compress"="ZLIB");
+
+
+-- CONSTRAINTS
+alter table customer_address add constraint pk_ca primary key (ca_address_sk) disable novalidate rely;
+alter table customer_demographics add constraint pk_cd primary key (cd_demo_sk) disable novalidate rely;
+alter table date_dim add constraint pk_dd primary key (d_date_sk) disable novalidate rely;
+alter table warehouse add constraint pk_w primary key (w_warehouse_sk) disable novalidate rely;
+alter table ship_mode add constraint pk_sm primary key (sm_ship_mode_sk) disable novalidate rely;
+alter table time_dim add constraint pk_td primary key (t_time_sk) disable novalidate rely;
+alter table reason add constraint pk_r primary key (r_reason_sk) disable novalidate rely;
+alter table income_band add constraint pk_ib primary key (ib_income_band_sk) disable novalidate rely;
+alter table item add constraint pk_i primary key (i_item_sk) disable novalidate rely;
+alter table store add constraint pk_s primary key (s_store_sk) disable novalidate rely;
+alter table call_center add constraint pk_cc primary key (cc_call_center_sk) disable novalidate rely;
+alter table customer add constraint pk_c primary key (c_customer_sk) disable novalidate rely;
+alter table web_site add constraint pk_ws primary key (web_site_sk) disable novalidate rely;
+alter table store_returns add constraint pk_sr primary key (sr_item_sk, sr_ticket_number) disable novalidate rely;
+alter table household_demographics add constraint pk_hd primary key (hd_demo_sk) disable novalidate rely;
+alter table web_page add constraint pk_wp primary key (wp_web_page_sk) disable novalidate rely;
+alter table promotion add constraint pk_p primary key (p_promo_sk) disable novalidate rely;
+alter table catalog_page add constraint pk_cp primary key (cp_catalog_page_sk) disable novalidate rely;
+-- partition_col case
+alter table inventory add constraint pk_in primary key (inv_date_sk, inv_item_sk, inv_warehouse_sk) disable novalidate rely;
+alter table catalog_returns add constraint pk_cr primary key (cr_item_sk, cr_order_number) disable novalidate rely;
+alter table web_returns add constraint pk_wr primary key (wr_item_sk, wr_order_number) disable novalidate rely;
+alter table web_sales add constraint pk_ws2 primary key (ws_item_sk, ws_order_number) disable novalidate rely;
+alter table catalog_sales add constraint pk_cs primary key (cs_item_sk, cs_order_number) disable novalidate rely;
+alter table store_sales add constraint pk_ss primary key (ss_item_sk, ss_ticket_number) disable novalidate rely;
+
+alter table call_center add constraint cc_d1 foreign key  (cc_closed_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table call_center add constraint cc_d2 foreign key  (cc_open_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table catalog_page add constraint cp_d1 foreign key  (cp_end_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table catalog_page add constraint cp_d2 foreign key  (cp_start_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_cc foreign key  (cr_call_center_sk) references call_center (cc_call_center_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_cp foreign key  (cr_catalog_page_sk) references catalog_page (cp_catalog_page_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_cs foreign key  (cr_item_sk, cr_order_number) references catalog_sales (cs_item_sk, cs_order_number) disable novalidate rely;
+alter table catalog_returns add constraint cr_i foreign key  (cr_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_r foreign key  (cr_reason_sk) references reason (r_reason_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_a1 foreign key  (cr_refunded_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_cd1 foreign key  (cr_refunded_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_c1 foreign key  (cr_refunded_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_hd1 foreign key  (cr_refunded_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+-- partition_col case
+alter table catalog_returns add constraint cr_d1 foreign key  (cr_returned_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_t foreign key  (cr_returned_time_sk) references time_dim (t_time_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_a2 foreign key  (cr_returning_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_cd2 foreign key  (cr_returning_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_c2 foreign key  (cr_returning_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_hd2 foreign key  (cr_returning_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+-- alter table catalog_returns add constraint cr_d2 foreign key  (cr_ship_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_sm foreign key  (cr_ship_mode_sk) references ship_mode (sm_ship_mode_sk) disable novalidate rely;
+alter table catalog_returns add constraint cr_w2 foreign key  (cr_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_b_a foreign key  (cs_bill_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_b_cd foreign key  (cs_bill_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_b_c foreign key  (cs_bill_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_b_hd foreign key  (cs_bill_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_cc foreign key  (cs_call_center_sk) references call_center (cc_call_center_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_cp foreign key  (cs_catalog_page_sk) references catalog_page (cp_catalog_page_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_i foreign key  (cs_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_p foreign key  (cs_promo_sk) references promotion (p_promo_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_s_a foreign key  (cs_ship_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_s_cd foreign key  (cs_ship_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_s_c foreign key  (cs_ship_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_d1 foreign key  (cs_ship_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_s_hd foreign key  (cs_ship_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_sm foreign key  (cs_ship_mode_sk) references ship_mode (sm_ship_mode_sk) disable novalidate rely;
+-- partition_col case
+alter table catalog_sales add constraint cs_d2 foreign key  (cs_sold_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_t foreign key  (cs_sold_time_sk) references time_dim (t_time_sk) disable novalidate rely;
+alter table catalog_sales add constraint cs_w foreign key  (cs_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
+alter table customer add constraint c_a foreign key  (c_current_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table customer add constraint c_cd foreign key  (c_current_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table customer add constraint c_hd foreign key  (c_current_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table customer add constraint c_fsd foreign key  (c_first_sales_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table customer add constraint c_fsd2 foreign key  (c_first_shipto_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table household_demographics add constraint hd_ib foreign key  (hd_income_band_sk) references income_band (ib_income_band_sk) disable novalidate rely;
+-- partition_col case
+alter table inventory add constraint inv_d foreign key  (inv_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table inventory add constraint inv_i foreign key  (inv_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table inventory add constraint inv_w foreign key  (inv_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
+alter table promotion add constraint p_end_date foreign key  (p_end_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table promotion add constraint p_i foreign key  (p_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table promotion add constraint p_start_date foreign key  (p_start_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table store add constraint s_close_date foreign key  (s_closed_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table store_returns add constraint sr_a foreign key  (sr_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table store_returns add constraint sr_cd foreign key  (sr_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table store_returns add constraint sr_c foreign key  (sr_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table store_returns add constraint sr_hd foreign key  (sr_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table store_returns add constraint sr_i foreign key  (sr_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table store_returns add constraint sr_r foreign key  (sr_reason_sk) references reason (r_reason_sk) disable novalidate rely;
+-- partition_col case
+alter table store_returns add constraint sr_ret_d foreign key  (sr_returned_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table store_returns add constraint sr_t foreign key  (sr_return_time_sk) references time_dim (t_time_sk) disable novalidate rely;
+alter table store_returns add constraint sr_s foreign key  (sr_store_sk) references store (s_store_sk) disable novalidate rely;
+alter table store_returns add constraint sr_ss foreign key  (sr_item_sk, sr_ticket_number) references store_sales (ss_item_sk, ss_ticket_number) disable novalidate rely;
+alter table store_sales add constraint ss_a foreign key  (ss_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table store_sales add constraint ss_cd foreign key  (ss_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table store_sales add constraint ss_c foreign key  (ss_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table store_sales add constraint ss_hd foreign key  (ss_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table store_sales add constraint ss_i foreign key  (ss_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table store_sales add constraint ss_p foreign key  (ss_promo_sk) references promotion (p_promo_sk) disable novalidate rely;
+-- partition_col case
+alter table store_sales add constraint ss_d foreign key  (ss_sold_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table store_sales add constraint ss_t foreign key  (ss_sold_time_sk) references time_dim (t_time_sk) disable novalidate rely;
+alter table store_sales add constraint ss_s foreign key  (ss_store_sk) references store (s_store_sk) disable novalidate rely;
+alter table web_page add constraint wp_ad foreign key  (wp_access_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table web_page add constraint wp_cd foreign key  (wp_creation_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table web_returns add constraint wr_i foreign key  (wr_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table web_returns add constraint wr_r foreign key  (wr_reason_sk) references reason (r_reason_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ref_a foreign key  (wr_refunded_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ref_cd foreign key  (wr_refunded_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ref_c foreign key  (wr_refunded_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ref_hd foreign key  (wr_refunded_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+-- partition_col case
+alter table web_returns add constraint wr_ret_d foreign key  (wr_returned_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ret_t foreign key  (wr_returned_time_sk) references time_dim (t_time_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ret_a foreign key  (wr_returning_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ret_cd foreign key  (wr_returning_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ret_c foreign key  (wr_returning_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ret_hd foreign key  (wr_returning_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table web_returns add constraint wr_ws foreign key  (wr_item_sk, wr_order_number) references web_sales (ws_item_sk, ws_order_number) disable novalidate rely;
+alter table web_returns add constraint wr_wp foreign key  (wr_web_page_sk) references web_page (wp_web_page_sk) disable novalidate rely;
+alter table web_sales add constraint ws_b_a foreign key  (ws_bill_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table web_sales add constraint ws_b_cd foreign key  (ws_bill_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table web_sales add constraint ws_b_c foreign key  (ws_bill_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table web_sales add constraint ws_b_hd foreign key  (ws_bill_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table web_sales add constraint ws_i foreign key  (ws_item_sk) references item (i_item_sk) disable novalidate rely;
+alter table web_sales add constraint ws_p foreign key  (ws_promo_sk) references promotion (p_promo_sk) disable novalidate rely;
+alter table web_sales add constraint ws_s_a foreign key  (ws_ship_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
+alter table web_sales add constraint ws_s_cd foreign key  (ws_ship_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
+alter table web_sales add constraint ws_s_c foreign key  (ws_ship_customer_sk) references customer (c_customer_sk) disable novalidate rely;
+alter table web_sales add constraint ws_s_d foreign key  (ws_ship_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table web_sales add constraint ws_s_hd foreign key  (ws_ship_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
+alter table web_sales add constraint ws_sm foreign key  (ws_ship_mode_sk) references ship_mode (sm_ship_mode_sk) disable novalidate rely;
+-- partition_col case
+alter table web_sales add constraint ws_d2 foreign key  (ws_sold_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table web_sales add constraint ws_t foreign key  (ws_sold_time_sk) references time_dim (t_time_sk) disable novalidate rely;
+alter table web_sales add constraint ws_w2 foreign key  (ws_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
+alter table web_sales add constraint ws_wp foreign key  (ws_web_page_sk) references web_page (wp_web_page_sk) disable novalidate rely;
+alter table web_sales add constraint ws_ws foreign key  (ws_web_site_sk) references web_site (web_site_sk) disable novalidate rely;
+alter table web_site add constraint web_d1 foreign key  (web_close_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+alter table web_site add constraint web_d2 foreign key (web_open_date_sk) references date_dim (d_date_sk) disable novalidate rely;
+
+alter table store change column s_store_id s_store_id string constraint strid_nn not null disable novalidate rely;
+alter table call_center change column cc_call_center_id cc_call_center_id string constraint ccid_nn not null disable novalidate rely;
+alter table catalog_page change column cp_catalog_page_id cp_catalog_page_id string constraint cpid_nn not null disable novalidate rely;
+alter table web_site change column web_site_id web_site_id string constraint wsid_nn not null disable novalidate rely;
+alter table web_page change column wp_web_page_id wp_web_page_id string constraint wpid_nn not null disable novalidate rely;
+alter table warehouse change column w_warehouse_id w_warehouse_id string constraint wid_nn not null disable novalidate rely;
+alter table customer change column c_customer_id c_customer_id string constraint cid_nn not null disable novalidate rely;
+alter table customer_address change column ca_address_id ca_address_id string constraint caid_nn not null disable novalidate rely;
+alter table date_dim change column d_date_id d_date_id string constraint did_nn not null disable novalidate rely;
+alter table item change column i_item_id i_item_id string constraint itid_nn not null disable novalidate rely;
+alter table promotion change column p_promo_id p_promo_id string constraint pid_nn not null disable novalidate rely;
+alter table reason change column r_reason_id r_reason_id string constraint rid_nn not null disable novalidate rely;
+alter table ship_mode change column sm_ship_mode_id sm_ship_mode_id string constraint smid_nn not null disable novalidate rely;
+alter table time_dim change column t_time_id t_time_id string constraint tid_nn not null disable novalidate rely;

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfCliDriver.java
----------------------------------------------------------------------
diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfCliDriver.java
index 98ceb21..18a470f 100644
--- a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfCliDriver.java
+++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfCliDriver.java
@@ -34,7 +34,7 @@ import org.junit.runners.Parameterized.Parameters;
 @RunWith(Parameterized.class)
 public class TestTezPerfCliDriver {
 
-  static CliAdapter adapter = new CliConfigs.TezPerfCliConfig().getCliAdapter();
+  static CliAdapter adapter = new CliConfigs.TezPerfCliConfig(false).getCliAdapter();
 
   @Parameters(name = "{0}")
   public static List<Object[]> getParameters() throws Exception {

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfConstraintsCliDriver.java
----------------------------------------------------------------------
diff --git a/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfConstraintsCliDriver.java b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfConstraintsCliDriver.java
new file mode 100644
index 0000000..5881353
--- /dev/null
+++ b/itests/qtest/src/test/java/org/apache/hadoop/hive/cli/TestTezPerfConstraintsCliDriver.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.cli;
+
+import java.io.File;
+import java.util.Comparator;
+import java.util.List;
+import org.apache.hadoop.hive.cli.control.CliAdapter;
+import org.apache.hadoop.hive.cli.control.CliConfigs;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class TestTezPerfConstraintsCliDriver {
+
+  static CliAdapter adapter = new CliConfigs.TezPerfCliConfig(true).getCliAdapter();
+
+  @Parameters(name = "{0}")
+  public static List<Object[]> getParameters() throws Exception {
+    List<Object[]> parameters = adapter.getParameters();
+    parameters.sort(new C1());
+    return parameters;
+  }
+
+  static class C1 implements Comparator<Object[]> {
+
+    @Override
+    public int compare(Object[] o1, Object[] o2) {
+      return o1[0].toString().compareTo(o2[0].toString());
+    }
+
+  }
+
+  @ClassRule
+  public static TestRule cliClassRule = adapter.buildClassRule();
+
+  @Rule
+  public TestRule cliTestRule = adapter.buildTestRule();
+
+  private String name;
+  private File qfile;
+
+  public TestTezPerfConstraintsCliDriver(String name, File qfile) {
+    this.name = name;
+    this.qfile = qfile;
+  }
+
+  @Test
+  public void testCliDriver() throws Exception {
+    adapter.runTest(name, qfile);
+  }
+
+}


[44/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query38.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query38.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query38.q.out
new file mode 100644
index 0000000..9633df1
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query38.q.out
@@ -0,0 +1,111 @@
+PREHOOK: query: explain cbo
+select  count(*) from (
+    select distinct c_last_name, c_first_name, d_date
+    from store_sales, date_dim, customer
+          where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+      and store_sales.ss_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from catalog_sales, date_dim, customer
+          where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+      and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from web_sales, date_dim, customer
+          where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+      and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+) hot_cust
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  count(*) from (
+    select distinct c_last_name, c_first_name, d_date
+    from store_sales, date_dim, customer
+          where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+      and store_sales.ss_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from catalog_sales, date_dim, customer
+          where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+      and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from web_sales, date_dim, customer
+          where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+      and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+) hot_cust
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0])
+    HiveAggregate(group=[{}], agg#0=[count()])
+      HiveProject(c_last_name=[$0], c_first_name=[$1], d_date=[$2], $f3=[$3])
+        HiveFilter(condition=[=($3, 3)])
+          HiveAggregate(group=[{0, 1, 2}], agg#0=[count($3)])
+            HiveProject(c_last_name=[$0], c_first_name=[$1], d_date=[$2], $f3=[$3])
+              HiveUnion(all=[true])
+                HiveProject(c_last_name=[$1], c_first_name=[$0], d_date=[$2], $f3=[$3])
+                  HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                    HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                      HiveAggregate(group=[{1, 2, 6}])
+                        HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                            HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                              HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(c_last_name=[$1], c_first_name=[$0], d_date=[$2], $f3=[$3])
+                  HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                    HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                      HiveAggregate(group=[{1, 2, 6}])
+                        HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3])
+                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($3))])
+                                HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                            HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                              HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(c_last_name=[$1], c_first_name=[$0], d_date=[$2], $f3=[$3])
+                  HiveAggregate(group=[{0, 1, 2}], agg#0=[count()])
+                    HiveProject(c_first_name=[$0], c_last_name=[$1], d_date=[$2])
+                      HiveAggregate(group=[{1, 2, 6}])
+                        HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                                HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                            HiveProject(d_date_sk=[$0], d_date=[$2], d_month_seq=[$3])
+                              HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out
new file mode 100644
index 0000000..fd3038e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query39.q.out
@@ -0,0 +1,168 @@
+PREHOOK: query: explain cbo
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], d_moy=[CAST(4):INTEGER], mean=[$2], cov=[$3], w_warehouse_sk1=[$4], i_item_sk1=[$5], d_moy1=[CAST(5):INTEGER], mean1=[$6], cov1=[$7])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$6], sort5=[$7], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC])
+    HiveProject(w_warehouse_sk=[$0], i_item_sk=[$1], mean=[$2], cov=[$3], w_warehouse_sk0=[$4], i_item_sk0=[$5], mean0=[$6], cov0=[$7])
+      HiveJoin(condition=[AND(=($1, $5), =($0, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(w_warehouse_sk=[$1], i_item_sk=[$2], mean=[/(CAST($6):DOUBLE, $5)], cov=[CASE(=(/(CAST($6):DOUBLE, $5), 0), null, /(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null, -($5, 1))), 0.5), /(CAST($6):DOUBLE, $5)))])
+          HiveFilter(condition=[CASE(=(/(CAST($6):DOUBLE, $5), 0), false, >(/(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null, -($5, 1))), 0.5), /(CAST($6):DOUBLE, $5)), 1))])
+            HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
+              HiveProject($f0=[$9], $f1=[$8], $f2=[$0], $f4=[$4], $f40=[CAST($4):DOUBLE], $f6=[*(CAST($4):DOUBLE, CAST($4):DOUBLE)])
+                HiveJoin(condition=[=($3, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(i_item_sk=[$0])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3])
+                        HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($2), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(4):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 4), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+        HiveProject(w_warehouse_sk=[$1], i_item_sk=[$2], mean=[/(CAST($6):DOUBLE, $5)], cov=[CASE(=(/(CAST($6):DOUBLE, $5), 0), null, /(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null, -($5, 1))), 0.5), /(CAST($6):DOUBLE, $5)))])
+          HiveFilter(condition=[CASE(=(/(CAST($6):DOUBLE, $5), 0), false, >(/(POWER(/(-($3, /(*($4, $4), $5)), CASE(=($5, 1), null, -($5, 1))), 0.5), /(CAST($6):DOUBLE, $5)), 1))])
+            HiveAggregate(group=[{0, 1, 2}], agg#0=[sum($5)], agg#1=[sum($4)], agg#2=[count($3)], agg#3=[sum($3)])
+              HiveProject($f0=[$9], $f1=[$8], $f2=[$0], $f4=[$4], $f40=[CAST($4):DOUBLE], $f6=[*(CAST($4):DOUBLE, CAST($4):DOUBLE)])
+                HiveJoin(condition=[=($3, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(i_item_sk=[$0])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_warehouse_sk=[$2], inv_quantity_on_hand=[$3])
+                        HiveFilter(condition=[AND(IS NOT NULL($1), IS NOT NULL($2), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(5):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 5), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+
+PREHOOK: query: with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out
new file mode 100644
index 0000000..d796f86
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query4.q.out
@@ -0,0 +1,324 @@
+PREHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
+       ,'c' sale_type
+ from customer
+     ,catalog_sales
+     ,date_dim
+ where c_customer_sk = cs_bill_customer_sk
+   and cs_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.customer_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_c_firstyear
+     ,year_total t_c_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_c_secyear.customer_id
+   and t_s_firstyear.customer_id = t_c_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_secyear.customer_id
+   and t_s_firstyear.sale_type = 's'
+   and t_c_firstyear.sale_type = 'c'
+   and t_w_firstyear.sale_type = 'w'
+   and t_s_secyear.sale_type = 's'
+   and t_c_secyear.sale_type = 'c'
+   and t_w_secyear.sale_type = 'w'
+   and t_s_firstyear.dyear =  2001
+   and t_s_secyear.dyear = 2001+1
+   and t_c_firstyear.dyear =  2001
+   and t_c_secyear.dyear =  2001+1
+   and t_w_firstyear.dyear = 2001
+   and t_w_secyear.dyear = 2001+1
+   and t_s_firstyear.year_total > 0
+   and t_c_firstyear.year_total > 0
+   and t_w_firstyear.year_total > 0
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+ order by t_s_secyear.customer_preferred_cust_flag
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
+       ,'c' sale_type
+ from customer
+     ,catalog_sales
+     ,date_dim
+ where c_customer_sk = cs_bill_customer_sk
+   and cs_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.customer_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_c_firstyear
+     ,year_total t_c_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_c_secyear.customer_id
+   and t_s_firstyear.customer_id = t_c_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_secyear.customer_id
+   and t_s_firstyear.sale_type = 's'
+   and t_c_firstyear.sale_type = 'c'
+   and t_w_firstyear.sale_type = 'w'
+   and t_s_secyear.sale_type = 's'
+   and t_c_secyear.sale_type = 'c'
+   and t_w_secyear.sale_type = 'w'
+   and t_s_firstyear.dyear =  2001
+   and t_s_secyear.dyear = 2001+1
+   and t_c_firstyear.dyear =  2001
+   and t_c_secyear.dyear =  2001+1
+   and t_w_firstyear.dyear = 2001
+   and t_w_secyear.dyear = 2001+1
+   and t_s_firstyear.year_total > 0
+   and t_c_firstyear.year_total > 0
+   and t_w_firstyear.year_total > 0
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+ order by t_s_secyear.customer_preferred_cust_flag
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(customer_preferred_cust_flag=[$1])
+    HiveJoin(condition=[AND(=($0, $7), CASE(CAST(IS NOT NULL($8)):BOOLEAN, CASE(CAST(IS NOT NULL($10)):BOOLEAN, >(/($4, $10), /($2, $8)), >(null, /($2, $8))), CASE(CAST(IS NOT NULL($10)):BOOLEAN, >(/($4, $10), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject($f0=[$0], $f3=[$3], $f8=[$7])
+        HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+          HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[/(+(-(-($13, $12), $10), $11), CAST(2):DECIMAL(10, 0))])
+            HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                  HiveTableScan(table=[[default, customer]], table:alias=[customer])
+              HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_ext_discount_amt=[$14], ss_ext_sales_price=[$15], ss_ext_wholesale_cost=[$16], ss_ext_list_price=[$17])
+                  HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                  HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveJoin(condition=[AND(=($4, $0), CASE(CAST(IS NOT NULL($9)):BOOLEAN, CASE(CAST(IS NOT NULL($7)):BOOLEAN, >(/($1, $7), /($3, $9)), >(null, /($3, $9))), CASE(CAST(IS NOT NULL($7)):BOOLEAN, >(/($1, $7), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject($f0=[$0], $f8=[$7])
+          HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+            HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[/(+(-(-($13, $12), $10), $11), CAST(2):DECIMAL(10, 0))])
+              HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_ext_discount_amt=[$22], cs_ext_sales_price=[$23], cs_ext_wholesale_cost=[$24], cs_ext_list_price=[$25])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveJoin(condition=[=($2, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($2, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[$0], $f8=[$7])
+                HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+                  HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[/(+(-(-($13, $12), $10), $11), CAST(2):DECIMAL(10, 0))])
+                    HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                      HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_ext_discount_amt=[$22], ws_ext_sales_price=[$23], ws_ext_wholesale_cost=[$24], ws_ext_list_price=[$25])
+                          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                        HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                          HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject($f0=[$0], $f8=[$7])
+                HiveFilter(condition=[>($7, 0)])
+                  HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+                    HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[/(+(-(-($13, $12), $10), $11), CAST(2):DECIMAL(10, 0))])
+                      HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                        HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_ext_discount_amt=[$14], ss_ext_sales_price=[$15], ss_ext_wholesale_cost=[$16], ss_ext_list_price=[$17])
+                            HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                            HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject($f0=[$0], $f8=[$7])
+              HiveFilter(condition=[>($7, 0)])
+                HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+                  HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[/(+(-(-($13, $12), $10), $11), CAST(2):DECIMAL(10, 0))])
+                    HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                      HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_ext_discount_amt=[$22], cs_ext_sales_price=[$23], cs_ext_wholesale_cost=[$24], cs_ext_list_price=[$25])
+                          HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                        HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                          HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject($f0=[$0], $f8=[$7])
+            HiveFilter(condition=[>($7, 0)])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6}], agg#0=[sum($7)])
+                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f6=[$7], $f8=[/(+(-(-($13, $12), $10), $11), CAST(2):DECIMAL(10, 0))])
+                  HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4], ws_ext_discount_amt=[$22], ws_ext_sales_price=[$23], ws_ext_wholesale_cost=[$24], ws_ext_list_price=[$25])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
new file mode 100644
index 0000000..7d8fc9b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query40.q.out
@@ -0,0 +1,91 @@
+PREHOOK: query: explain cbo
+select  
+   w_state
+  ,i_item_id
+  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
+  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
+ from
+   catalog_sales left outer join catalog_returns on
+       (cs_order_number = cr_order_number 
+        and cs_item_sk = cr_item_sk)
+  ,warehouse 
+  ,item
+  ,date_dim
+ where
+     i_current_price between 0.99 and 1.49
+ and i_item_sk          = cs_item_sk
+ and cs_warehouse_sk    = w_warehouse_sk 
+ and cs_sold_date_sk    = d_date_sk
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
+ group by
+    w_state,i_item_id
+ order by w_state,i_item_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@warehouse
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+   w_state
+  ,i_item_id
+  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
+  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
+ from
+   catalog_sales left outer join catalog_returns on
+       (cs_order_number = cr_order_number 
+        and cs_item_sk = cr_item_sk)
+  ,warehouse 
+  ,item
+  ,date_dim
+ where
+     i_current_price between 0.99 and 1.49
+ and i_item_sk          = cs_item_sk
+ and cs_warehouse_sk    = w_warehouse_sk 
+ and cs_sold_date_sk    = d_date_sk
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
+ group by
+    w_state,i_item_id
+ order by w_state,i_item_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
+    HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)])
+      HiveProject($f0=[$1], $f1=[$13], $f2=[CASE(<(CAST($11):DATE, 1998-04-08), -($6, CASE(IS NOT NULL($9), $9, 0)), 0)], $f3=[CASE(>=(CAST($11):DATE, 1998-04-08), -($6, CASE(IS NOT NULL($9), $9, 0)), 0)])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(w_warehouse_sk=[$0], w_state=[$10])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+          HiveJoin(condition=[=($10, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[AND(=($3, $6), =($2, $5))], joinType=[left], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_warehouse_sk=[$14], cs_item_sk=[$15], cs_order_number=[$17], cs_sales_price=[$21])
+                  HiveFilter(condition=[AND(IS NOT NULL($14), IS NOT NULL($15), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_refunded_cash=[$23])
+                  HiveFilter(condition=[IS NOT NULL($2)])
+                    HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+              HiveProject(d_date_sk=[$0], d_date=[$2])
+                HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-09 00:00:00, 1998-05-08 00:00:00), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(i_item_sk=[$0], i_item_id=[$1], i_current_price=[$5])
+              HiveFilter(condition=[AND(BETWEEN(false, $5, 0.99, 1.49), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query42.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query42.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query42.q.out
new file mode 100644
index 0000000..ddb3223
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query42.q.out
@@ -0,0 +1,68 @@
+PREHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_category_id
+ 	,item.i_category
+ 	,sum(ss_ext_sales_price)
+ 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_manager_id = 1  	
+ 	and dt.d_moy=12
+ 	and dt.d_year=1998
+ group by 	dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  dt.d_year
+ 	,item.i_category_id
+ 	,item.i_category
+ 	,sum(ss_ext_sales_price)
+ 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_manager_id = 1  	
+ 	and dt.d_moy=12
+ 	and dt.d_year=1998
+ group by 	dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject(d_year=[CAST(1998):INTEGER], i_category_id=[$0], i_category=[$1], _o__c3=[$2])
+    HiveSortLimit(sort0=[$3], sort1=[$0], sort2=[$1], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC])
+      HiveProject(i_category_id=[$0], i_category=[$1], _o__c3=[$2], (tok_function sum (tok_table_or_col ss_ext_sales_price))=[$2])
+        HiveAggregate(group=[{7, 8}], agg#0=[sum($2)])
+          HiveJoin(condition=[=($1, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER], d_moy=[CAST(12):INTEGER])
+                HiveFilter(condition=[AND(=($8, 12), =($6, 1998), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[dt])
+            HiveProject(i_item_sk=[$0], i_category_id=[$11], i_category=[$12], i_manager_id=[CAST(1):INTEGER])
+              HiveFilter(condition=[AND(=($20, 1), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
new file mode 100644
index 0000000..f6eeae3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query43.q.out
@@ -0,0 +1,61 @@
+PREHOOK: query: explain cbo
+select  s_store_name, s_store_id,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from date_dim, store_sales, store
+ where d_date_sk = ss_sold_date_sk and
+       s_store_sk = ss_store_sk and
+       s_gmt_offset = -6 and
+       d_year = 1998 
+ group by s_store_name, s_store_id
+ order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  s_store_name, s_store_id,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from date_dim, store_sales, store
+ where d_date_sk = ss_sold_date_sk and
+       s_store_sk = ss_store_sk and
+       s_gmt_offset = -6 and
+       d_year = 1998 
+ group by s_store_name, s_store_id
+ order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
+    HiveAggregate(group=[{0, 1}], agg#0=[sum($2)], agg#1=[sum($3)], agg#2=[sum($4)], agg#3=[sum($5)], agg#4=[sum($6)], agg#5=[sum($7)], agg#6=[sum($8)])
+      HiveProject($f0=[$8], $f1=[$7], $f2=[CASE(=($5, _UTF-16LE'Sunday'), $2, null)], $f3=[CASE(=($5, _UTF-16LE'Monday'), $2, null)], $f4=[CASE(=($5, _UTF-16LE'Tuesday'), $2, null)], $f5=[CASE(=($5, _UTF-16LE'Wednesday'), $2, null)], $f6=[CASE(=($5, _UTF-16LE'Thursday'), $2, null)], $f7=[CASE(=($5, _UTF-16LE'Friday'), $2, null)], $f8=[CASE(=($5, _UTF-16LE'Saturday'), $2, null)])
+        HiveJoin(condition=[=($6, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ss_sold_date_sk=[$0], ss_store_sk=[$7], ss_sales_price=[$13])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER], d_day_name=[$14])
+              HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5], s_gmt_offset=[CAST(-6):DECIMAL(5, 2)])
+            HiveFilter(condition=[AND(=($27, -6), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query44.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query44.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query44.q.out
new file mode 100644
index 0000000..73d4213
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query44.q.out
@@ -0,0 +1,115 @@
+Warning: Shuffle Join MERGEJOIN[103][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain cbo
+select  asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
+from(select *
+     from (select item_sk,rank() over (order by rank_col asc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col 
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V1)V11
+     where rnk  < 11) asceding,
+    (select *
+     from (select item_sk,rank() over (order by rank_col desc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V2)V21
+     where rnk  < 11) descending,
+item i1,
+item i2
+where asceding.rnk = descending.rnk 
+  and i1.i_item_sk=asceding.item_sk
+  and i2.i_item_sk=descending.item_sk
+order by asceding.rnk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
+from(select *
+     from (select item_sk,rank() over (order by rank_col asc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col 
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V1)V11
+     where rnk  < 11) asceding,
+    (select *
+     from (select item_sk,rank() over (order by rank_col desc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V2)V21
+     where rnk  < 11) descending,
+item i1,
+item i2
+where asceding.rnk = descending.rnk 
+  and i1.i_item_sk=asceding.item_sk
+  and i2.i_item_sk=descending.item_sk
+order by asceding.rnk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(rnk=[$3], best_performing=[$1], worst_performing=[$5])
+    HiveJoin(condition=[=($3, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_product_name=[$21])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, item]], table:alias=[i1])
+        HiveProject(item_sk=[$0], rank_window_0=[$1])
+          HiveFilter(condition=[AND(<($1, 11), IS NOT NULL($0))])
+            HiveProject(item_sk=[$0], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY $1 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+              HiveJoin(condition=[>($1, *(0.9, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject($f0=[$0], $f1=[/($1, $2)])
+                  HiveAggregate(group=[{2}], agg#0=[sum($22)], agg#1=[count($22)])
+                    HiveFilter(condition=[=($7, 410)])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[ss1])
+                HiveProject($f1=[/($1, $2)])
+                  HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[count($1)])
+                    HiveProject($f0=[true], $f1=[$22])
+                      HiveFilter(condition=[AND(=($7, 410), IS NULL($5))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+      HiveProject(i_item_sk=[$0], i_product_name=[$1], item_sk=[$2], rank_window_0=[$3])
+        HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_product_name=[$21])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, item]], table:alias=[i2])
+          HiveProject(item_sk=[$0], rank_window_0=[$1])
+            HiveFilter(condition=[AND(<($1, 11), IS NOT NULL($0))])
+              HiveProject(item_sk=[$0], rank_window_0=[rank() OVER (PARTITION BY 0 ORDER BY $1 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveJoin(condition=[>($1, *(0.9, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject($f0=[$0], $f1=[/($1, $2)])
+                    HiveAggregate(group=[{2}], agg#0=[sum($22)], agg#1=[count($22)])
+                      HiveFilter(condition=[=($7, 410)])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[ss1])
+                  HiveProject($f1=[/($1, $2)])
+                    HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[count($1)])
+                      HiveProject($f0=[true], $f1=[$22])
+                        HiveFilter(condition=[AND(=($7, 410), IS NULL($5))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query45.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query45.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query45.q.out
new file mode 100644
index 0000000..986dae9
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query45.q.out
@@ -0,0 +1,89 @@
+Warning: Shuffle Join MERGEJOIN[133][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 4' is a cross product
+PREHOOK: query: explain cbo
+select  ca_zip, ca_county, sum(ws_sales_price)
+ from web_sales, customer, customer_address, date_dim, item
+ where ws_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ws_item_sk = i_item_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
+ 	      or 
+ 	      i_item_id in (select i_item_id
+                             from item
+                             where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                             )
+ 	    )
+ 	and ws_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip, ca_county
+ order by ca_zip, ca_county
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  ca_zip, ca_county, sum(ws_sales_price)
+ from web_sales, customer, customer_address, date_dim, item
+ where ws_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ws_item_sk = i_item_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
+ 	      or 
+ 	      i_item_id in (select i_item_id
+                             from item
+                             where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                             )
+ 	    )
+ 	and ws_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip, ca_county
+ order by ca_zip, ca_county
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(ca_zip=[$1], ca_county=[$0], $f2=[$2])
+    HiveAggregate(group=[{7, 8}], agg#0=[sum($3)])
+      HiveFilter(condition=[OR(IN(substr($8, 1, 5), _UTF-16LE'85669', _UTF-16LE'86197', _UTF-16LE'88274', _UTF-16LE'83405', _UTF-16LE'86475', _UTF-16LE'85392', _UTF-16LE'85460', _UTF-16LE'80348', _UTF-16LE'81792'), CASE(=($14, 0), false, IS NOT NULL($17), true, IS NULL($13), null, <($15, $14), null, false))])
+        HiveProject(ws_sold_date_sk=[$9], ws_item_sk=[$10], ws_bill_customer_sk=[$11], ws_sales_price=[$12], c_customer_sk=[$0], c_current_addr_sk=[$1], ca_address_sk=[$2], ca_county=[$3], ca_zip=[$4], d_date_sk=[$13], d_year=[$14], d_qoy=[$15], i_item_sk=[$5], i_item_id=[$6], c=[$16], ck=[$17], i_item_id0=[$7], i1142=[$8])
+          HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($11, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                    HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                HiveProject(ca_address_sk=[$0], ca_county=[$7], ca_zip=[$9])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_id0=[$2], i1142=[$3], ws_sold_date_sk=[$4], ws_item_sk=[$5], ws_bill_customer_sk=[$6], ws_sales_price=[$7], d_date_sk=[$8], d_year=[$9], d_qoy=[$10])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $2)], joinType=[left], algorithm=[none], cost=[not available])
+                    HiveProject(i_item_sk=[$0], i_item_id=[$1])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                    HiveProject(i_item_id=[$0], i1142=[true])
+                      HiveAggregate(group=[{1}])
+                        HiveFilter(condition=[IN($0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29)])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$1], ws_bill_customer_sk=[$2], ws_sales_price=[$3], d_date_sk=[$4], d_year=[$5], d_qoy=[$6])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_customer_sk=[$4], ws_sales_price=[$21])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(2):INTEGER])
+                        HiveFilter(condition=[AND(=($10, 2), =($6, 2000), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(c=[$0], ck=[$1])
+              HiveAggregate(group=[{}], c=[COUNT()], ck=[COUNT($1)])
+                HiveFilter(condition=[IN($0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out
new file mode 100644
index 0000000..0728056
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query46.q.out
@@ -0,0 +1,115 @@
+PREHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,amt,profit 
+ from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,ca_city bought_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics,customer_address 
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and store_sales.ss_addr_sk = customer_address.ca_address_sk
+    and (household_demographics.hd_dep_count = 2 or
+         household_demographics.hd_vehicle_count= 1)
+    and date_dim.d_dow in (6,0)
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_city in ('Cedar Grove','Wildwood','Union','Salem','Highland Park') 
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
+    where ss_customer_sk = c_customer_sk
+      and customer.c_current_addr_sk = current_addr.ca_address_sk
+      and current_addr.ca_city <> bought_city
+  order by c_last_name
+          ,c_first_name
+          ,ca_city
+          ,bought_city
+          ,ss_ticket_number
+  limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,amt,profit 
+ from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,ca_city bought_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics,customer_address 
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and store_sales.ss_addr_sk = customer_address.ca_address_sk
+    and (household_demographics.hd_dep_count = 2 or
+         household_demographics.hd_vehicle_count= 1)
+    and date_dim.d_dow in (6,0)
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_city in ('Cedar Grove','Wildwood','Union','Salem','Highland Park') 
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
+    where ss_customer_sk = c_customer_sk
+      and customer.c_current_addr_sk = current_addr.ca_address_sk
+      and current_addr.ca_city <> bought_city
+  order by c_last_name
+          ,c_first_name
+          ,ca_city
+          ,bought_city
+          ,ss_ticket_number
+  limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], ca_city=[$5], bought_city=[$8], ss_ticket_number=[$6], amt=[$9], profit=[$10])
+    HiveJoin(condition=[AND(<>($5, $8), =($7, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9])
+          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ca_address_sk=[$0], ca_city=[$6])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, customer_address]], table:alias=[current_addr])
+      HiveProject(ss_ticket_number=[$3], ss_customer_sk=[$1], bought_city=[$0], amt=[$4], profit=[$5])
+        HiveAggregate(group=[{1, 3, 5, 7}], agg#0=[sum($8)], agg#1=[sum($9)])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ca_address_sk=[$0], ca_city=[$6])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveJoin(condition=[=($2, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($4, $11)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_coupon_amt=[$19], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($6), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[$6], d_dow=[$7])
+                    HiveFilter(condition=[AND(IN($7, 6, 0), IN($6, 1998, 1999, 2000), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_city=[$22])
+                  HiveFilter(condition=[AND(IN($22, _UTF-16LE'Cedar Grove', _UTF-16LE'Wildwood', _UTF-16LE'Union', _UTF-16LE'Salem', _UTF-16LE'Highland Park'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                HiveFilter(condition=[AND(OR(=($3, 2), =($4, 1)), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out
new file mode 100644
index 0000000..11fd577
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query47.q.out
@@ -0,0 +1,177 @@
+PREHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        s_store_name, s_company_name,
+        d_year, d_moy,
+        sum(ss_sales_price) sum_sales,
+        avg(sum(ss_sales_price)) over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name
+           order by d_year, d_moy) rn
+ from item, store_sales, date_dim, store
+ where ss_item_sk = i_item_sk and
+       ss_sold_date_sk = d_date_sk and
+       ss_store_sk = s_store_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          s_store_name, s_company_name,
+          d_year, d_moy),
+ v2 as(
+ select v1.i_category
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1.s_store_name = v1_lag.s_store_name and
+       v1.s_store_name = v1_lead.s_store_name and
+       v1.s_company_name = v1_lag.s_company_name and
+       v1.s_company_name = v1_lead.s_company_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and    
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with v1 as(
+ select i_category, i_brand,
+        s_store_name, s_company_name,
+        d_year, d_moy,
+        sum(ss_sales_price) sum_sales,
+        avg(sum(ss_sales_price)) over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name
+           order by d_year, d_moy) rn
+ from item, store_sales, date_dim, store
+ where ss_item_sk = i_item_sk and
+       ss_sold_date_sk = d_date_sk and
+       ss_store_sk = s_store_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          s_store_name, s_company_name,
+          d_year, d_moy),
+ v2 as(
+ select v1.i_category
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1.s_store_name = v1_lag.s_store_name and
+       v1.s_store_name = v1_lead.s_store_name and
+       v1.s_company_name = v1_lag.s_company_name and
+       v1.s_company_name = v1_lead.s_company_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and    
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(i_category=[$0], d_year=[$1], d_moy=[$2], avg_monthly_sales=[$3], sum_sales=[$4], psum=[$5], nsum=[$6])
+  HiveSortLimit(sort0=[$7], sort1=[$2], dir0=[ASC], dir1=[ASC], fetch=[100])
+    HiveProject(i_category=[$12], d_year=[$16], d_moy=[$17], avg_monthly_sales=[$19], sum_sales=[$18], psum=[$10], nsum=[$4], (- (tok_table_or_col sum_sales) (tok_table_or_col avg_monthly_sales))=[-($18, $19)])
+      HiveJoin(condition=[AND(AND(AND(AND(=($12, $0), =($13, $1)), =($14, $2)), =($15, $3)), =($20, -($5, 1)))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col s_store_name)=[$2], (tok_table_or_col s_company_name)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$4], rank_window_1=[$5])
+          HiveFilter(condition=[IS NOT NULL($5)])
+            HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4, $5 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+              HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+                HiveAggregate(group=[{1, 2, 8, 9, 11, 12}], agg#0=[sum($6)])
+                  HiveJoin(condition=[=($5, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($8))])
+                          HiveTableScan(table=[[default, item]], table:alias=[item])
+                      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                          HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($7))])
+                            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                        HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                          HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                    HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($5), IS NOT NULL($17))])
+                        HiveTableScan(table=[[default, store]], table:alias=[store])
+        HiveJoin(condition=[AND(AND(AND(AND(=($6, $0), =($7, $1)), =($8, $2)), =($9, $3)), =($14, +($5, 1)))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col s_store_name)=[$2], (tok_table_or_col s_company_name)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$4], rank_window_1=[$5])
+            HiveFilter(condition=[IS NOT NULL($5)])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4, $5 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11, 12}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($8))])
+                            HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                            HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($5), IS NOT NULL($17))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveProject((tok_table_or_col i_category)=[$0], (tok_table_or_col i_brand)=[$1], (tok_table_or_col s_store_name)=[$2], (tok_table_or_col s_company_name)=[$3], (tok_table_or_col d_year)=[$4], (tok_table_or_col d_moy)=[$5], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[$7], rank_window_1=[$8])
+            HiveFilter(condition=[AND(=($4, 2000), >($7, 0), CASE(>($7, 0), >(/(ABS(-($6, $7)), $7), 0.1), null), IS NOT NULL($8))])
+              HiveProject((tok_table_or_col i_category)=[$1], (tok_table_or_col i_brand)=[$0], (tok_table_or_col s_store_name)=[$4], (tok_table_or_col s_company_name)=[$5], (tok_table_or_col d_year)=[$2], (tok_table_or_col d_moy)=[$3], (tok_function sum (tok_table_or_col ss_sales_price))=[$6], avg_window_0=[avg($6) OVER (PARTITION BY $1, $0, $4, $5, $2 ORDER BY $1 NULLS FIRST, $0 NULLS FIRST, $4 NULLS FIRST, $5 NULLS FIRST, $2 NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], rank_window_1=[rank() OVER (PARTITION BY $1, $0, $4, $5 ORDER BY $2 NULLS LAST, $3 NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+                HiveProject(i_brand=[$0], i_category=[$1], d_year=[$2], d_moy=[$3], s_store_name=[$4], s_company_name=[$5], $f6=[$6])
+                  HiveAggregate(group=[{1, 2, 8, 9, 11, 12}], agg#0=[sum($6)])
+                    HiveJoin(condition=[=($5, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(i_item_sk=[$0], i_brand=[$8], i_category=[$12])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($12), IS NOT NULL($8))])
+                            HiveTableScan(table=[[default, item]], table:alias=[item])
+                        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                            HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($0), IS NOT NULL($7))])
+                              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                          HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[$8])
+                            HiveFilter(condition=[AND(IN($6, 2000, 1999, 2001), OR(=($6, 2000), IN(ROW($6, $8), ROW(1999, 12), ROW(2001, 1))), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(s_store_sk=[$0], s_store_name=[$5], s_company_name=[$17])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($5), IS NOT NULL($17))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out
new file mode 100644
index 0000000..feb4012
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query48.q.out
@@ -0,0 +1,164 @@
+PREHOOK: query: explain cbo
+select sum (ss_quantity)
+ from store_sales, store, customer_demographics, customer_address, date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 1998
+ and  
+ (
+  (
+   cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 100.00 and 150.00  
+   )
+ or
+  (
+  cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 50.00 and 100.00   
+  )
+ or 
+ (
+  cd_demo_sk = ss_cdemo_sk
+  and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 150.00 and 200.00  
+ )
+ )
+ and
+ (
+  (
+  ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 0 and 2000  
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 3000 
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 25000 
+  )
+ )
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select sum (ss_quantity)
+ from store_sales, store, customer_demographics, customer_address, date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 1998
+ and  
+ (
+  (
+   cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 100.00 and 150.00  
+   )
+ or
+  (
+  cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 50.00 and 100.00   
+  )
+ or 
+ (
+  cd_demo_sk = ss_cdemo_sk
+  and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 150.00 and 200.00  
+ )
+ )
+ and
+ (
+  (
+  ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 0 and 2000  
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 3000 
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 25000 
+  )
+ )
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveAggregate(group=[{}], agg#0=[sum($13)])
+  HiveJoin(condition=[AND(=($11, $0), OR(AND(IN($1, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM'), BETWEEN(false, $15, 0, 2000)), AND(IN($1, _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN'), BETWEEN(false, $15, 150, 3000)), AND(IN($1, _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), BETWEEN(false, $15, 50, 25000))))], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_country=[CAST(_UTF-16LE'United States'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+      HiveFilter(condition=[AND(IN($8, _UTF-16LE'KY', _UTF-16LE'GA', _UTF-16LE'NM', _UTF-16LE'MT', _UTF-16LE'OR', _UTF-16LE'IN', _UTF-16LE'WI', _UTF-16LE'MO', _UTF-16LE'WV'), =($10, _UTF-16LE'United States'), IS NOT NULL($0))])
+        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+    HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(cd_demo_sk=[$0], cd_marital_status=[CAST(_UTF-16LE'M'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_education_status=[CAST(_UTF-16LE'4 yr Degree'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+        HiveFilter(condition=[AND(=($2, _UTF-16LE'M'), =($3, _UTF-16LE'4 yr Degree'), IS NOT NULL($0))])
+          HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+      HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER])
+          HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
+            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(s_store_sk=[$0])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+          HiveProject(ss_sold_date_sk=[$0], ss_cdemo_sk=[$4], ss_addr_sk=[$6], ss_store_sk=[$7], ss_quantity=[$10], ss_sales_price=[$13], ss_net_profit=[$22])
+            HiveFilter(condition=[AND(OR(BETWEEN(false, $13, 100, 150), BETWEEN(false, $13, 50, 100), BETWEEN(false, $13, 150, 200)), OR(BETWEEN(false, $22, 0, 2000), BETWEEN(false, $22, 150, 3000), BETWEEN(false, $22, 50, 25000)), IS NOT NULL($7), IS NOT NULL($4), IS NOT NULL($6), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+


[67/75] [abbrv] hive git commit: HIVE-20788: Extended SJ reduction may backtrack columns incorrectly when creating filters (Jesus Camacho Rodriguez, reviewed by Deepak Jaiswal)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out
index ff4c05f..b7f9778 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query18.q.out
@@ -99,56 +99,56 @@ Stage-0
     limit:100
     Stage-1
       Reducer 6 vectorized
-      File Output Operator [FS_179]
-        Limit [LIM_178] (rows=100 width=1165)
+      File Output Operator [FS_177]
+        Limit [LIM_176] (rows=100 width=1165)
           Number of rows:100
-          Select Operator [SEL_177] (rows=10969055 width=1165)
+          Select Operator [SEL_175] (rows=10969055 width=1165)
             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
           <-Reducer 5 [SIMPLE_EDGE] vectorized
-            SHUFFLE [RS_176]
-              Select Operator [SEL_175] (rows=10969055 width=1165)
+            SHUFFLE [RS_174]
+              Select Operator [SEL_173] (rows=10969055 width=1165)
                 Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
-                Group By Operator [GBY_174] (rows=10969055 width=1229)
+                Group By Operator [GBY_172] (rows=10969055 width=1229)
                   Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","sum(VALUE._col6)","count(VALUE._col7)","sum(VALUE._col8)","count(VALUE._col9)","sum(VALUE._col10)","count(VALUE._col11)","sum(VALUE._col12)","count(VALUE._col13)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
                 <-Reducer 4 [SIMPLE_EDGE]
                   SHUFFLE [RS_40]
                     PartitionCols:_col0, _col1, _col2, _col3, _col4
                     Group By Operator [GBY_39] (rows=10969055 width=1229)
                       Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18"],aggregations:["sum(_col15)","count(_col15)","sum(_col16)","count(_col16)","sum(_col17)","count(_col17)","sum(_col18)","count(_col18)","sum(_col19)","count(_col19)","sum(_col3)","count(_col3)","sum(_col22)","count(_col22)"],keys:_col5, _col6, _col7, _col10, 0L
-                      Merge Join Operator [MERGEJOIN_142] (rows=2193811 width=811)
+                      Merge Join Operator [MERGEJOIN_140] (rows=2193811 width=811)
                         Conds:RS_35._col0=RS_36._col3(Inner),Output:["_col3","_col5","_col6","_col7","_col10","_col15","_col16","_col17","_col18","_col19","_col22"]
                       <-Reducer 3 [SIMPLE_EDGE]
                         PARTITION_ONLY_SHUFFLE [RS_35]
                           PartitionCols:_col0
-                          Merge Join Operator [MERGEJOIN_138] (rows=4959744 width=368)
-                            Conds:RS_32._col1=RS_150._col0(Inner),Output:["_col0","_col3","_col5","_col6","_col7"]
+                          Merge Join Operator [MERGEJOIN_136] (rows=4959744 width=368)
+                            Conds:RS_32._col1=RS_148._col0(Inner),Output:["_col0","_col3","_col5","_col6","_col7"]
                           <-Map 9 [SIMPLE_EDGE] vectorized
-                            SHUFFLE [RS_150]
+                            SHUFFLE [RS_148]
                               PartitionCols:_col0
-                              Select Operator [SEL_149] (rows=1861800 width=4)
+                              Select Operator [SEL_147] (rows=1861800 width=4)
                                 Output:["_col0"]
                                 TableScan [TS_6] (rows=1861800 width=4)
                                   default@customer_demographics,cd2,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk"]
                           <-Reducer 2 [SIMPLE_EDGE]
                             SHUFFLE [RS_32]
                               PartitionCols:_col1
-                              Merge Join Operator [MERGEJOIN_137] (rows=4890586 width=371)
-                                Conds:RS_145._col2=RS_148._col0(Inner),Output:["_col0","_col1","_col3","_col5","_col6","_col7"]
+                              Merge Join Operator [MERGEJOIN_135] (rows=4890586 width=371)
+                                Conds:RS_143._col2=RS_146._col0(Inner),Output:["_col0","_col1","_col3","_col5","_col6","_col7"]
                               <-Map 1 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_145]
+                                SHUFFLE [RS_143]
                                   PartitionCols:_col2
-                                  Select Operator [SEL_144] (rows=35631408 width=119)
+                                  Select Operator [SEL_142] (rows=35631408 width=119)
                                     Output:["_col0","_col1","_col2","_col3"]
-                                    Filter Operator [FIL_143] (rows=35631408 width=19)
+                                    Filter Operator [FIL_141] (rows=35631408 width=19)
                                       predicate:((c_birth_month) IN (9, 5, 12, 4, 1, 10) and c_current_addr_sk is not null and c_current_cdemo_sk is not null)
                                       TableScan [TS_0] (rows=80000000 width=19)
                                         default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk","c_birth_month","c_birth_year"]
                               <-Map 8 [SIMPLE_EDGE] vectorized
-                                SHUFFLE [RS_148]
+                                SHUFFLE [RS_146]
                                   PartitionCols:_col0
-                                  Select Operator [SEL_147] (rows=5490196 width=285)
+                                  Select Operator [SEL_145] (rows=5490196 width=285)
                                     Output:["_col0","_col1","_col2","_col3"]
-                                    Filter Operator [FIL_146] (rows=5490196 width=285)
+                                    Filter Operator [FIL_144] (rows=5490196 width=285)
                                       predicate:(ca_state) IN ('ND', 'WI', 'AL', 'NC', 'OK', 'MS', 'TN')
                                       TableScan [TS_3] (rows=40000000 width=285)
                                         default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_county","ca_state","ca_country"]
@@ -157,83 +157,83 @@ Stage-0
                           PartitionCols:_col3
                           Select Operator [SEL_28] (rows=15983481 width=735)
                             Output:["_col1","_col3","_col6","_col7","_col8","_col9","_col10","_col13"]
-                            Merge Join Operator [MERGEJOIN_141] (rows=15983481 width=735)
-                              Conds:RS_25._col3=RS_173._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col8","_col11","_col13"]
+                            Merge Join Operator [MERGEJOIN_139] (rows=15983481 width=735)
+                              Conds:RS_25._col3=RS_171._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7","_col8","_col11","_col13"]
                             <-Map 18 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_173]
+                              SHUFFLE [RS_171]
                                 PartitionCols:_col0
-                                Select Operator [SEL_172] (rows=462000 width=104)
+                                Select Operator [SEL_170] (rows=462000 width=104)
                                   Output:["_col0","_col1"]
                                   TableScan [TS_17] (rows=462000 width=104)
                                     default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
                             <-Reducer 12 [SIMPLE_EDGE]
                               SHUFFLE [RS_25]
                                 PartitionCols:_col3
-                                Merge Join Operator [MERGEJOIN_140] (rows=15983481 width=639)
-                                  Conds:RS_22._col2=RS_161._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col11"]
+                                Merge Join Operator [MERGEJOIN_138] (rows=15983481 width=639)
+                                  Conds:RS_22._col2=RS_159._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7","_col8","_col11"]
                                 <-Map 16 [SIMPLE_EDGE] vectorized
-                                  PARTITION_ONLY_SHUFFLE [RS_161]
+                                  PARTITION_ONLY_SHUFFLE [RS_159]
                                     PartitionCols:_col0
-                                    Select Operator [SEL_160] (rows=103433 width=116)
+                                    Select Operator [SEL_158] (rows=103433 width=116)
                                       Output:["_col0","_col1"]
-                                      Filter Operator [FIL_159] (rows=103433 width=187)
+                                      Filter Operator [FIL_157] (rows=103433 width=187)
                                         predicate:((cd_education_status = 'College') and (cd_gender = 'M'))
                                         TableScan [TS_14] (rows=1861800 width=187)
                                           default@customer_demographics,cd1,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_education_status","cd_dep_count"]
                                 <-Reducer 11 [SIMPLE_EDGE]
                                   SHUFFLE [RS_22]
                                     PartitionCols:_col2
-                                    Merge Join Operator [MERGEJOIN_139] (rows=100578970 width=565)
-                                      Conds:RS_171._col0=RS_153._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                    Merge Join Operator [MERGEJOIN_137] (rows=100578970 width=565)
+                                      Conds:RS_169._col0=RS_151._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
                                     <-Map 14 [SIMPLE_EDGE] vectorized
-                                      PARTITION_ONLY_SHUFFLE [RS_153]
+                                      PARTITION_ONLY_SHUFFLE [RS_151]
                                         PartitionCols:_col0
-                                        Select Operator [SEL_152] (rows=652 width=4)
+                                        Select Operator [SEL_150] (rows=652 width=4)
                                           Output:["_col0"]
-                                          Filter Operator [FIL_151] (rows=652 width=8)
+                                          Filter Operator [FIL_149] (rows=652 width=8)
                                             predicate:(d_year = 2001)
                                             TableScan [TS_11] (rows=73049 width=8)
                                               default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
                                     <-Map 10 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_171]
+                                      SHUFFLE [RS_169]
                                         PartitionCols:_col0
-                                        Select Operator [SEL_170] (rows=283692098 width=573)
+                                        Select Operator [SEL_168] (rows=283692098 width=573)
                                           Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
-                                          Filter Operator [FIL_169] (rows=283692098 width=466)
+                                          Filter Operator [FIL_167] (rows=283692098 width=466)
                                             predicate:((cs_bill_cdemo_sk BETWEEN DynamicValue(RS_23_cd1_cd_demo_sk_min) AND DynamicValue(RS_23_cd1_cd_demo_sk_max) and in_bloom_filter(cs_bill_cdemo_sk, DynamicValue(RS_23_cd1_cd_demo_sk_bloom_filter))) and (cs_bill_customer_sk BETWEEN DynamicValue(RS_35_customer_c_customer_sk_min) AND DynamicValue(RS_35_customer_c_customer_sk_max) and in_bloom_filter(cs_bill_customer_sk, DynamicValue(RS_35_customer_c_customer_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_20_date_dim_d_date_sk_min) AND DynamicValue(RS_20_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_20_date_dim_d_date_sk_bloom_filter))) and cs_bill_cdemo_sk is not null and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
                                             TableScan [TS_8] (rows=287989836 width=466)
                                               default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk","cs_bill_cdemo_sk","cs_item_sk","cs_quantity","cs_list_price","cs_sales_price","cs_coupon_amt","cs_net_profit"]
                                             <-Reducer 15 [BROADCAST_EDGE] vectorized
-                                              BROADCAST [RS_158]
-                                                Group By Operator [GBY_157] (rows=1 width=12)
+                                              BROADCAST [RS_156]
+                                                Group By Operator [GBY_155] (rows=1 width=12)
                                                   Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                 <-Map 14 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                  PARTITION_ONLY_SHUFFLE [RS_156]
-                                                    Group By Operator [GBY_155] (rows=1 width=12)
+                                                  PARTITION_ONLY_SHUFFLE [RS_154]
+                                                    Group By Operator [GBY_153] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                      Select Operator [SEL_154] (rows=652 width=4)
+                                                      Select Operator [SEL_152] (rows=652 width=4)
                                                         Output:["_col0"]
-                                                         Please refer to the previous Select Operator [SEL_152]
+                                                         Please refer to the previous Select Operator [SEL_150]
                                             <-Reducer 17 [BROADCAST_EDGE] vectorized
-                                              BROADCAST [RS_166]
-                                                Group By Operator [GBY_165] (rows=1 width=12)
+                                              BROADCAST [RS_164]
+                                                Group By Operator [GBY_163] (rows=1 width=12)
                                                   Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
                                                 <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                  PARTITION_ONLY_SHUFFLE [RS_164]
-                                                    Group By Operator [GBY_163] (rows=1 width=12)
+                                                  PARTITION_ONLY_SHUFFLE [RS_162]
+                                                    Group By Operator [GBY_161] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                      Select Operator [SEL_162] (rows=103433 width=4)
+                                                      Select Operator [SEL_160] (rows=103433 width=4)
                                                         Output:["_col0"]
-                                                         Please refer to the previous Select Operator [SEL_160]
+                                                         Please refer to the previous Select Operator [SEL_158]
                                             <-Reducer 7 [BROADCAST_EDGE] vectorized
-                                              BROADCAST [RS_168]
-                                                Group By Operator [GBY_167] (rows=1 width=12)
+                                              BROADCAST [RS_166]
+                                                Group By Operator [GBY_165] (rows=1 width=12)
                                                   Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=4890586)"]
                                                 <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
-                                                  PARTITION_ONLY_SHUFFLE [RS_123]
-                                                    Group By Operator [GBY_122] (rows=1 width=12)
+                                                  PARTITION_ONLY_SHUFFLE [RS_117]
+                                                    Group By Operator [GBY_116] (rows=1 width=12)
                                                       Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=4890586)"]
-                                                      Select Operator [SEL_121] (rows=4959744 width=4)
+                                                      Select Operator [SEL_115] (rows=4959744 width=4)
                                                         Output:["_col0"]
-                                                         Please refer to the previous Merge Join Operator [MERGEJOIN_138]
+                                                         Please refer to the previous Merge Join Operator [MERGEJOIN_136]
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out
index 7fbbc05..fb77386 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query24.q.out
@@ -1,4 +1,4 @@
-Warning: Shuffle Join MERGEJOIN[287][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[298][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
 PREHOOK: query: explain
 with ssales as
 (select c_last_name
@@ -23,7 +23,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -79,7 +80,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -114,230 +116,248 @@ POSTHOOK: Output: hdfs://### HDFS PATH ###
 Plan optimized by CBO.
 
 Vertex dependency in root stage
-Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
-Map 24 <- Reducer 20 (BROADCAST_EDGE)
-Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
-Reducer 11 <- Map 9 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
-Reducer 12 <- Map 22 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
-Reducer 13 <- Map 23 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
-Reducer 14 <- Reducer 13 (SIMPLE_EDGE)
-Reducer 15 <- Reducer 14 (CUSTOM_SIMPLE_EDGE)
-Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
-Reducer 18 <- Map 16 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
-Reducer 19 <- Map 21 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
-Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
-Reducer 20 <- Map 16 (CUSTOM_SIMPLE_EDGE)
-Reducer 3 <- Map 16 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
-Reducer 4 <- Map 21 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
-Reducer 5 <- Map 22 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
-Reducer 6 <- Map 23 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
-Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
-Reducer 8 <- Reducer 15 (CUSTOM_SIMPLE_EDGE), Reducer 7 (CUSTOM_SIMPLE_EDGE)
+Map 1 <- Reducer 16 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE)
+Map 25 <- Reducer 22 (BROADCAST_EDGE)
+Reducer 10 <- Map 24 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 15 <- Map 23 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Reducer 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 13 (SIMPLE_EDGE), Map 23 (SIMPLE_EDGE)
+Reducer 19 <- Map 25 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 20 <- Map 21 (SIMPLE_EDGE), Reducer 19 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 15 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 24 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 12 (CUSTOM_SIMPLE_EDGE), Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Map 7 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 7 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
 
 Stage-0
   Fetch Operator
     limit:-1
     Stage-1
-      Reducer 8
-      File Output Operator [FS_88]
-        Select Operator [SEL_87] (rows=78393744 width=380)
+      Reducer 6
+      File Output Operator [FS_91]
+        Select Operator [SEL_90] (rows=1313165 width=380)
           Output:["_col0","_col1","_col2","_col3"]
-          Filter Operator [FIL_86] (rows=78393744 width=492)
+          Filter Operator [FIL_89] (rows=1313165 width=492)
             predicate:(_col3 > _col4)
-            Merge Join Operator [MERGEJOIN_287] (rows=235181232 width=492)
+            Merge Join Operator [MERGEJOIN_298] (rows=3939496 width=492)
               Conds:(Inner),Output:["_col0","_col1","_col2","_col3","_col4"]
-            <-Reducer 15 [CUSTOM_SIMPLE_EDGE] vectorized
-              PARTITION_ONLY_SHUFFLE [RS_340]
-                Select Operator [SEL_339] (rows=1 width=112)
+            <-Reducer 12 [CUSTOM_SIMPLE_EDGE] vectorized
+              PARTITION_ONLY_SHUFFLE [RS_350]
+                Select Operator [SEL_349] (rows=1 width=112)
                   Output:["_col0"]
-                  Group By Operator [GBY_338] (rows=1 width=120)
+                  Group By Operator [GBY_348] (rows=1 width=120)
                     Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"]
-                  <-Reducer 14 [CUSTOM_SIMPLE_EDGE] vectorized
-                    PARTITION_ONLY_SHUFFLE [RS_337]
-                      Group By Operator [GBY_336] (rows=1 width=120)
+                  <-Reducer 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                    PARTITION_ONLY_SHUFFLE [RS_347]
+                      Group By Operator [GBY_346] (rows=1 width=120)
                         Output:["_col0","_col1"],aggregations:["sum(_col10)","count(_col10)"]
-                        Select Operator [SEL_335] (rows=2121289008973 width=932)
+                        Select Operator [SEL_345] (rows=8029453 width=932)
                           Output:["_col10"]
-                          Group By Operator [GBY_334] (rows=2121289008973 width=932)
+                          Group By Operator [GBY_344] (rows=8029453 width=932)
                             Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8, KEY._col9
-                          <-Reducer 13 [SIMPLE_EDGE]
-                            SHUFFLE [RS_75]
+                          <-Reducer 10 [SIMPLE_EDGE]
+                            SHUFFLE [RS_78]
                               PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9
-                              Group By Operator [GBY_74] (rows=2121289008973 width=932)
-                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col4)"],keys:_col10, _col11, _col6, _col7, _col14, _col15, _col16, _col17, _col18, _col21
-                                Merge Join Operator [MERGEJOIN_286] (rows=2121289008973 width=932)
-                                  Conds:RS_70._col12, _col8=RS_323._col2, _col1(Inner),Output:["_col4","_col6","_col7","_col10","_col11","_col14","_col15","_col16","_col17","_col18","_col21"]
-                                <-Map 23 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_323]
-                                    PartitionCols:_col2, _col1
-                                    Select Operator [SEL_321] (rows=40000000 width=359)
-                                      Output:["_col0","_col1","_col2"]
-                                      Filter Operator [FIL_320] (rows=40000000 width=272)
-                                        predicate:(ca_zip is not null and upper(ca_country) is not null)
-                                        TableScan [TS_14] (rows=40000000 width=272)
-                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_state","ca_zip","ca_country"]
-                                <-Reducer 12 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_70]
-                                    PartitionCols:_col12, _col8
-                                    Merge Join Operator [MERGEJOIN_285] (rows=537799796 width=1023)
-                                      Conds:RS_67._col0, _col3=RS_319._col0, _col1(Inner),Output:["_col4","_col6","_col7","_col8","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col18"]
-                                    <-Map 22 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_319]
-                                        PartitionCols:_col0, _col1
-                                        Select Operator [SEL_317] (rows=57591150 width=8)
-                                          Output:["_col0","_col1"]
-                                          TableScan [TS_12] (rows=57591150 width=8)
-                                            default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number"]
-                                    <-Reducer 11 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_67]
-                                        PartitionCols:_col0, _col3
-                                        Merge Join Operator [MERGEJOIN_284] (rows=385681992 width=1029)
-                                          Conds:RS_64._col0=RS_291._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col8","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col18"]
-                                        <-Map 9 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_291]
-                                            PartitionCols:_col0
-                                            Select Operator [SEL_289] (rows=462000 width=384)
-                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
-                                              TableScan [TS_3] (rows=462000 width=384)
-                                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_size","i_color","i_units","i_manager_id"]
-                                        <-Reducer 19 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_64]
-                                            PartitionCols:_col0
-                                            Merge Join Operator [MERGEJOIN_283] (rows=385681992 width=648)
-                                              Conds:RS_61._col1=RS_316._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col8","_col10","_col11","_col12"]
-                                            <-Map 21 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_316]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_314] (rows=80000000 width=276)
-                                                  Output:["_col0","_col1","_col2","_col3"]
-                                                  Filter Operator [FIL_313] (rows=80000000 width=276)
-                                                    predicate:c_birth_country is not null
-                                                    TableScan [TS_9] (rows=80000000 width=276)
-                                                      default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_first_name","c_last_name","c_birth_country"]
-                                            <-Reducer 18 [SIMPLE_EDGE]
-                                              SHUFFLE [RS_61]
-                                                PartitionCols:_col1
-                                                Merge Join Operator [MERGEJOIN_282] (rows=385681992 width=379)
-                                                  Conds:RS_333._col2=RS_302._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col6","_col7","_col8"]
-                                                <-Map 16 [SIMPLE_EDGE] vectorized
-                                                  SHUFFLE [RS_302]
-                                                    PartitionCols:_col0
-                                                    Select Operator [SEL_299] (rows=155 width=267)
-                                                      Output:["_col0","_col1","_col2","_col3"]
-                                                      Filter Operator [FIL_298] (rows=155 width=271)
-                                                        predicate:((s_market_id = 7) and s_zip is not null)
-                                                        TableScan [TS_6] (rows=1704 width=270)
-                                                          default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_market_id","s_state","s_zip"]
-                                                <-Map 24 [SIMPLE_EDGE] vectorized
-                                                  SHUFFLE [RS_333]
-                                                    PartitionCols:_col2
-                                                    Select Operator [SEL_332] (rows=525333486 width=122)
-                                                      Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                      Filter Operator [FIL_331] (rows=525333486 width=122)
-                                                        predicate:((ss_store_sk BETWEEN DynamicValue(RS_59_store_s_store_sk_min) AND DynamicValue(RS_59_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_59_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_store_sk is not null)
-                                                        TableScan [TS_42] (rows=575995635 width=122)
-                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
-                                                        <-Reducer 20 [BROADCAST_EDGE] vectorized
-                                                          BROADCAST [RS_330]
-                                                            Group By Operator [GBY_329] (rows=1 width=12)
-                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                            <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                              SHUFFLE [RS_307]
-                                                                Group By Operator [GBY_305] (rows=1 width=12)
-                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                                  Select Operator [SEL_303] (rows=155 width=4)
-                                                                    Output:["_col0"]
-                                                                     Please refer to the previous Select Operator [SEL_299]
-            <-Reducer 7 [CUSTOM_SIMPLE_EDGE] vectorized
-              PARTITION_ONLY_SHUFFLE [RS_328]
-                Select Operator [SEL_327] (rows=235181232 width=380)
-                  Output:["_col0","_col1","_col2","_col3"]
-                  Group By Operator [GBY_326] (rows=235181232 width=380)
-                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col9)"],keys:_col1, _col2, _col7
-                    Select Operator [SEL_325] (rows=365777643230 width=843)
-                      Output:["_col1","_col2","_col7","_col9"]
-                      Group By Operator [GBY_324] (rows=365777643230 width=843)
-                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8
-                      <-Reducer 6 [SIMPLE_EDGE]
-                        SHUFFLE [RS_34]
-                          PartitionCols:_col0, _col1, _col2
-                          Group By Operator [GBY_33] (rows=365777643230 width=843)
-                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(_col4)"],keys:_col15, _col16, _col11, _col20, _col6, _col7, _col8, _col9, _col12
-                            Merge Join Operator [MERGEJOIN_281] (rows=365777643230 width=843)
-                              Conds:RS_29._col13, _col17=RS_322._col1, _col2(Inner),Output:["_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col15","_col16","_col20"]
-                            <-Map 23 [SIMPLE_EDGE] vectorized
-                              SHUFFLE [RS_322]
-                                PartitionCols:_col1, _col2
-                                 Please refer to the previous Select Operator [SEL_321]
-                            <-Reducer 5 [SIMPLE_EDGE]
-                              SHUFFLE [RS_29]
-                                PartitionCols:_col13, _col17
-                                Merge Join Operator [MERGEJOIN_280] (rows=92733777 width=910)
-                                  Conds:RS_26._col0, _col3=RS_318._col0, _col1(Inner),Output:["_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col15","_col16","_col17"]
-                                <-Map 22 [SIMPLE_EDGE] vectorized
-                                  SHUFFLE [RS_318]
+                              Group By Operator [GBY_77] (rows=8029453 width=932)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"],aggregations:["sum(_col13)"],keys:_col2, _col3, _col6, _col15, _col16, _col19, _col20, _col21, _col22, _col23
+                                Merge Join Operator [MERGEJOIN_297] (rows=13238221 width=865)
+                                  Conds:RS_73._col9, _col12=RS_333._col0, _col1(Inner),Output:["_col2","_col3","_col6","_col13","_col15","_col16","_col19","_col20","_col21","_col22","_col23"]
+                                <-Map 24 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_333]
                                     PartitionCols:_col0, _col1
-                                     Please refer to the previous Select Operator [SEL_317]
-                                <-Reducer 4 [SIMPLE_EDGE]
-                                  SHUFFLE [RS_26]
-                                    PartitionCols:_col0, _col3
-                                    Merge Join Operator [MERGEJOIN_279] (rows=56246341 width=899)
-                                      Conds:RS_23._col1=RS_315._col0(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col15","_col16","_col17"]
-                                    <-Map 21 [SIMPLE_EDGE] vectorized
-                                      SHUFFLE [RS_315]
+                                    Select Operator [SEL_331] (rows=57591150 width=8)
+                                      Output:["_col0","_col1"]
+                                      TableScan [TS_23] (rows=57591150 width=8)
+                                        default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number"]
+                                <-Reducer 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_73]
+                                    PartitionCols:_col9, _col12
+                                    Merge Join Operator [MERGEJOIN_296] (rows=8029453 width=828)
+                                      Conds:RS_70._col9=RS_302._col0(Inner),Output:["_col2","_col3","_col6","_col9","_col12","_col13","_col15","_col16","_col19","_col20","_col21","_col22","_col23"]
+                                    <-Map 7 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_302]
                                         PartitionCols:_col0
-                                         Please refer to the previous Select Operator [SEL_314]
-                                    <-Reducer 3 [SIMPLE_EDGE]
-                                      SHUFFLE [RS_23]
-                                        PartitionCols:_col1
-                                        Merge Join Operator [MERGEJOIN_278] (rows=56246341 width=630)
-                                          Conds:RS_20._col2=RS_300._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col6","_col7","_col8","_col9","_col11","_col12","_col13"]
-                                        <-Map 16 [SIMPLE_EDGE] vectorized
-                                          SHUFFLE [RS_300]
-                                            PartitionCols:_col0
-                                             Please refer to the previous Select Operator [SEL_299]
-                                        <-Reducer 2 [SIMPLE_EDGE]
-                                          SHUFFLE [RS_20]
-                                            PartitionCols:_col2
-                                            Merge Join Operator [MERGEJOIN_277] (rows=76612563 width=382)
-                                              Conds:RS_312._col0=RS_292._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col6","_col7","_col8","_col9"]
-                                            <-Map 9 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_292]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_290] (rows=7000 width=295)
-                                                  Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                  Filter Operator [FIL_288] (rows=7000 width=384)
-                                                    predicate:(i_color = 'orchid')
-                                                     Please refer to the previous TableScan [TS_3]
-                                            <-Map 1 [SIMPLE_EDGE] vectorized
-                                              SHUFFLE [RS_312]
-                                                PartitionCols:_col0
-                                                Select Operator [SEL_311] (rows=525333486 width=122)
+                                        Select Operator [SEL_300] (rows=462000 width=384)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                          TableScan [TS_3] (rows=462000 width=384)
+                                            default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_size","i_color","i_units","i_manager_id"]
+                                    <-Reducer 20 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_70]
+                                        PartitionCols:_col9
+                                        Merge Join Operator [MERGEJOIN_295] (rows=8029453 width=448)
+                                          Conds:RS_67._col7, _col11=RS_316._col3, _col0(Inner),Output:["_col2","_col3","_col6","_col9","_col12","_col13","_col15","_col16"]
+                                        <-Map 21 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_316]
+                                            PartitionCols:_col3, _col0
+                                            Select Operator [SEL_314] (rows=155 width=267)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_313] (rows=155 width=271)
+                                                predicate:((s_market_id = 7) and s_zip is not null)
+                                                TableScan [TS_9] (rows=1704 width=270)
+                                                  default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_market_id","s_state","s_zip"]
+                                        <-Reducer 19 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_67]
+                                            PartitionCols:_col7, _col11
+                                            Merge Join Operator [MERGEJOIN_294] (rows=525333486 width=473)
+                                              Conds:RS_64._col0=RS_343._col1(Inner),Output:["_col2","_col3","_col6","_col7","_col9","_col11","_col12","_col13"]
+                                            <-Map 25 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_343]
+                                                PartitionCols:_col1
+                                                Select Operator [SEL_342] (rows=525333486 width=122)
                                                   Output:["_col0","_col1","_col2","_col3","_col4"]
-                                                  Filter Operator [FIL_310] (rows=525333486 width=122)
-                                                    predicate:((ss_item_sk BETWEEN DynamicValue(RS_18_item_i_item_sk_min) AND DynamicValue(RS_18_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_18_item_i_item_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_21_store_s_store_sk_min) AND DynamicValue(RS_21_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_21_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_store_sk is not null)
-                                                    TableScan [TS_0] (rows=575995635 width=122)
+                                                  Filter Operator [FIL_341] (rows=525333486 width=122)
+                                                    predicate:((ss_store_sk BETWEEN DynamicValue(RS_68_store_s_store_sk_min) AND DynamicValue(RS_68_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_68_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_store_sk is not null)
+                                                    TableScan [TS_50] (rows=575995635 width=122)
                                                       default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
-                                                    <-Reducer 10 [BROADCAST_EDGE] vectorized
-                                                      BROADCAST [RS_297]
-                                                        Group By Operator [GBY_296] (rows=1 width=12)
+                                                    <-Reducer 22 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_340]
+                                                        Group By Operator [GBY_339] (rows=1 width=12)
                                                           Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                        <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                          SHUFFLE [RS_295]
-                                                            Group By Operator [GBY_294] (rows=1 width=12)
+                                                        <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_319]
+                                                            Group By Operator [GBY_318] (rows=1 width=12)
                                                               Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                              Select Operator [SEL_293] (rows=7000 width=4)
+                                                              Select Operator [SEL_317] (rows=155 width=4)
                                                                 Output:["_col0"]
-                                                                 Please refer to the previous Select Operator [SEL_290]
-                                                    <-Reducer 17 [BROADCAST_EDGE] vectorized
-                                                      BROADCAST [RS_309]
-                                                        Group By Operator [GBY_308] (rows=1 width=12)
-                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
-                                                        <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
-                                                          SHUFFLE [RS_306]
-                                                            Group By Operator [GBY_304] (rows=1 width=12)
-                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
-                                                              Select Operator [SEL_301] (rows=155 width=4)
-                                                                Output:["_col0"]
-                                                                 Please refer to the previous Select Operator [SEL_299]
+                                                                 Please refer to the previous Select Operator [SEL_314]
+                                            <-Reducer 18 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_64]
+                                                PartitionCols:_col0
+                                                Filter Operator [FIL_63] (rows=80000000 width=635)
+                                                  predicate:(_col4 <> _col8)
+                                                  Merge Join Operator [MERGEJOIN_293] (rows=80000000 width=635)
+                                                    Conds:RS_323._col1=RS_312._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col6","_col7","_col8"]
+                                                  <-Map 13 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_312]
+                                                      PartitionCols:_col0
+                                                      Select Operator [SEL_310] (rows=40000000 width=363)
+                                                        Output:["_col0","_col1","_col2","_col3"]
+                                                        Filter Operator [FIL_309] (rows=40000000 width=276)
+                                                          predicate:ca_zip is not null
+                                                          TableScan [TS_6] (rows=40000000 width=276)
+                                                            default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state","ca_zip","ca_country"]
+                                                  <-Map 23 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_323]
+                                                      PartitionCols:_col1
+                                                      Select Operator [SEL_321] (rows=80000000 width=280)
+                                                        Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                        Filter Operator [FIL_320] (rows=80000000 width=280)
+                                                          predicate:c_current_addr_sk is not null
+                                                          TableScan [TS_12] (rows=80000000 width=280)
+                                                            default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk","c_first_name","c_last_name","c_birth_country"]
+            <-Reducer 5 [CUSTOM_SIMPLE_EDGE] vectorized
+              PARTITION_ONLY_SHUFFLE [RS_338]
+                Select Operator [SEL_337] (rows=3939496 width=380)
+                  Output:["_col0","_col1","_col2","_col3"]
+                  Group By Operator [GBY_336] (rows=3939496 width=380)
+                    Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col9)"],keys:_col4, _col5, _col7
+                    Select Operator [SEL_335] (rows=84010488 width=843)
+                      Output:["_col4","_col5","_col7","_col9"]
+                      Group By Operator [GBY_334] (rows=84010488 width=843)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8
+                      <-Reducer 4 [SIMPLE_EDGE]
+                        SHUFFLE [RS_36]
+                          PartitionCols:_col0, _col1, _col2
+                          Group By Operator [GBY_35] (rows=84010488 width=843)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"],aggregations:["sum(_col4)"],keys:_col12, _col13, _col20, _col6, _col7, _col8, _col9, _col16, _col21
+                            Merge Join Operator [MERGEJOIN_292] (rows=138508741 width=824)
+                              Conds:RS_31._col0, _col3=RS_332._col0, _col1(Inner),Output:["_col4","_col6","_col7","_col8","_col9","_col12","_col13","_col16","_col20","_col21"]
+                            <-Map 24 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_332]
+                                PartitionCols:_col0, _col1
+                                 Please refer to the previous Select Operator [SEL_331]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_31]
+                                PartitionCols:_col0, _col3
+                                Merge Join Operator [MERGEJOIN_291] (rows=84010488 width=820)
+                                  Conds:RS_28._col1, _col2=RS_29._col0, _col9(Inner),Output:["_col0","_col3","_col4","_col6","_col7","_col8","_col9","_col12","_col13","_col16","_col20","_col21"]
+                                <-Reducer 15 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_29]
+                                    PartitionCols:_col0, _col9
+                                    Select Operator [SEL_22] (rows=7276996 width=724)
+                                      Output:["_col0","_col2","_col3","_col6","_col9","_col10","_col11"]
+                                      Filter Operator [FIL_21] (rows=7276996 width=724)
+                                        predicate:(_col12 <> _col3)
+                                        Merge Join Operator [MERGEJOIN_290] (rows=7276996 width=724)
+                                          Conds:RS_18._col0=RS_322._col1(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col8","_col10","_col11","_col12"]
+                                        <-Map 23 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_322]
+                                            PartitionCols:_col1
+                                             Please refer to the previous Select Operator [SEL_321]
+                                        <-Reducer 14 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_18]
+                                            PartitionCols:_col0
+                                            Merge Join Operator [MERGEJOIN_289] (rows=611379 width=452)
+                                              Conds:RS_311._col2=RS_315._col3(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6"]
+                                            <-Map 21 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_315]
+                                                PartitionCols:_col3
+                                                 Please refer to the previous Select Operator [SEL_314]
+                                            <-Map 13 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_311]
+                                                PartitionCols:_col2
+                                                 Please refer to the previous Select Operator [SEL_310]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_28]
+                                    PartitionCols:_col1, _col2
+                                    Merge Join Operator [MERGEJOIN_288] (rows=76612563 width=382)
+                                      Conds:RS_330._col0=RS_303._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col6","_col7","_col8","_col9"]
+                                    <-Map 7 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_303]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_301] (rows=7000 width=295)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                          Filter Operator [FIL_299] (rows=7000 width=384)
+                                            predicate:(i_color = 'orchid')
+                                             Please refer to the previous TableScan [TS_3]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_330]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_329] (rows=525333486 width=122)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                          Filter Operator [FIL_328] (rows=525333486 width=122)
+                                            predicate:((ss_customer_sk BETWEEN DynamicValue(RS_29_customer_c_customer_sk_min) AND DynamicValue(RS_29_customer_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_29_customer_c_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_26_item_i_item_sk_min) AND DynamicValue(RS_26_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_26_item_i_item_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_29_store_s_store_sk_min) AND DynamicValue(RS_29_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_29_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_store_sk is not null)
+                                            TableScan [TS_0] (rows=575995635 width=122)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number","ss_sales_price"]
+                                            <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_325]
+                                                Group By Operator [GBY_324] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=6636187)"]
+                                                <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                  SHUFFLE [RS_149]
+                                                    Group By Operator [GBY_148] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=6636187)"]
+                                                      Select Operator [SEL_147] (rows=7276996 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_22]
+                                            <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_327]
+                                                Group By Operator [GBY_326] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Reducer 15 [CUSTOM_SIMPLE_EDGE]
+                                                  SHUFFLE [RS_154]
+                                                    Group By Operator [GBY_153] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_152] (rows=7276996 width=8)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_22]
+                                            <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_308]
+                                                Group By Operator [GBY_307] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_306]
+                                                    Group By Operator [GBY_305] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_304] (rows=7000 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_301]
 


[75/75] [abbrv] hive git commit: HIVE-20605 : Merge branch 'master' into master-tez092

Posted by se...@apache.org.
HIVE-20605 : Merge branch 'master' into master-tez092


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/c55347d5
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/c55347d5
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/c55347d5

Branch: refs/heads/master-tez092
Commit: c55347d5283fc89ed073f30f61ec87e3092ca2ce
Parents: 8151911 1002e89
Author: sergey <se...@apache.org>
Authored: Fri Oct 26 14:10:20 2018 -0700
Committer: sergey <se...@apache.org>
Committed: Fri Oct 26 14:10:20 2018 -0700

----------------------------------------------------------------------
 .../positive/accumulo_predicate_pushdown.q.out  |    40 +
 .../results/positive/accumulo_queries.q.out     |    22 +
 .../accumulo_single_sourced_multi_insert.q.out  |     6 +
 .../java/org/apache/hive/beeline/BeeLine.java   |    57 +-
 .../org/apache/hive/beeline/BeeLineOpts.java    |    10 +
 beeline/src/main/resources/BeeLine.properties   |     1 +
 .../org/apache/hadoop/hive/cli/CliDriver.java   |     6 +
 .../hadoop/hive/cli/TestCliDriverMethods.java   |     3 +
 .../hadoop/hive/common/GcTimeMonitor.java       |   261 +
 .../org/apache/hadoop/hive/common/LogUtils.java |    25 +
 .../org/apache/hadoop/hive/conf/Constants.java  |    20 +-
 .../org/apache/hadoop/hive/conf/HiveConf.java   |    95 +-
 .../hive/contrib/serde2/MultiDelimitSerDe.java  |   308 -
 .../results/clientnegative/serde_regex.q.out    |     4 +
 .../test/results/clientpositive/dboutput.q.out  |     8 +
 .../clientpositive/fileformat_base64.q.out      |     4 +
 .../results/clientpositive/serde_regex.q.out    |     4 +
 .../clientpositive/serde_typedbytes.q.out       |     4 +
 .../clientpositive/serde_typedbytes2.q.out      |     4 +
 .../clientpositive/serde_typedbytes3.q.out      |     4 +
 .../clientpositive/serde_typedbytes4.q.out      |     4 +
 .../clientpositive/serde_typedbytes5.q.out      |     4 +
 .../clientpositive/udaf_example_avg.q.out       |     4 +
 .../udaf_example_group_concat.q.out             |     4 +
 .../clientpositive/udaf_example_max.q.out       |     4 +
 .../clientpositive/udaf_example_max_n.q.out     |     4 +
 .../clientpositive/udaf_example_min.q.out       |     4 +
 .../clientpositive/udaf_example_min_n.q.out     |     4 +
 .../clientpositive/udf_example_add.q.out        |     4 +
 .../udf_example_arraymapstruct.q.out            |     4 +
 .../clientpositive/udf_example_format.q.out     |     4 +
 .../clientpositive/udf_row_sequence.q.out       |     4 +
 .../vector_udf_example_arraymapstruct.q.out     |     4 +
 data/conf/hive-site.xml                         |    10 +
 data/conf/perf-reg/spark/hive-site.xml          |     7 +-
 data/conf/perf-reg/tez/hive-site.xml            |    17 +-
 data/conf/spark/standalone/hive-site.xml        |     7 +-
 data/files/exported_table/_metadata             |     2 +-
 ...307-b382b8c7-271c-4025-be64-4a68f4db32e5_0_0 |   Bin 0 -> 501 bytes
 ...307-b382b8c7-271c-4025-be64-4a68f4db32e5_1_0 |   Bin 0 -> 465 bytes
 data/files/test.jceks                           |   Bin 0 -> 988 bytes
 data/scripts/q_perf_test_init.sql               |    96 +-
 data/scripts/q_perf_test_init_constraints.sql   |   771 +
 .../hadoop/hive/druid/DruidStorageHandler.java  |     1 +
 .../hive/druid/DruidStorageHandlerUtils.java    |     7 +-
 .../druid/io/DruidQueryBasedInputFormat.java    |    31 +-
 .../hadoop/hive/druid/serde/DruidSerDe.java     |     8 +-
 .../TestHiveDruidQueryBasedInputFormat.java     |     8 +-
 .../hadoop/hive/druid/serde/TestDruidSerDe.java |    34 +
 hbase-handler/pom.xml                           |    12 +-
 .../hive/hbase/HiveHBaseTableOutputFormat.java  |    64 +-
 .../hbase/TestHiveHBaseTableOutputFormat.java   |    38 +
 .../results/positive/external_table_ppd.q.out   |     4 +
 .../results/positive/hbase_custom_key2.q.out    |    12 +
 .../results/positive/hbase_custom_key3.q.out    |    16 +
 .../src/test/results/positive/hbase_ddl.q.out   |     4 +
 .../results/positive/hbase_ppd_key_range.q.out  |    40 +
 .../test/results/positive/hbase_pushdown.q.out  |    36 +
 .../test/results/positive/hbase_queries.q.out   |    22 +
 .../hbase_single_sourced_multi_insert.q.out     |     6 +
 .../test/results/positive/hbase_timestamp.q.out |    16 +
 .../src/test/results/positive/hbasestats.q.out  |    12 +
 .../test/results/positive/ppd_key_ranges.q.out  |    16 +
 .../listener/DbNotificationListener.java        |   353 +-
 .../json/JSONCreateFunctionMessage.java         |     3 +-
 .../messaging/json/JSONDropFunctionMessage.java |     3 +-
 .../messaging/json/JSONMessageFactory.java      |    39 +-
 hcatalog/webhcat/svr/pom.xml                    |    10 +-
 .../listener/DummyRawStoreFailEvent.java        |     9 +
 .../listener/TestDbNotificationListener.java    |   159 +-
 .../test/results/clientpositive/explain.q.out   |     4 +
 .../insert_into_dynamic_partitions.q.out        |   129 +-
 .../clientpositive/insert_into_table.q.out      |     4 +
 .../insert_overwrite_directory.q.out            |    10 +
 .../insert_overwrite_dynamic_partitions.q.out   |   129 +-
 .../clientpositive/insert_overwrite_table.q.out |     4 +
 .../clientpositive/orc_format_part.q.out        |    14 +-
 .../orc_nonstd_partitions_loc.q.out             |     8 +-
 .../clientpositive/parquet_format_part.q.out    |    14 +-
 .../parquet_nonstd_partitions_loc.q.out         |     8 +-
 .../clientpositive/rcfile_format_part.q.out     |    14 +-
 .../rcfile_nonstd_partitions_loc.q.out          |     6 +-
 .../write_final_output_blobstore.q.out          |     8 +
 .../apache/hadoop/hive/ql/TestAcidOnTez.java    |    45 +
 .../hadoop/hive/ql/TestLocationQueries.java     |     6 +-
 .../apache/hadoop/hive/ql/TestMTQueries.java    |     2 +-
 .../ql/exec/spark/TestSparkSessionTimeout.java  |    45 +-
 .../TestReplAcidTablesWithJsonMessage.java      |    43 +
 ...eplAcrossInstancesWithJsonMessageFormat.java |    45 +
 ...ncrementalLoadAcidTablesWithJsonMessage.java |    46 +
 .../ql/parse/TestReplWithJsonMessageFormat.java |    39 +
 .../hive/ql/parse/TestReplicationScenarios.java |   184 +-
 .../TestReplicationScenariosAcidTables.java     |    67 +-
 ...TestReplicationScenariosAcrossInstances.java |   195 +-
 ...ationScenariosIncrementalLoadAcidTables.java |    55 +-
 .../hadoop/hive/ql/parse/WarehouseInstance.java |    19 +-
 .../TestAuthorizationPreEventListener.java      |     3 +
 .../TestMetastoreAuthorizationProvider.java     |     3 +
 .../hive/ql/txn/compactor/TestCompactor.java    |    10 +-
 .../hive/jdbc/TestJdbcWithMiniLlapArrow.java    |   157 +-
 .../jdbc/TestTriggersTezSessionPoolManager.java |     4 +
 .../miniHS2/TestHs2ConnectionMetricsBinary.java |     7 +
 .../miniHS2/TestHs2ConnectionMetricsHttp.java   |     8 +-
 .../service/cli/session/TestQueryDisplay.java   |    83 +
 .../thrift/TestThriftCLIServiceSecurity.java    |    44 +
 itests/qtest-druid/pom.xml                      |     7 +-
 .../hadoop/hive/cli/TestTezPerfCliDriver.java   |     2 +-
 .../cli/TestTezPerfConstraintsCliDriver.java    |    73 +
 .../test/resources/testconfiguration.properties |   116 +-
 .../hadoop/hive/accumulo/AccumuloQTestUtil.java |    16 +-
 .../hadoop/hive/accumulo/AccumuloTestSetup.java |    21 +-
 .../control/AbstractCoreBlobstoreCliDriver.java |    17 +-
 .../hadoop/hive/cli/control/CliConfigs.java     |    22 +-
 .../hive/cli/control/CoreAccumuloCliDriver.java |    25 +-
 .../cli/control/CoreBlobstoreCliDriver.java     |     2 +-
 .../control/CoreBlobstoreNegativeCliDriver.java |     2 +-
 .../hadoop/hive/cli/control/CoreCliDriver.java  |    23 +-
 .../hive/cli/control/CoreCompareCliDriver.java  |    20 +-
 .../hadoop/hive/cli/control/CoreDummy.java      |     4 +-
 .../hive/cli/control/CoreHBaseCliDriver.java    |     7 +-
 .../cli/control/CoreHBaseNegativeCliDriver.java |     6 +-
 .../hive/cli/control/CoreNegativeCliDriver.java |    24 +-
 .../hive/cli/control/CorePerfCliDriver.java     |    20 +-
 .../hadoop/hive/hbase/HBaseQTestUtil.java       |    11 +-
 .../hadoop/hive/hbase/HBaseTestSetup.java       |     1 +
 .../apache/hadoop/hive/ql/QTestArguments.java   |    55 +-
 .../org/apache/hadoop/hive/ql/QTestUtil.java    |   176 +-
 .../hadoop/hive/ql/parse/CoreParseNegative.java |    25 +-
 jdbc-handler/pom.xml                            |    14 +
 .../hive/storage/jdbc/JdbcInputFormat.java      |   117 +-
 .../hive/storage/jdbc/JdbcInputSplit.java       |    73 +-
 .../hive/storage/jdbc/JdbcRecordReader.java     |     3 +-
 .../org/apache/hive/storage/jdbc/JdbcSerDe.java |   187 +-
 .../storage/jdbc/conf/JdbcStorageConfig.java    |    25 +-
 .../jdbc/conf/JdbcStorageConfigManager.java     |    55 +-
 .../hive/storage/jdbc/dao/DatabaseAccessor.java |    10 +-
 .../jdbc/dao/GenericJdbcDatabaseAccessor.java   |   184 +-
 .../storage/jdbc/dao/JdbcRecordIterator.java    |   129 +-
 .../jdbc/dao/JethroDatabaseAccessor.java        |     3 +-
 .../storage/jdbc/dao/MySqlDatabaseAccessor.java |    16 +-
 .../jdbc/spitter/DateIntervalSplitter.java      |    42 +
 .../jdbc/spitter/DecimalIntervalSplitter.java   |    50 +
 .../jdbc/spitter/DoubleIntervalSplitter.java    |    41 +
 .../storage/jdbc/spitter/IntervalSplitter.java  |    24 +
 .../jdbc/spitter/IntervalSplitterFactory.java   |    45 +
 .../jdbc/spitter/LongIntervalSpitter.java       |    42 +
 .../jdbc/spitter/TimestampIntervalSplitter.java |    43 +
 .../hive/storage/jdbc/TestJdbcInputFormat.java  |   219 +-
 .../dao/TestGenericJdbcDatabaseAccessor.java    |    18 +-
 .../org/apache/hive/jdbc/HiveConnection.java    |    92 +-
 .../apache/hive/jdbc/HiveQueryResultSet.java    |    11 +-
 .../jdbc/HttpKerberosRequestInterceptor.java    |    23 +-
 jdbc/src/java/org/apache/hive/jdbc/Utils.java   |     2 +-
 kafka-handler/README.md                         |   217 +
 kafka-handler/pom.xml                           |    28 +-
 .../hadoop/hive/kafka/GenericKafkaSerDe.java    |   162 -
 .../hadoop/hive/kafka/HiveKafkaProducer.java    |   256 +
 .../hadoop/hive/kafka/KafkaInputFormat.java     |   208 +
 .../hadoop/hive/kafka/KafkaInputSplit.java      |   209 +
 .../hadoop/hive/kafka/KafkaJsonSerDe.java       |    15 +-
 .../hadoop/hive/kafka/KafkaOutputFormat.java    |   109 +
 .../hive/kafka/KafkaPullerInputFormat.java      |   205 -
 .../hive/kafka/KafkaPullerInputSplit.java       |   213 -
 .../hive/kafka/KafkaPullerRecordReader.java     |   173 -
 .../hadoop/hive/kafka/KafkaRecordIterator.java  |    75 +-
 .../hadoop/hive/kafka/KafkaRecordReader.java    |   169 +
 .../hadoop/hive/kafka/KafkaRecordWritable.java  |   209 -
 .../hadoop/hive/kafka/KafkaScanTrimmer.java     |    83 +-
 .../apache/hadoop/hive/kafka/KafkaSerDe.java    |   380 +
 .../hadoop/hive/kafka/KafkaStorageHandler.java  |   320 +-
 .../hadoop/hive/kafka/KafkaStreamingUtils.java  |   255 -
 .../hadoop/hive/kafka/KafkaTableProperties.java |    84 +
 .../apache/hadoop/hive/kafka/KafkaUtils.java    |   303 +
 .../apache/hadoop/hive/kafka/KafkaWritable.java |   177 +
 .../hadoop/hive/kafka/MetadataColumn.java       |   110 +
 .../apache/hadoop/hive/kafka/RetryUtils.java    |   154 +
 .../hadoop/hive/kafka/SimpleKafkaWriter.java    |   170 +
 .../hive/kafka/TransactionalKafkaWriter.java    |   363 +
 .../hive/kafka/HiveKafkaProducerTest.java       |   179 +
 .../hadoop/hive/kafka/KafkaBrokerResource.java  |   100 +
 .../hadoop/hive/kafka/KafkaInputSplitTest.java  |   126 +
 .../hive/kafka/KafkaPullerInputSplitTest.java   |   131 -
 .../hive/kafka/KafkaRecordIteratorTest.java     |   249 +-
 .../hive/kafka/KafkaRecordWritableTest.java     |    84 -
 .../hadoop/hive/kafka/KafkaScanTrimmerTest.java |    46 +-
 .../hive/kafka/KafkaStorageHandlerTest.java     |   145 +
 .../hive/kafka/KafkaStreamingUtilsTest.java     |   108 -
 .../hadoop/hive/kafka/KafkaUtilsTest.java       |   120 +
 .../hadoop/hive/kafka/KafkaWritableTest.java    |    85 +
 .../hive/kafka/SimpleKafkaWriterTest.java       |   182 +
 .../kafka/TransactionalKafkaWriterTest.java     |   246 +
 .../org/apache/hadoop/hive/llap/LlapUtil.java   |    17 +
 .../hive/llap/counters/LlapIOCounters.java      |     4 +-
 .../hadoop/hive/llap/cache/BuddyAllocator.java  |    45 +-
 .../hive/llap/cache/LowLevelCacheCounters.java  |     3 +-
 .../llap/cli/LlapStatusOptionsProcessor.java    |    26 +-
 .../hive/llap/cli/LlapStatusServiceDriver.java  |   426 +-
 .../llap/counters/QueryFragmentCounters.java    |    10 +-
 .../daemon/impl/StatsRecordingThreadPool.java   |    42 +-
 .../hive/llap/io/api/impl/LlapRecordReader.java |    63 +-
 .../llap/io/decode/EncodedDataConsumer.java     |    43 +-
 .../llap/io/decode/OrcEncodedDataConsumer.java  |     6 +-
 .../llap/io/encoded/OrcEncodedDataReader.java   |    18 +-
 .../llap/io/encoded/SerDeEncodedDataReader.java |     9 +-
 .../hive/llap/cache/TestBuddyAllocator.java     |    17 +-
 .../cache/TestBuddyAllocatorForceEvict.java     |     4 +-
 .../hive/llap/cache/TestOrcMetadataCache.java   |     4 +-
 .../llap/cli/TestLlapStatusServiceDriver.java   |    98 +
 .../tezplugins/LlapTaskSchedulerService.java    |     7 +-
 pom.xml                                         |    14 +-
 ql/pom.xml                                      |    13 +
 .../metastore/SynchronizedMetaStoreClient.java  |     4 +
 .../java/org/apache/hadoop/hive/ql/Context.java |     9 +
 .../java/org/apache/hadoop/hive/ql/Driver.java  |   139 +-
 .../java/org/apache/hadoop/hive/ql/IDriver.java |     2 +
 .../org/apache/hadoop/hive/ql/MapRedStats.java  |    12 +-
 .../org/apache/hadoop/hive/ql/QueryDisplay.java |    82 +
 .../org/apache/hadoop/hive/ql/QueryInfo.java    |    10 +
 .../org/apache/hadoop/hive/ql/QueryState.java   |    23 +-
 .../ql/cache/results/QueryResultsCache.java     |    14 +-
 .../org/apache/hadoop/hive/ql/exec/DDLTask.java |     8 +-
 .../ql/exec/DefaultMemoryExhaustionChecker.java |    45 +
 .../apache/hadoop/hive/ql/exec/ExplainTask.java |    21 +-
 .../hadoop/hive/ql/exec/FileSinkOperator.java   |    12 +-
 .../hadoop/hive/ql/exec/FunctionRegistry.java   |    12 +-
 .../hive/ql/exec/HashTableSinkOperator.java     |     9 +-
 .../hadoop/hive/ql/exec/MapJoinOperator.java    |    11 +-
 .../apache/hadoop/hive/ql/exec/MapOperator.java |    10 +-
 .../hive/ql/exec/MemoryExhaustionChecker.java   |    28 +
 .../ql/exec/MemoryExhaustionCheckerFactory.java |    39 +
 .../apache/hadoop/hive/ql/exec/MemoryInfo.java  |   114 +
 .../hadoop/hive/ql/exec/OperatorUtils.java      |    91 +
 .../ql/exec/SparkMemoryExhaustionChecker.java   |    91 +
 .../apache/hadoop/hive/ql/exec/Utilities.java   |    80 +-
 .../hadoop/hive/ql/exec/mr/ExecMapper.java      |     6 +
 .../hadoop/hive/ql/exec/mr/ExecReducer.java     |     9 +-
 .../hive/ql/exec/mr/HadoopJobExecHelper.java    |    34 +-
 .../hadoop/hive/ql/exec/mr/MapRedTask.java      |    16 +
 .../hadoop/hive/ql/exec/repl/ReplDumpTask.java  |    78 +-
 .../hadoop/hive/ql/exec/repl/ReplLoadTask.java  |     9 +
 .../hadoop/hive/ql/exec/repl/ReplLoadWork.java  |     9 +-
 .../filesystem/DatabaseEventsIterator.java      |    49 +-
 .../repl/bootstrap/load/LoadConstraint.java     |     4 +-
 .../bootstrap/load/table/LoadPartitions.java    |    17 +-
 .../repl/bootstrap/load/table/LoadTable.java    |     2 +-
 .../IncrementalLoadEventsIterator.java          |     4 +-
 .../IncrementalLoadTasksBuilder.java            |    20 +-
 .../ql/exec/spark/LocalHiveSparkClient.java     |    38 +-
 .../ql/exec/spark/RemoteHiveSparkClient.java    |     4 +-
 .../ql/exec/spark/SparkMapRecordHandler.java    |     6 +
 .../ql/exec/spark/SparkReduceRecordHandler.java |    38 +-
 .../hive/ql/exec/spark/SparkUtilities.java      |     1 +
 .../ql/exec/spark/session/SparkSessionImpl.java |    88 +-
 .../spark/session/SparkSessionManagerImpl.java  |     1 +
 .../hadoop/hive/ql/exec/tez/DagUtils.java       |     8 +-
 .../ql/exec/tez/KillTriggerActionHandler.java   |     8 +-
 .../hive/ql/exec/tez/MapRecordProcessor.java    |     7 +
 .../hive/ql/exec/tez/ReduceRecordSource.java    |     9 +-
 .../hive/ql/exec/tez/WorkloadManager.java       |     3 +
 .../ql/exec/vector/VectorGroupByOperator.java   |    24 +-
 .../ql/exec/vector/VectorizationContext.java    |   116 +-
 .../vector/expressions/BucketNumExpression.java |    21 +-
 .../expressions/CastTimestampToString.java      |    10 +-
 .../VectorReduceSinkObjectHashOperator.java     |    32 +-
 .../apache/hadoop/hive/ql/hooks/ATSHook.java    |     3 +-
 .../hive/ql/hooks/EnforceReadOnlyTables.java    |     7 +-
 .../hive/ql/hooks/HiveProtoLoggingHook.java     |    71 +-
 .../org/apache/hadoop/hive/ql/io/AcidUtils.java |    47 +-
 .../org/apache/hadoop/hive/ql/io/HdfsUtils.java |     4 +-
 .../hadoop/hive/ql/io/HiveInputFormat.java      |     1 +
 .../hadoop/hive/ql/io/RecordIdentifier.java     |    17 +-
 .../hadoop/hive/ql/io/arrow/Serializer.java     |    33 +-
 .../apache/hadoop/hive/ql/io/orc/OrcFile.java   |    48 +-
 .../hadoop/hive/ql/io/orc/OrcInputFormat.java   |    36 +-
 .../hadoop/hive/ql/io/orc/OrcOutputFormat.java  |     9 +-
 .../hive/ql/io/orc/OrcRawRecordMerger.java      |    88 +-
 .../hadoop/hive/ql/io/orc/OrcRecordUpdater.java |     2 +-
 .../apache/hadoop/hive/ql/io/orc/OrcSplit.java  |    59 +-
 .../io/orc/VectorizedOrcAcidRowBatchReader.java |   756 +-
 .../vector/VectorizedParquetRecordReader.java   |     3 +-
 .../apache/hadoop/hive/ql/lock/CompileLock.java |   137 +
 .../hadoop/hive/ql/lock/CompileLockFactory.java |   125 +
 .../hadoop/hive/ql/lockmgr/DbTxnManager.java    |     2 +-
 .../apache/hadoop/hive/ql/metadata/Hive.java    |   555 +-
 .../metadata/HiveMaterializedViewsRegistry.java |    36 +-
 .../ql/metadata/SessionHiveMetaStoreClient.java |    54 +-
 .../hive/ql/metadata/events/EventUtils.java     |    16 +-
 .../hive/ql/optimizer/ConvertJoinMapJoin.java   |    43 +-
 .../hadoop/hive/ql/optimizer/Optimizer.java     |     7 +-
 .../hive/ql/optimizer/SharedWorkOptimizer.java  |    62 +
 .../optimizer/SortedDynPartitionOptimizer.java  |   117 +-
 .../calcite/HiveDefaultRelMetadataProvider.java |     2 +
 .../ql/optimizer/calcite/HiveRelOptUtil.java    |   238 +
 .../optimizer/calcite/HiveRexExecutorImpl.java  |     3 +-
 .../ql/optimizer/calcite/RelOptHiveTable.java   |    49 +-
 .../calcite/cost/HiveAlgorithmsUtil.java        |    30 +-
 .../calcite/cost/HiveOnTezCostModel.java        |    12 +-
 .../optimizer/calcite/reloperators/HiveIn.java  |    27 +
 .../reloperators/jdbc/HiveJdbcConverter.java    |   121 +-
 .../rules/HiveAggregateJoinTransposeRule.java   |     2 +-
 .../calcite/rules/HiveJoinConstraintsRule.java  |   228 +-
 .../rules/HiveJoinProjectTransposeRule.java     |     3 +-
 .../rules/HivePointLookupOptimizerRule.java     |    46 +-
 .../calcite/rules/HivePreFilteringRule.java     |    40 +-
 .../calcite/rules/HiveRelFieldTrimmer.java      |   269 +-
 .../calcite/rules/jdbc/HiveJdbcImplementor.java |    60 +
 .../rules/jdbc/JDBCJoinPushDownRule.java        |    57 +-
 .../rules/jdbc/JDBCUnionPushDownRule.java       |    32 +-
 .../calcite/stats/EstimateUniqueKeys.java       |   333 +
 .../stats/FilterSelectivityEstimator.java       |    33 +-
 .../stats/HiveRelMdColumnUniqueness.java        |    63 +
 .../calcite/stats/HiveRelMdRowCount.java        |     7 +-
 .../calcite/stats/HiveRelMdUniqueKeys.java      |   152 +-
 .../calcite/translator/ASTBuilder.java          |    28 +-
 .../calcite/translator/RexNodeConverter.java    |    39 +-
 .../translator/SqlFunctionConverter.java        |    29 +-
 .../physical/LlapClusterStateForCompile.java    |    12 +
 .../hive/ql/optimizer/physical/Vectorizer.java  |    33 +-
 .../ppr/PartitionExpressionForMetastore.java    |    13 +-
 .../stats/annotation/StatsRulesProcFactory.java |   129 +-
 .../hive/ql/parse/BaseSemanticAnalyzer.java     |    85 +-
 .../hadoop/hive/ql/parse/CalcitePlanner.java    |    57 +-
 .../ql/parse/ColumnStatsAutoGatherContext.java  |     2 +-
 .../hive/ql/parse/DDLSemanticAnalyzer.java      |     9 +-
 .../hive/ql/parse/ExplainConfiguration.java     |    18 +
 .../hive/ql/parse/ExplainSemanticAnalyzer.java  |    14 +-
 .../org/apache/hadoop/hive/ql/parse/HiveLexer.g |     1 +
 .../apache/hadoop/hive/ql/parse/HiveParser.g    |     5 +-
 .../hadoop/hive/ql/parse/IdentifiersParser.g    |     2 +-
 .../hive/ql/parse/ImportSemanticAnalyzer.java   |    13 +
 .../hive/ql/parse/LoadSemanticAnalyzer.java     |     6 +
 .../hadoop/hive/ql/parse/MapReduceCompiler.java |    13 +
 .../apache/hadoop/hive/ql/parse/ParseUtils.java |    28 +
 .../ql/parse/ReplicationSemanticAnalyzer.java   |    35 +-
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java  |   124 +-
 .../hadoop/hive/ql/parse/TezCompiler.java       |    24 +
 .../ql/parse/UpdateDeleteSemanticAnalyzer.java  |    88 +-
 .../hadoop/hive/ql/parse/repl/CopyUtils.java    |    12 +-
 .../parse/repl/dump/events/AbortTxnHandler.java |    12 +-
 .../events/AbstractConstraintEventHandler.java  |     3 +-
 .../repl/dump/events/AbstractEventHandler.java  |    32 +-
 .../repl/dump/events/AddForeignKeyHandler.java  |    12 +-
 .../events/AddNotNullConstraintHandler.java     |    12 +-
 .../repl/dump/events/AddPartitionHandler.java   |    10 +-
 .../repl/dump/events/AddPrimaryKeyHandler.java  |    12 +-
 .../dump/events/AddUniqueConstraintHandler.java |    13 +-
 .../repl/dump/events/AllocWriteIdHandler.java   |    12 +-
 .../repl/dump/events/AlterDatabaseHandler.java  |    12 +-
 .../repl/dump/events/AlterPartitionHandler.java |    21 +-
 .../repl/dump/events/AlterTableHandler.java     |    18 +-
 .../repl/dump/events/CommitTxnHandler.java      |    28 +-
 .../repl/dump/events/CreateDatabaseHandler.java |    13 +-
 .../repl/dump/events/CreateFunctionHandler.java |    13 +-
 .../repl/dump/events/CreateTableHandler.java    |    15 +-
 .../parse/repl/dump/events/DefaultHandler.java  |     9 +
 .../repl/dump/events/DropConstraintHandler.java |    13 +-
 .../repl/dump/events/DropDatabaseHandler.java   |    12 +-
 .../repl/dump/events/DropFunctionHandler.java   |    12 +-
 .../repl/dump/events/DropPartitionHandler.java  |    12 +-
 .../repl/dump/events/DropTableHandler.java      |    12 +-
 .../repl/dump/events/EventHandlerFactory.java   |    44 +-
 .../parse/repl/dump/events/InsertHandler.java   |    22 +-
 .../parse/repl/dump/events/OpenTxnHandler.java  |    12 +-
 .../repl/dump/io/ConstraintsSerializer.java     |    10 +-
 .../load/message/AbstractMessageHandler.java    |     4 +-
 .../apache/hadoop/hive/ql/plan/ExplainWork.java |    17 +-
 .../hadoop/hive/ql/plan/ExprNodeDescUtils.java  |    34 +-
 .../hadoop/hive/ql/plan/LoadTableDesc.java      |     4 +-
 .../apache/hadoop/hive/ql/plan/MapJoinDesc.java |    26 +
 .../org/apache/hadoop/hive/ql/plan/MapWork.java |     2 +-
 .../apache/hadoop/hive/ql/plan/PlanUtils.java   |     9 +
 .../apache/hadoop/hive/ql/plan/TableDesc.java   |     2 +
 .../hadoop/hive/ql/plan/VectorMapJoinDesc.java  |    14 +
 .../hive/ql/ppd/SyntheticJoinPredicate.java     |    17 +-
 .../hadoop/hive/ql/reexec/ReExecDriver.java     |     5 +
 .../plugin/SettableConfigUpdater.java           |     2 +-
 .../plugin/fallback/FallbackHiveAuthorizer.java |   253 +
 .../fallback/FallbackHiveAuthorizerFactory.java |    36 +
 .../hadoop/hive/ql/session/SessionState.java    |     4 +-
 .../hive/ql/txn/compactor/CompactorMR.java      |    11 +-
 .../generic/GenericUDAFApproximateDistinct.java |   237 +
 .../ql/udf/generic/GenericUDAFComputeStats.java |     1 +
 .../generic/GenericUDFCardinalityViolation.java |    19 +-
 .../ql/udf/generic/GenericUDFOPDTIMinus.java    |   110 +-
 .../ql/udf/generic/GenericUDFOPDTIPlus.java     |    94 +-
 .../ql/udf/generic/GenericUDFSurrogateKey.java  |   137 +
 .../ql/udf/generic/GenericUDFTumbledWindow.java |   139 +
 .../ql/udf/generic/GenericUDTFGetSplits.java    |    29 +-
 .../hadoop/hive/ql/util/DateTimeMath.java       |    18 +-
 .../hive/metastore/TestMetastoreExpr.java       |    10 +-
 .../apache/hadoop/hive/ql/CompileLockTest.java  |   329 +
 .../apache/hadoop/hive/ql/TestTxnCommands.java  |     9 +
 .../apache/hadoop/hive/ql/TestTxnCommands2.java |     5 +-
 .../apache/hadoop/hive/ql/TestTxnCommands3.java |   286 +
 .../hadoop/hive/ql/TestTxnConcatenate.java      |    63 -
 .../apache/hadoop/hive/ql/TestTxnLoadData.java  |     6 +
 .../apache/hadoop/hive/ql/TestTxnNoBuckets.java |     8 +
 .../hadoop/hive/ql/TxnCommandsBaseForTests.java |     5 +
 .../exec/TestMsckDropPartitionsInBatches.java   |     1 +
 .../hadoop/hive/ql/exec/TestOperators.java      |     1 +
 .../hive/ql/exec/repl/TestReplDumpTask.java     |    10 +-
 .../ql/exec/spark/TestLocalHiveSparkClient.java |   149 +
 .../exec/vector/TestVectorGroupByOperator.java  |    96 +
 .../exec/vector/TestVectorizationContext.java   |    31 +-
 .../hive/ql/hooks/TestHiveProtoLoggingHook.java |    37 +
 .../io/arrow/TestArrowColumnarBatchSerDe.java   |    25 +
 .../hive/ql/io/orc/TestInputOutputFormat.java   |    10 +-
 .../hadoop/hive/ql/io/orc/TestOrcFile.java      |    41 +
 .../TestVectorizedOrcAcidRowBatchReader.java    |   875 +-
 .../hive/ql/lockmgr/TestDbTxnManager.java       |     4 +-
 .../hadoop/hive/ql/metadata/TestHive.java       |     5 +
 .../ql/metadata/TestHiveMetaStoreChecker.java   |     5 +
 .../rules/TestHivePointLookupOptimizerRule.java |    43 +
 .../parse/TestUpdateDeleteSemanticAnalyzer.java |     2 +-
 .../dump/events/TestEventHandlerFactory.java    |     7 +-
 .../udf/generic/TestGenericUDFSurrogateKey.java |   206 +
 .../clientnegative/authorization_explain.q      |     7 +
 .../authorization_jdbc_keystore.q               |    28 +
 .../clientnegative/authorization_kill_query.q   |    15 -
 .../default_constraint_invalid_default_value2.q |     2 -
 ...ault_constraint_invalid_default_value_type.q |     2 -
 .../clientnegative/fallbackauth_addjar.q        |     4 +
 .../clientnegative/fallbackauth_compile.q       |     9 +
 .../clientnegative/fallbackauth_create_func1.q  |     5 +
 .../clientnegative/fallbackauth_create_func2.q  |     6 +
 .../queries/clientnegative/fallbackauth_dfs.q   |     4 +
 .../fallbackauth_disallow_transform.q           |     6 +
 .../queries/clientnegative/fallbackauth_load.q  |    15 +
 .../fallbackauth_set_invalidconf.q              |     8 +
 .../clientnegative/merge_column_mismatch.q      |    15 +
 .../clientpositive/acid_meta_columns_decode.q   |    24 +
 .../acid_vectorization_original.q               |    29 +-
 .../clientpositive/alter_table_location2.q      |    21 +
 .../clientpositive/alter_table_location3.q      |    16 +
 .../clientpositive/annotate_stats_groupby.q     |    17 +
 .../queries/clientpositive/approx_distinct.q    |    76 +
 .../queries/clientpositive/autoColumnStats_11.q |    28 +
 .../clientpositive/constraints_optimization.q   |   149 +
 ql/src/test/queries/clientpositive/cttl.q       |     2 +-
 .../clientpositive/date_int_operation_test.q    |     5 +
 .../test/queries/clientpositive/dp_counter_mm.q |     1 +
 .../queries/clientpositive/dp_counter_non_mm.q  |     1 +
 .../clientpositive/druidmini_test_insert.q      |    11 +
 .../dynpart_sort_opt_vectorization.q            |    25 +-
 .../clientpositive/dynpart_sort_optimization.q  |    63 +-
 .../clientpositive/dynpart_sort_optimization2.q |     9 +-
 .../dynpart_sort_optimization_acid.q            |    12 +-
 .../dynpart_sort_optimization_acid2.q           |     2 +-
 .../queries/clientpositive/exim_hidden_files.q  |    10 +-
 .../queries/clientpositive/external_jdbc_auth.q |   120 +
 .../clientpositive/external_jdbc_table.q        |   187 +
 .../clientpositive/external_jdbc_table2.q       |   142 +
 .../external_jdbc_table_partition.q             |   135 +
 .../external_jdbc_table_typeconversion.q        |   119 +
 .../test/queries/clientpositive/fold_to_null.q  |    14 +
 .../insert_into_default_keyword.q               |    10 +-
 .../test/queries/clientpositive/jdbc_handler.q  |     2 +-
 .../clientpositive/kafka_storage_handler.q      |    74 +-
 .../clientpositive/load_data_using_job.q        |    20 +-
 ql/src/test/queries/clientpositive/mm_dp.q      |    51 +
 .../test/queries/clientpositive/msck_repair_0.q |     8 +-
 .../test/queries/clientpositive/msck_repair_2.q |     6 +-
 .../test/queries/clientpositive/msck_repair_3.q |     2 +-
 .../clientpositive/msck_repair_batchsize.q      |    18 +-
 .../queries/clientpositive/msck_repair_drop.q   |   164 +-
 .../queries/clientpositive/perf/cbo_query1.q    |    27 +
 .../queries/clientpositive/perf/cbo_query10.q   |    61 +
 .../queries/clientpositive/perf/cbo_query11.q   |    77 +
 .../queries/clientpositive/perf/cbo_query12.q   |    35 +
 .../queries/clientpositive/perf/cbo_query13.q   |    54 +
 .../queries/clientpositive/perf/cbo_query14.q   |   104 +
 .../queries/clientpositive/perf/cbo_query15.q   |    22 +
 .../queries/clientpositive/perf/cbo_query16.q   |    33 +
 .../queries/clientpositive/perf/cbo_query17.q   |    47 +
 .../queries/clientpositive/perf/cbo_query18.q   |    36 +
 .../queries/clientpositive/perf/cbo_query19.q   |    27 +
 .../queries/clientpositive/perf/cbo_query2.q    |    62 +
 .../queries/clientpositive/perf/cbo_query20.q   |    31 +
 .../queries/clientpositive/perf/cbo_query21.q   |    32 +
 .../queries/clientpositive/perf/cbo_query22.q   |    24 +
 .../queries/clientpositive/perf/cbo_query23.q   |    52 +
 .../queries/clientpositive/perf/cbo_query24.q   |    52 +
 .../queries/clientpositive/perf/cbo_query25.q   |    50 +
 .../queries/clientpositive/perf/cbo_query26.q   |    23 +
 .../queries/clientpositive/perf/cbo_query27.q   |    25 +
 .../queries/clientpositive/perf/cbo_query28.q   |    59 +
 .../queries/clientpositive/perf/cbo_query29.q   |    49 +
 .../queries/clientpositive/perf/cbo_query3.q    |    23 +
 .../queries/clientpositive/perf/cbo_query30.q   |    33 +
 .../queries/clientpositive/perf/cbo_query31.q   |    54 +
 .../queries/clientpositive/perf/cbo_query32.q   |    30 +
 .../queries/clientpositive/perf/cbo_query33.q   |    77 +
 .../queries/clientpositive/perf/cbo_query34.q   |    33 +
 .../queries/clientpositive/perf/cbo_query35.q   |    59 +
 .../queries/clientpositive/perf/cbo_query36.q   |    32 +
 .../queries/clientpositive/perf/cbo_query37.q   |    19 +
 .../queries/clientpositive/perf/cbo_query38.q   |    25 +
 .../queries/clientpositive/perf/cbo_query39.q   |    56 +
 .../queries/clientpositive/perf/cbo_query4.q    |   111 +
 .../queries/clientpositive/perf/cbo_query40.q   |    30 +
 .../queries/clientpositive/perf/cbo_query42.q   |    24 +
 .../queries/clientpositive/perf/cbo_query43.q   |    21 +
 .../queries/clientpositive/perf/cbo_query44.q   |    37 +
 .../queries/clientpositive/perf/cbo_query45.q   |    22 +
 .../queries/clientpositive/perf/cbo_query46.q   |    37 +
 .../queries/clientpositive/perf/cbo_query47.q   |    53 +
 .../queries/clientpositive/perf/cbo_query48.q   |    69 +
 .../queries/clientpositive/perf/cbo_query49.q   |   129 +
 .../queries/clientpositive/perf/cbo_query5.q    |   130 +
 .../queries/clientpositive/perf/cbo_query50.q   |    61 +
 .../queries/clientpositive/perf/cbo_query51.q   |    47 +
 .../queries/clientpositive/perf/cbo_query52.q   |    24 +
 .../queries/clientpositive/perf/cbo_query53.q   |    30 +
 .../queries/clientpositive/perf/cbo_query54.q   |    58 +
 .../queries/clientpositive/perf/cbo_query55.q   |    16 +
 .../queries/clientpositive/perf/cbo_query56.q   |    70 +
 .../queries/clientpositive/perf/cbo_query57.q   |    50 +
 .../queries/clientpositive/perf/cbo_query58.q   |    67 +
 .../queries/clientpositive/perf/cbo_query59.q   |    46 +
 .../queries/clientpositive/perf/cbo_query6.q    |    30 +
 .../queries/clientpositive/perf/cbo_query60.q   |    80 +
 .../queries/clientpositive/perf/cbo_query61.q   |    46 +
 .../queries/clientpositive/perf/cbo_query63.q   |    31 +
 .../queries/clientpositive/perf/cbo_query64.q   |   121 +
 .../queries/clientpositive/perf/cbo_query65.q   |    31 +
 .../queries/clientpositive/perf/cbo_query66.q   |   224 +
 .../queries/clientpositive/perf/cbo_query67.q   |    46 +
 .../queries/clientpositive/perf/cbo_query68.q   |    44 +
 .../queries/clientpositive/perf/cbo_query69.q   |    49 +
 .../queries/clientpositive/perf/cbo_query7.q    |    23 +
 .../queries/clientpositive/perf/cbo_query70.q   |    40 +
 .../queries/clientpositive/perf/cbo_query71.q   |    42 +
 .../queries/clientpositive/perf/cbo_query72.q   |    33 +
 .../queries/clientpositive/perf/cbo_query73.q   |    30 +
 .../queries/clientpositive/perf/cbo_query74.q   |    63 +
 .../queries/clientpositive/perf/cbo_query75.q   |    72 +
 .../queries/clientpositive/perf/cbo_query76.q   |    26 +
 .../queries/clientpositive/perf/cbo_query77.q   |   109 +
 .../queries/clientpositive/perf/cbo_query78.q   |    60 +
 .../queries/clientpositive/perf/cbo_query79.q   |    25 +
 .../queries/clientpositive/perf/cbo_query8.q    |   110 +
 .../queries/clientpositive/perf/cbo_query80.q   |    98 +
 .../queries/clientpositive/perf/cbo_query81.q   |    33 +
 .../queries/clientpositive/perf/cbo_query82.q   |    19 +
 .../queries/clientpositive/perf/cbo_query83.q   |    69 +
 .../queries/clientpositive/perf/cbo_query84.q   |    23 +
 .../queries/clientpositive/perf/cbo_query85.q   |    86 +
 .../queries/clientpositive/perf/cbo_query86.q   |    28 +
 .../queries/clientpositive/perf/cbo_query87.q   |    25 +
 .../queries/clientpositive/perf/cbo_query88.q   |    96 +
 .../queries/clientpositive/perf/cbo_query89.q   |    30 +
 .../queries/clientpositive/perf/cbo_query9.q    |    53 +
 .../queries/clientpositive/perf/cbo_query90.q   |    24 +
 .../queries/clientpositive/perf/cbo_query91.q   |    33 +
 .../queries/clientpositive/perf/cbo_query92.q   |    32 +
 .../queries/clientpositive/perf/cbo_query93.q   |    20 +
 .../queries/clientpositive/perf/cbo_query94.q   |    31 +
 .../queries/clientpositive/perf/cbo_query95.q   |    34 +
 .../queries/clientpositive/perf/cbo_query96.q   |    18 +
 .../queries/clientpositive/perf/cbo_query97.q   |    27 +
 .../queries/clientpositive/perf/cbo_query98.q   |    34 +
 .../queries/clientpositive/perf/cbo_query99.q   |    37 +
 .../test/queries/clientpositive/perf/query24.q  |     3 +-
 .../test/queries/clientpositive/pointlookup5.q  |    20 +
 ql/src/test/queries/clientpositive/repair.q     |     6 +-
 .../clientpositive/show_materialized_views.q    |     6 +-
 .../clientpositive/skewjoin_union_remove_1.q    |     1 -
 .../clientpositive/skewjoin_union_remove_2.q    |     1 -
 .../queries/clientpositive/sqlmerge_stats.q     |    83 +-
 .../queries/clientpositive/tez_input_counters.q |     1 +
 .../clientpositive/tumbled_window_tests.q       |    19 +
 .../queries/clientpositive/udf_isops_simplify.q |    10 +
 .../test/queries/clientpositive/udf_to_string.q |     2 +
 .../queries/clientpositive/union_remove_1.q     |     1 -
 .../queries/clientpositive/union_remove_10.q    |     1 -
 .../queries/clientpositive/union_remove_11.q    |     1 -
 .../queries/clientpositive/union_remove_12.q    |     1 -
 .../queries/clientpositive/union_remove_13.q    |     1 -
 .../queries/clientpositive/union_remove_14.q    |     1 -
 .../queries/clientpositive/union_remove_15.q    |     1 -
 .../queries/clientpositive/union_remove_16.q    |     1 -
 .../queries/clientpositive/union_remove_17.q    |     1 -
 .../queries/clientpositive/union_remove_18.q    |     1 -
 .../queries/clientpositive/union_remove_19.q    |     1 -
 .../queries/clientpositive/union_remove_2.q     |     1 -
 .../queries/clientpositive/union_remove_20.q    |     1 -
 .../queries/clientpositive/union_remove_21.q    |     1 -
 .../queries/clientpositive/union_remove_22.q    |     1 -
 .../queries/clientpositive/union_remove_23.q    |     1 -
 .../queries/clientpositive/union_remove_24.q    |     1 -
 .../queries/clientpositive/union_remove_25.q    |     1 -
 .../queries/clientpositive/union_remove_26.q    |     2 -
 .../queries/clientpositive/union_remove_3.q     |     1 -
 .../queries/clientpositive/union_remove_4.q     |     1 -
 .../queries/clientpositive/union_remove_5.q     |     1 -
 .../queries/clientpositive/union_remove_6.q     |     1 -
 .../clientpositive/union_remove_6_subq.q        |     1 -
 .../queries/clientpositive/union_remove_7.q     |     1 -
 .../queries/clientpositive/union_remove_8.q     |     1 -
 .../queries/clientpositive/union_remove_9.q     |     1 -
 .../queries/clientpositive/union_remove_plan.q  |     1 -
 .../vector_case_when_conversion.q               |   136 +
 .../vector_mapjoin_complex_values.q             |    34 +
 .../vector_partitioned_date_time.q              |     3 +-
 ...on_alter_table_exchange_partition_fail.q.out |     4 +
 ...n_alter_table_exchange_partition_fail2.q.out |     4 +
 .../clientnegative/authorization_explain.q.out  |    37 +
 .../authorization_insertpart_noinspriv.q.out    |     8 +
 .../authorization_jdbc_keystore.q.out           |     1 +
 .../authorization_kill_query.q.out              |     2 +
 .../bucket_mapjoin_mismatch1.q.out              |    20 +
 ...ault_constraint_invalid_default_value2.q.out |     1 -
 ..._constraint_invalid_default_value_type.q.out |     1 -
 .../clientnegative/fallbackauth_addjar.q.out    |     1 +
 .../clientnegative/fallbackauth_compile.q.out   |     1 +
 .../fallbackauth_create_func1.q.out             |     1 +
 .../fallbackauth_create_func2.q.out             |     1 +
 .../clientnegative/fallbackauth_dfs.q.out       |     1 +
 .../fallbackauth_disallow_transform.q.out       |    16 +
 .../clientnegative/fallbackauth_load.q.out      |     9 +
 .../fallbackauth_set_invalidconf.q.out          |     7 +
 .../results/clientnegative/masking_mv.q.out     |     6 +
 .../clientnegative/merge_column_mismatch.q.out  |    37 +
 .../results/clientnegative/script_error.q.out   |     4 +
 .../sortmerge_mapjoin_mismatch_1.q.out          |     6 +
 .../spark/spark_job_max_tasks.q.out             |     4 +
 .../spark/spark_stage_max_tasks.q.out           |     4 +
 .../spark/spark_task_failure.q.out              |     4 +
 .../clientnegative/udf_assert_true.q.out        |     8 +
 .../clientnegative/udf_assert_true2.q.out       |     4 +
 .../results/clientpositive/acid_mapjoin.q.out   |     6 +
 .../results/clientpositive/acid_nullscan.q.out  |     4 +
 .../results/clientpositive/acid_stats.q.out     |    12 +
 .../results/clientpositive/acid_stats2.q.out    |    48 +
 .../results/clientpositive/acid_stats3.q.out    |    42 +
 .../results/clientpositive/acid_stats4.q.out    |   120 +
 .../results/clientpositive/acid_stats5.q.out    |    56 +
 .../clientpositive/acid_table_stats.q.out       |    38 +-
 .../clientpositive/add_part_multiple.q.out      |     4 +
 .../clientpositive/alias_casted_column.q.out    |     8 +
 .../clientpositive/allcolref_in_udf.q.out       |    12 +
 .../clientpositive/alterColumnStatsPart.q.out   |    32 +
 .../alter_partition_coltype.q.out               |    32 +
 .../clientpositive/alter_rename_table.q.out     |     8 +
 .../alter_table_update_status.q.out             |   358 +-
 ..._table_update_status_disable_bitvector.q.out |   288 +-
 .../results/clientpositive/ambiguitycheck.q.out |     6 +
 .../results/clientpositive/ambiguous_col.q.out  |    22 +
 .../analyze_table_null_partition.q.out          |    12 +
 .../clientpositive/analyze_tbl_date.q.out       |     4 +
 .../annotate_stats_deep_filters.q.out           |     8 +
 .../clientpositive/annotate_stats_filter.q.out  |   120 +
 .../clientpositive/annotate_stats_groupby.q.out |   282 +
 .../annotate_stats_groupby2.q.out               |    28 +
 .../clientpositive/annotate_stats_join.q.out    |    70 +
 .../annotate_stats_join_pkfk.q.out              |    68 +
 .../clientpositive/annotate_stats_limit.q.out   |    16 +
 .../clientpositive/annotate_stats_part.q.out    |   128 +
 .../clientpositive/annotate_stats_select.q.out  |   136 +
 .../clientpositive/annotate_stats_table.q.out   |    42 +
 .../clientpositive/annotate_stats_udtf.q.out    |    20 +
 .../clientpositive/annotate_stats_union.q.out   |    28 +
 .../clientpositive/ansi_sql_arithmetic.q.out    |     8 +
 .../array_map_access_nonconstant.q.out          |     8 +
 .../clientpositive/array_size_estimation.q.out  |    16 +
 ...ization_alter_table_exchange_partition.q.out |     4 +
 .../clientpositive/authorization_explain.q.out  |    31 +
 .../clientpositive/authorization_wm.q.out       |    28 +
 .../clientpositive/autoColumnStats_1.q.out      |    72 +
 .../clientpositive/autoColumnStats_11.q.out     |   372 +
 .../clientpositive/autoColumnStats_2.q.out      |    78 +
 .../clientpositive/autoColumnStats_4.q.out      |     4 +
 .../clientpositive/autoColumnStats_5.q.out      |    12 +
 .../clientpositive/autoColumnStats_5a.q.out     |    12 +
 .../clientpositive/autoColumnStats_6.q.out      |     3 +
 .../clientpositive/autoColumnStats_7.q.out      |     4 +
 .../clientpositive/autoColumnStats_8.q.out      |    12 +
 .../clientpositive/autoColumnStats_9.q.out      |     4 +
 .../results/clientpositive/auto_join0.q.out     |     4 +
 .../results/clientpositive/auto_join1.q.out     |     4 +
 .../results/clientpositive/auto_join10.q.out    |     4 +
 .../results/clientpositive/auto_join11.q.out    |     4 +
 .../results/clientpositive/auto_join12.q.out    |     4 +
 .../results/clientpositive/auto_join13.q.out    |     4 +
 .../results/clientpositive/auto_join14.q.out    |    10 +
 .../results/clientpositive/auto_join15.q.out    |     4 +
 .../results/clientpositive/auto_join16.q.out    |     4 +
 .../results/clientpositive/auto_join17.q.out    |     4 +
 .../results/clientpositive/auto_join18.q.out    |     6 +
 .../auto_join18_multi_distinct.q.out            |     6 +
 .../results/clientpositive/auto_join19.q.out    |    14 +
 .../clientpositive/auto_join19_inclause.q.out   |    14 +
 .../results/clientpositive/auto_join2.q.out     |     4 +
 .../results/clientpositive/auto_join20.q.out    |     8 +
 .../results/clientpositive/auto_join21.q.out    |     4 +
 .../results/clientpositive/auto_join22.q.out    |     4 +
 .../results/clientpositive/auto_join23.q.out    |     4 +
 .../results/clientpositive/auto_join24.q.out    |     4 +
 .../results/clientpositive/auto_join26.q.out    |     6 +
 .../results/clientpositive/auto_join27.q.out    |     4 +
 .../results/clientpositive/auto_join28.q.out    |    16 +
 .../results/clientpositive/auto_join29.q.out    |    36 +
 .../results/clientpositive/auto_join3.q.out     |     4 +
 .../results/clientpositive/auto_join31.q.out    |     4 +
 .../results/clientpositive/auto_join32.q.out    |    24 +
 .../results/clientpositive/auto_join33.q.out    |     4 +
 .../results/clientpositive/auto_join4.q.out     |     4 +
 .../results/clientpositive/auto_join5.q.out     |     4 +
 .../results/clientpositive/auto_join6.q.out     |     4 +
 .../results/clientpositive/auto_join7.q.out     |     4 +
 .../results/clientpositive/auto_join8.q.out     |     4 +
 .../results/clientpositive/auto_join9.q.out     |     8 +
 .../auto_join_reordering_values.q.out           |     6 +
 .../clientpositive/auto_join_stats.q.out        |    14 +
 .../clientpositive/auto_join_stats2.q.out       |    14 +
 .../auto_join_without_localtask.q.out           |    12 +
 .../avro_schema_evolution_native.q.out          |    16 +
 .../beeline/explain_outputs.q.out               |    12 +
 .../clientpositive/beeline/mapjoin2.q.out       |    28 +
 .../materialized_view_create_rewrite.q.out      |    24 +
 .../beeline/select_dummy_source.q.out           |    28 +
 .../clientpositive/beeline/smb_mapjoin_1.q.out  |    48 +
 .../clientpositive/beeline/smb_mapjoin_10.q.out |     8 +
 .../clientpositive/beeline/smb_mapjoin_11.q.out |    22 +
 .../clientpositive/beeline/smb_mapjoin_12.q.out |    24 +
 .../clientpositive/beeline/smb_mapjoin_13.q.out |    12 +
 .../clientpositive/beeline/smb_mapjoin_16.q.out |     6 +
 .../clientpositive/beeline/smb_mapjoin_2.q.out  |    48 +
 .../clientpositive/beeline/smb_mapjoin_3.q.out  |    48 +
 .../clientpositive/beeline/smb_mapjoin_7.q.out  |     6 +
 .../clientpositive/binary_output_format.q.out   |     4 +
 .../clientpositive/binarysortable_1.q.out       |   Bin 4384 -> 4527 bytes
 .../test/results/clientpositive/bucket1.q.out   |     4 +
 .../test/results/clientpositive/bucket2.q.out   |     8 +
 .../test/results/clientpositive/bucket3.q.out   |    10 +
 .../clientpositive/bucket_map_join_1.q.out      |     6 +
 .../clientpositive/bucket_map_join_2.q.out      |     6 +
 .../clientpositive/bucket_map_join_spark1.q.out |    20 +
 .../clientpositive/bucket_map_join_spark2.q.out |    20 +
 .../clientpositive/bucket_map_join_spark3.q.out |    20 +
 .../clientpositive/bucket_map_join_spark4.q.out |    16 +
 .../clientpositive/bucketcontext_1.q.out        |    24 +
 .../clientpositive/bucketcontext_2.q.out        |    24 +
 .../clientpositive/bucketcontext_3.q.out        |    24 +
 .../clientpositive/bucketcontext_4.q.out        |    24 +
 .../clientpositive/bucketcontext_5.q.out        |    12 +
 .../clientpositive/bucketcontext_6.q.out        |    20 +
 .../clientpositive/bucketcontext_7.q.out        |    28 +
 .../clientpositive/bucketcontext_8.q.out        |    28 +
 .../clientpositive/bucketmapjoin10.q.out        |    14 +
 .../clientpositive/bucketmapjoin11.q.out        |    28 +
 .../clientpositive/bucketmapjoin12.q.out        |    20 +
 .../clientpositive/bucketmapjoin13.q.out        |    42 +
 .../results/clientpositive/bucketmapjoin5.q.out |    20 +
 .../results/clientpositive/bucketmapjoin8.q.out |    20 +
 .../results/clientpositive/bucketmapjoin9.q.out |    20 +
 .../clientpositive/bucketmapjoin_negative.q.out |     8 +
 .../bucketmapjoin_negative2.q.out               |    10 +
 .../bucketmapjoin_negative3.q.out               |    48 +
 .../bucketsortoptimize_insert_1.q.out           |    30 +
 .../bucketsortoptimize_insert_3.q.out           |    12 +
 .../bucketsortoptimize_insert_4.q.out           |    20 +
 .../bucketsortoptimize_insert_5.q.out           |    20 +
 .../bucketsortoptimize_insert_8.q.out           |    20 +
 .../clientpositive/case_sensitivity.q.out       |     4 +
 ql/src/test/results/clientpositive/cast1.q.out  |     4 +
 .../clientpositive/cast_on_constant.q.out       |    20 +
 .../cbo_SortUnionTransposeRule.q.out            |    48 +
 .../test/results/clientpositive/cbo_const.q.out |    16 +
 .../results/clientpositive/cbo_input26.q.out    |    24 +
 .../cbo_ppd_non_deterministic.q.out             |    12 +
 .../cbo_rp_annotate_stats_groupby.q.out         |    92 +
 .../clientpositive/cbo_rp_auto_join0.q.out      |     8 +
 .../clientpositive/cbo_rp_auto_join1.q.out      |    76 +
 .../clientpositive/cbo_rp_auto_join17.q.out     |     4 +
 .../cbo_rp_cross_product_check_2.q.out          |    30 +
 .../cbo_rp_gby2_map_multi_distinct.q.out        |     8 +
 .../cbo_rp_groupby3_noskew_multi_distinct.q.out |     4 +
 .../results/clientpositive/cbo_rp_join0.q.out   |    24 +
 .../results/clientpositive/cbo_rp_join1.q.out   |    16 +
 .../clientpositive/cbo_rp_outer_join_ppr.q.out  |    20 +
 .../clientpositive/cbo_rp_simple_select.q.out   |    36 +
 .../cbo_rp_udaf_percentile_approx_23.q.out      |     8 +
 .../clientpositive/cbo_simple_select.q.out      |    36 +
 .../results/clientpositive/cbo_union_view.q.out |    20 +
 .../columnStatsUpdateForStatsOptimizer_2.q.out  |    24 +
 .../column_pruner_multiple_children.q.out       |     4 +
 .../column_pruning_partitioned_view.q.out       |     6 +
 .../columnarserde_create_shortcut.q.out         |     4 +
 .../clientpositive/columnstats_partlvl.q.out    |    78 +
 .../clientpositive/columnstats_partlvl_dp.q.out |    84 +
 .../clientpositive/columnstats_quoting.q.out    |    12 +
 .../clientpositive/columnstats_tbllvl.q.out     |    42 +
 .../test/results/clientpositive/combine2.q.out  |    36 +
 .../test/results/clientpositive/comments.q.out  |     4 +
 .../results/clientpositive/complex_alias.q.out  |     4 +
 .../clientpositive/compute_stats_date.q.out     |     6 +
 .../test/results/clientpositive/concat_op.q.out |    12 +
 .../test/results/clientpositive/constGby.q.out  |     8 +
 .../clientpositive/constantPropWhen.q.out       |    32 +
 .../constantPropagateForSubQuery.q.out          |     6 +
 .../results/clientpositive/constant_prop.q.out  |     4 +
 .../clientpositive/constant_prop_1.q.out        |    28 +
 .../clientpositive/constant_prop_2.q.out        |    14 +
 .../clientpositive/constant_prop_3.q.out        |     8 +
 .../clientpositive/constantfolding.q.out        |    12 +
 .../results/clientpositive/constprog1.q.out     |     4 +
 .../results/clientpositive/constprog2.q.out     |     8 +
 .../results/clientpositive/constprog3.q.out     |     6 +
 .../results/clientpositive/constprog_dp.q.out   |     7 +
 .../clientpositive/constprog_partitioner.q.out  |     8 +
 .../results/clientpositive/constprog_type.q.out |    35 +-
 .../clientpositive/constprog_when_case.q.out    |     4 +
 .../convert_decimal64_to_decimal.q.out          |    12 +
 .../clientpositive/correlated_join_keys.q.out   |     8 +
 .../clientpositive/correlationoptimizer10.q.out |    32 +
 .../clientpositive/correlationoptimizer11.q.out |    28 +
 .../clientpositive/correlationoptimizer12.q.out |     6 +
 .../clientpositive/correlationoptimizer13.q.out |     4 +
 .../clientpositive/correlationoptimizer14.q.out |    60 +
 .../clientpositive/correlationoptimizer15.q.out |    12 +
 .../clientpositive/correlationoptimizer5.q.out  |    30 +
 .../clientpositive/correlationoptimizer7.q.out  |    24 +
 .../clientpositive/correlationoptimizer8.q.out  |    36 +
 .../clientpositive/correlationoptimizer9.q.out  |    16 +
 .../clientpositive/count_dist_rewrite.q.out     |    36 +
 ql/src/test/results/clientpositive/cp_sel.q.out |    15 +
 .../clientpositive/create_genericudaf.q.out     |     6 +
 .../clientpositive/create_genericudf.q.out      |     2 +
 .../results/clientpositive/create_udaf.q.out    |     2 +
 .../clientpositive/create_union_table.q.out     |     4 +
 .../results/clientpositive/create_view.q.out    |    12 +
 .../clientpositive/create_view_translate.q.out  |     6 +
 .../results/clientpositive/cross_join.q.out     |    24 +
 .../clientpositive/cross_join_merge.q.out       |    24 +
 .../clientpositive/cross_product_check_1.q.out  |    30 +
 .../clientpositive/cross_product_check_2.q.out  |    30 +
 ql/src/test/results/clientpositive/ctas.q.out   |    30 +
 .../results/clientpositive/ctas_colname.q.out   |    42 +
 .../ctas_uses_database_location.q.out           |     6 +
 ql/src/test/results/clientpositive/cte_1.q.out  |    12 +
 ql/src/test/results/clientpositive/cte_3.q.out  |    12 +
 ql/src/test/results/clientpositive/cte_5.q.out  |     6 +
 ql/src/test/results/clientpositive/cte_6.q.out  |     8 +
 .../test/results/clientpositive/cte_mat_1.q.out |     4 +
 .../test/results/clientpositive/cte_mat_2.q.out |     4 +
 .../test/results/clientpositive/cte_mat_3.q.out |     4 +
 .../test/results/clientpositive/cte_mat_4.q.out |     8 +
 .../test/results/clientpositive/cte_mat_5.q.out |     6 +
 .../date_int_operation_test.q.out               |    18 +
 .../results/clientpositive/decimal_join2.q.out  |     8 +
 .../clientpositive/decimal_precision.q.out      |     4 +
 .../clientpositive/decimal_precision2.q.out     |    28 +
 .../results/clientpositive/decimal_stats.q.out  |     4 +
 .../results/clientpositive/decimal_udf.q.out    |   136 +
 .../results/clientpositive/decimal_udf2.q.out   |     8 +
 .../results/clientpositive/deleteAnalyze.q.out  |     6 +-
 .../display_colstats_tbllvl.q.out               |    18 +
 .../results/clientpositive/distinct_stats.q.out |    12 +
 .../clientpositive/distinct_windowing.q.out     |    12 +
 .../distinct_windowing_no_cbo.q.out             |    20 +
 .../drop_deleted_partitions.q.out               |     4 +
 .../clientpositive/drop_multi_partitions.q.out  |     6 +
 .../test/results/clientpositive/drop_udf.q.out  |     2 +
 .../druid/druidkafkamini_basic.q.out            |    34 +
 .../druid/druidmini_dynamic_partition.q.out     |    14 +
 .../druid/druidmini_expressions.q.out           |   266 +-
 .../druid/druidmini_extractTime.q.out           |    76 +
 .../druid/druidmini_floorTime.q.out             |    64 +
 .../clientpositive/druid/druidmini_mv.q.out     |    34 +-
 .../clientpositive/druid/druidmini_test1.q.out  |    60 +
 .../druid/druidmini_test_insert.q.out           |    83 +
 .../druid/druidmini_test_ts.q.out               |    40 +
 .../druid/kafka_storage_handler.q.out           |   414 +-
 .../clientpositive/druid_timeseries.q.out       |    76 +
 .../results/clientpositive/druid_topn.q.out     |    32 +
 .../dynamic_partition_skip_default.q.out        |    20 +
 .../dynpart_sort_optimization_acid2.q.out       |    99 +-
 .../results/clientpositive/empty_join.q.out     |     8 +
 .../encryption_join_unencrypted_tbl.q.out       |     6 +
 ...on_join_with_different_encryption_keys.q.out |     6 +
 .../erasurecoding/erasure_explain.q.out         |    32 +
 .../clientpositive/escape_clusterby1.q.out      |     8 +
 .../clientpositive/escape_distributeby1.q.out   |     8 +
 .../clientpositive/escape_orderby1.q.out        |     8 +
 .../results/clientpositive/escape_sortby1.q.out |     8 +
 .../results/clientpositive/except_all.q.out     |    14 +
 .../exec_parallel_column_stats.q.out            |     6 +
 .../clientpositive/exim_hidden_files.q.out      |     8 +-
 .../results/clientpositive/explain_ast.q.out    |     4 +
 .../results/clientpositive/explain_ddl.q.out    |    50 +
 .../clientpositive/explain_dependency.q.out     |   108 +
 .../clientpositive/explain_dependency2.q.out    |    40 +
 .../results/clientpositive/explain_locks.q.out  |    61 +
 .../clientpositive/explain_logical.q.out        |    72 +
 .../clientpositive/explain_outputs.q.out        |    18 +
 .../clientpositive/explain_rearrange.q.out      |    24 +
 .../explaindenpendencydiffengs.q.out            |     8 +
 .../test/results/clientpositive/extract.q.out   |     8 +
 .../extrapolate_part_stats_date.q.out           |    20 +-
 .../extrapolate_part_stats_full.q.out           |    40 +
 .../extrapolate_part_stats_partial.q.out        |   100 +
 .../clientpositive/fetch_aggregation.q.out      |     4 +
 .../fileformat_sequencefile.q.out               |     4 +
 .../clientpositive/fileformat_text.q.out        |     4 +
 .../results/clientpositive/filter_aggr.q.out    |     4 +
 .../clientpositive/filter_cond_pushdown.q.out   |    58 +-
 .../clientpositive/filter_cond_pushdown2.q.out  |     4 +
 .../filter_cond_pushdown_HIVE_15647.q.out       |    24 +
 .../clientpositive/filter_in_or_dup.q.out       |    18 +
 .../clientpositive/filter_join_breaktask.q.out  |     6 +
 .../results/clientpositive/filter_numeric.q.out |    32 +
 .../results/clientpositive/filter_union.q.out   |    16 +
 .../results/clientpositive/flatten_and_or.q.out |     4 +
 .../results/clientpositive/floor_time.q.out     |     8 +
 .../test/results/clientpositive/fm-sketch.q.out |    12 +
 .../test/results/clientpositive/fold_case.q.out |    52 +
 .../clientpositive/fold_eq_with_case_when.q.out |    20 +
 .../results/clientpositive/fold_to_null.q.out   |   209 +
 .../test/results/clientpositive/fold_when.q.out |    60 +
 .../clientpositive/folder_predicate.q.out       |    28 +
 ql/src/test/results/clientpositive/foldts.q.out |    12 +
 .../clientpositive/fp_literal_arithmetic.q.out  |    16 +
 .../test/results/clientpositive/gby_star.q.out  |    16 +
 .../clientpositive/gen_udf_example_add10.q.out  |     4 +
 .../test/results/clientpositive/groupby1.q.out  |     4 +
 .../test/results/clientpositive/groupby10.q.out |    18 +
 .../test/results/clientpositive/groupby11.q.out |     6 +
 .../test/results/clientpositive/groupby12.q.out |     4 +
 .../test/results/clientpositive/groupby13.q.out |     6 +-
 .../results/clientpositive/groupby1_limit.q.out |     4 +
 .../results/clientpositive/groupby1_map.q.out   |     4 +
 .../clientpositive/groupby1_map_nomap.q.out     |     4 +
 .../clientpositive/groupby1_map_skew.q.out      |     4 +
 .../clientpositive/groupby1_noskew.q.out        |     4 +
 .../results/clientpositive/groupby2_limit.q.out |     4 +
 .../results/clientpositive/groupby2_map.q.out   |     4 +
 .../groupby2_map_multi_distinct.q.out           |     8 +
 .../clientpositive/groupby2_map_skew.q.out      |     4 +
 .../clientpositive/groupby2_noskew.q.out        |     4 +
 .../groupby2_noskew_multi_distinct.q.out        |     4 +
 .../test/results/clientpositive/groupby3.q.out  |     4 +
 .../results/clientpositive/groupby3_map.q.out   |     4 +
 .../groupby3_map_multi_distinct.q.out           |     4 +
 .../clientpositive/groupby3_map_skew.q.out      |     4 +
 .../clientpositive/groupby3_noskew.q.out        |     4 +
 .../groupby3_noskew_multi_distinct.q.out        |     4 +
 .../test/results/clientpositive/groupby4.q.out  |     4 +
 .../results/clientpositive/groupby4_map.q.out   |     4 +
 .../clientpositive/groupby4_map_skew.q.out      |     4 +
 .../clientpositive/groupby4_noskew.q.out        |     4 +
 .../test/results/clientpositive/groupby5.q.out  |     4 +
 .../results/clientpositive/groupby5_map.q.out   |     4 +
 .../clientpositive/groupby5_map_skew.q.out      |     4 +
 .../clientpositive/groupby5_noskew.q.out        |     4 +
 .../test/results/clientpositive/groupby6.q.out  |     4 +
 .../results/clientpositive/groupby6_map.q.out   |     4 +
 .../clientpositive/groupby6_map_skew.q.out      |     4 +
 .../clientpositive/groupby6_noskew.q.out        |     4 +
 .../results/clientpositive/groupby7_map.q.out   |     6 +
 .../groupby7_map_multi_single_reducer.q.out     |     6 +
 .../clientpositive/groupby7_map_skew.q.out      |     6 +
 .../clientpositive/groupby7_noskew.q.out        |     6 +
 .../groupby7_noskew_multi_single_reducer.q.out  |     6 +
 .../test/results/clientpositive/groupby8.q.out  |    12 +
 .../results/clientpositive/groupby8_map.q.out   |     6 +
 .../clientpositive/groupby8_map_skew.q.out      |     6 +
 .../clientpositive/groupby8_noskew.q.out        |     6 +
 .../test/results/clientpositive/groupby9.q.out  |    30 +
 .../clientpositive/groupby_complex_types.q.out  |     8 +
 ...pby_complex_types_multi_single_reducer.q.out |     6 +
 .../results/clientpositive/groupby_cube1.q.out  |    30 +
 .../clientpositive/groupby_cube_multi_gby.q.out |     6 +
 .../groupby_distinct_samekey.q.out              |     8 +
 .../clientpositive/groupby_duplicate_key.q.out  |    14 +
 .../results/clientpositive/groupby_empty.q.out  |     4 +
 .../clientpositive/groupby_grouping_id3.q.out   |     8 +
 .../clientpositive/groupby_grouping_sets1.q.out |    28 +
 .../clientpositive/groupby_grouping_sets2.q.out |    16 +
 .../clientpositive/groupby_grouping_sets3.q.out |    12 +
 .../clientpositive/groupby_grouping_sets4.q.out |    12 +
 .../clientpositive/groupby_grouping_sets5.q.out |    12 +
 .../clientpositive/groupby_grouping_sets6.q.out |     8 +
 .../groupby_grouping_sets_grouping.q.out        |    60 +
 .../groupby_grouping_sets_limit.q.out           |    24 +
 .../groupby_grouping_window.q.out               |     4 +
 .../clientpositive/groupby_join_pushdown.q.out  |    52 +
 .../clientpositive/groupby_map_ppr.q.out        |     8 +
 .../groupby_map_ppr_multi_distinct.q.out        |     8 +
 .../groupby_multi_insert_common_distinct.q.out  |     6 +
 .../groupby_multi_single_reducer.q.out          |    20 +
 .../groupby_multi_single_reducer2.q.out         |     6 +
 .../groupby_multi_single_reducer3.q.out         |    24 +
 .../clientpositive/groupby_multialias.q.out     |     4 +
 .../clientpositive/groupby_position.q.out       |    28 +
 .../results/clientpositive/groupby_ppd.q.out    |     4 +
 .../results/clientpositive/groupby_ppr.q.out    |     8 +
 .../groupby_ppr_multi_distinct.q.out            |    16 +
 .../clientpositive/groupby_rollup1.q.out        |    22 +
 .../clientpositive/groupby_rollup_empty.q.out   |     4 +
 .../clientpositive/groupby_sort_10.q.out        |    14 +
 .../clientpositive/groupby_sort_11.q.out        |    42 +
 .../clientpositive/groupby_sort_1_23.q.out      |    80 +
 .../results/clientpositive/groupby_sort_2.q.out |     4 +
 .../results/clientpositive/groupby_sort_3.q.out |     8 +
 .../results/clientpositive/groupby_sort_4.q.out |     8 +
 .../results/clientpositive/groupby_sort_5.q.out |    12 +
 .../results/clientpositive/groupby_sort_6.q.out |    14 +
 .../results/clientpositive/groupby_sort_7.q.out |     6 +
 .../results/clientpositive/groupby_sort_8.q.out |     6 +
 .../results/clientpositive/groupby_sort_9.q.out |     8 +
 .../clientpositive/groupby_sort_skew_1_23.q.out |    80 +
 .../clientpositive/groupby_sort_test_1.q.out    |     4 +
 ql/src/test/results/clientpositive/having.q.out |    24 +
 .../test/results/clientpositive/having2.q.out   |    26 +
 ql/src/test/results/clientpositive/hll.q.out    |    12 +
 .../identity_project_remove_skip.q.out          |     4 +
 .../results/clientpositive/implicit_cast1.q.out |     4 +
 .../implicit_cast_during_insert.q.out           |     3 +
 .../clientpositive/implicit_decimal.q.out       |     4 +
 .../infer_bucket_sort_dyn_part.q.out            |     7 +
 .../infer_bucket_sort_grouping_operators.q.out  |    12 +
 .../infer_bucket_sort_map_operators.q.out       |    22 +
 .../infer_bucket_sort_num_buckets.q.out         |     7 +
 .../clientpositive/infer_const_type.q.out       |    16 +
 .../clientpositive/infer_join_preds.q.out       |    48 +
 .../test/results/clientpositive/innerjoin.q.out |     8 +
 .../results/clientpositive/innerjoin1.q.out     |    84 +-
 ql/src/test/results/clientpositive/input.q.out  |     4 +
 ql/src/test/results/clientpositive/input0.q.out |     4 +
 ql/src/test/results/clientpositive/input1.q.out |     2 +
 .../test/results/clientpositive/input10.q.out   |     2 +
 .../test/results/clientpositive/input11.q.out   |     4 +
 .../results/clientpositive/input11_limit.q.out  |     4 +
 .../test/results/clientpositive/input12.q.out   |     8 +
 .../test/results/clientpositive/input13.q.out   |    10 +
 .../test/results/clientpositive/input14.q.out   |     4 +
 .../results/clientpositive/input14_limit.q.out  |     4 +
 .../test/results/clientpositive/input15.q.out   |     4 +
 .../test/results/clientpositive/input17.q.out   |     4 +
 .../test/results/clientpositive/input18.q.out   |     4 +
 .../results/clientpositive/input1_limit.q.out   |     6 +
 ql/src/test/results/clientpositive/input2.q.out |     2 +
 .../test/results/clientpositive/input20.q.out   |     4 +
 .../test/results/clientpositive/input21.q.out   |     4 +
 .../test/results/clientpositive/input22.q.out   |     4 +
 .../test/results/clientpositive/input23.q.out   |     6 +
 .../test/results/clientpositive/input24.q.out   |     4 +
 .../test/results/clientpositive/input25.q.out   |     8 +
 .../test/results/clientpositive/input26.q.out   |     6 +
 .../results/clientpositive/input2_limit.q.out   |     4 +
 ql/src/test/results/clientpositive/input3.q.out |    12 +
 .../test/results/clientpositive/input30.q.out   |     8 +
 .../test/results/clientpositive/input32.q.out   |     4 +
 .../test/results/clientpositive/input33.q.out   |     4 +
 .../test/results/clientpositive/input34.q.out   |     4 +
 .../test/results/clientpositive/input35.q.out   |     4 +
 .../test/results/clientpositive/input36.q.out   |     4 +
 .../test/results/clientpositive/input38.q.out   |     4 +
 .../test/results/clientpositive/input39.q.out   |    10 +
 .../results/clientpositive/input3_limit.q.out   |     4 +
 ql/src/test/results/clientpositive/input4.q.out |     8 +
 .../test/results/clientpositive/input42.q.out   |    24 +
 .../results/clientpositive/input4_limit.q.out   |     4 +
 ql/src/test/results/clientpositive/input5.q.out |     4 +
 ql/src/test/results/clientpositive/input6.q.out |     4 +
 ql/src/test/results/clientpositive/input7.q.out |     4 +
 ql/src/test/results/clientpositive/input8.q.out |     4 +
 ql/src/test/results/clientpositive/input9.q.out |     4 +
 .../clientpositive/input_columnarserde.q.out    |     4 +
 .../clientpositive/input_dynamicserde.q.out     |     4 +
 .../clientpositive/input_lazyserde.q.out        |     4 +
 .../clientpositive/input_lazyserde2.q.out       |     4 +
 .../results/clientpositive/input_limit.q.out    |     4 +
 .../results/clientpositive/input_part0.q.out    |     8 +
 .../results/clientpositive/input_part1.q.out    |     6 +
 .../results/clientpositive/input_part10.q.out   |     4 +
 .../results/clientpositive/input_part2.q.out    |    10 +
 .../results/clientpositive/input_part3.q.out    |     6 +
 .../results/clientpositive/input_part4.q.out    |     4 +
 .../results/clientpositive/input_part5.q.out    |     8 +
 .../results/clientpositive/input_part6.q.out    |     8 +
 .../results/clientpositive/input_part7.q.out    |     8 +
 .../results/clientpositive/input_part8.q.out    |     8 +
 .../results/clientpositive/input_part9.q.out    |     8 +
 .../clientpositive/input_testsequencefile.q.out |     4 +
 .../clientpositive/input_testxpath.q.out        |     4 +
 .../clientpositive/input_testxpath2.q.out       |     4 +
 .../clientpositive/input_testxpath3.q.out       |     4 +
 .../clientpositive/input_testxpath4.q.out       |     8 +
 .../test/results/clientpositive/inputddl1.q.out |     4 +
 .../test/results/clientpositive/inputddl2.q.out |     4 +
 .../test/results/clientpositive/inputddl3.q.out |     4 +
 .../test/results/clientpositive/inputddl6.q.out |     2 +
 .../clientpositive/inputwherefalse.q.out        |     4 +
 .../test/results/clientpositive/insert1.q.out   |    22 +
 .../insert2_overwrite_partitions.q.out          |    12 +
 .../results/clientpositive/insert_into1.q.out   |    40 +
 .../results/clientpositive/insert_into2.q.out   |    34 +
 .../results/clientpositive/insert_into3.q.out   |    12 +
 .../results/clientpositive/insert_into4.q.out   |    12 +
 .../results/clientpositive/insert_into5.q.out   |    18 +
 .../results/clientpositive/insert_into6.q.out   |    11 +
 .../clientpositive/insertoverwrite_bucket.q.out |     8 +
 .../results/clientpositive/interval_3.q.out     |     4 +
 .../results/clientpositive/interval_alt.q.out   |     4 +
 .../clientpositive/interval_arithmetic.q.out    |    36 +
 .../results/clientpositive/ivyDownload.q.out    |     4 +
 ql/src/test/results/clientpositive/join0.q.out  |     8 +
 ql/src/test/results/clientpositive/join10.q.out |     4 +
 ql/src/test/results/clientpositive/join11.q.out |     4 +
 ql/src/test/results/clientpositive/join12.q.out |     4 +
 ql/src/test/results/clientpositive/join13.q.out |     4 +
 ql/src/test/results/clientpositive/join14.q.out |    10 +
 ql/src/test/results/clientpositive/join15.q.out |     4 +
 ql/src/test/results/clientpositive/join16.q.out |     4 +
 ql/src/test/results/clientpositive/join17.q.out |     4 +
 ql/src/test/results/clientpositive/join18.q.out |     6 +
 .../clientpositive/join18_multi_distinct.q.out  |     6 +
 ql/src/test/results/clientpositive/join19.q.out |     4 +
 ql/src/test/results/clientpositive/join2.q.out  |     4 +
 ql/src/test/results/clientpositive/join20.q.out |     8 +
 ql/src/test/results/clientpositive/join21.q.out |     4 +
 ql/src/test/results/clientpositive/join22.q.out |     4 +
 ql/src/test/results/clientpositive/join23.q.out |     4 +
 ql/src/test/results/clientpositive/join25.q.out |     6 +
 ql/src/test/results/clientpositive/join26.q.out |    10 +
 ql/src/test/results/clientpositive/join27.q.out |     6 +
 ql/src/test/results/clientpositive/join28.q.out |    10 +
 ql/src/test/results/clientpositive/join29.q.out |     6 +
 ql/src/test/results/clientpositive/join3.q.out  |     4 +
 ql/src/test/results/clientpositive/join30.q.out |     6 +
 ql/src/test/results/clientpositive/join31.q.out |     6 +
 ql/src/test/results/clientpositive/join32.q.out |    10 +
 ql/src/test/results/clientpositive/join33.q.out |    10 +
 ql/src/test/results/clientpositive/join34.q.out |     6 +
 ql/src/test/results/clientpositive/join35.q.out |     6 +
 ql/src/test/results/clientpositive/join36.q.out |     6 +
 ql/src/test/results/clientpositive/join37.q.out |     6 +
 ql/src/test/results/clientpositive/join38.q.out |     6 +
 ql/src/test/results/clientpositive/join39.q.out |     4 +
 ql/src/test/results/clientpositive/join4.q.out  |     4 +
 ql/src/test/results/clientpositive/join40.q.out |    24 +
 ql/src/test/results/clientpositive/join41.q.out |     8 +
 ql/src/test/results/clientpositive/join42.q.out |    14 +
 ql/src/test/results/clientpositive/join43.q.out |    16 +
 ql/src/test/results/clientpositive/join44.q.out |     4 +
 ql/src/test/results/clientpositive/join45.q.out |    84 +
 ql/src/test/results/clientpositive/join46.q.out |   114 +
 ql/src/test/results/clientpositive/join47.q.out |    84 +
 ql/src/test/results/clientpositive/join5.q.out  |     4 +
 ql/src/test/results/clientpositive/join6.q.out  |     4 +
 ql/src/test/results/clientpositive/join7.q.out  |     4 +
 ql/src/test/results/clientpositive/join8.q.out  |     4 +
 ql/src/test/results/clientpositive/join9.q.out  |     8 +
 .../clientpositive/join_alt_syntax.q.out        |    24 +
 .../clientpositive/join_cond_pushdown_1.q.out   |    16 +
 .../clientpositive/join_cond_pushdown_2.q.out   |     8 +
 .../clientpositive/join_cond_pushdown_3.q.out   |    16 +
 .../clientpositive/join_cond_pushdown_4.q.out   |     8 +
 .../join_cond_pushdown_unqual1.q.out            |    32 +
 .../join_cond_pushdown_unqual2.q.out            |    16 +
 .../join_cond_pushdown_unqual3.q.out            |    32 +
 .../join_cond_pushdown_unqual4.q.out            |    16 +
 .../join_cond_pushdown_unqual5.q.out            |    16 +-
 .../clientpositive/join_emit_interval.q.out     |    12 +
 .../clientpositive/join_filters_overlap.q.out   |    20 +
 .../clientpositive/join_grp_diff_keys.q.out     |    10 +
 .../results/clientpositive/join_hive_626.q.out  |     8 +
 .../results/clientpositive/join_map_ppr.q.out   |    20 +
 .../join_merge_multi_expressions.q.out          |    12 +
 .../results/clientpositive/join_merging.q.out   |     8 +
 .../clientpositive/join_on_varchar.q.out        |     6 +
 .../results/clientpositive/join_parse.q.out     |    56 +
 .../test/results/clientpositive/join_rc.q.out   |     6 +
 .../results/clientpositive/join_reorder.q.out   |    44 +
 .../results/clientpositive/join_reorder2.q.out  |    20 +
 .../results/clientpositive/join_reorder3.q.out  |    20 +
 .../results/clientpositive/join_reorder4.q.out  |    24 +
 .../test/results/clientpositive/join_star.q.out |    48 +
 .../results/clientpositive/join_thrift.q.out    |     4 +
 .../test/results/clientpositive/join_vc.q.out   |     8 +
 .../test/results/clientpositive/join_view.q.out |     8 +
 .../test/results/clientpositive/keyword_1.q.out |     8 +
 .../results/clientpositive/kill_query.q.out     |     2 +
 .../clientpositive/lateral_view_cp.q.out        |     6 +
 .../clientpositive/lateral_view_explode2.q.out  |     4 +
 .../clientpositive/lateral_view_noalias.q.out   |    14 +
 .../clientpositive/lateral_view_onview.q.out    |    36 +
 .../clientpositive/lateral_view_onview2.q.out   |     6 +
 .../clientpositive/lateral_view_outer.q.out     |    12 +
 .../clientpositive/lateral_view_ppd.q.out       |    22 +
 .../results/clientpositive/leftsemijoin.q.out   |     8 +
 ql/src/test/results/clientpositive/limit0.q.out |    20 +
 .../clientpositive/limit_pushdown2.q.out        |    44 +
 .../limit_pushdown_negative.q.out               |    18 +
 .../test/results/clientpositive/lineage1.q.out  |     6 +
 .../clientpositive/list_bucket_dml_1.q.out      |    13 +
 .../clientpositive/list_bucket_dml_11.q.out     |    10 +
 .../clientpositive/list_bucket_dml_12.q.out     |    16 +
 .../clientpositive/list_bucket_dml_13.q.out     |    10 +
 .../clientpositive/list_bucket_dml_14.q.out     |     8 +
 .../clientpositive/list_bucket_dml_2.q.out      |    14 +
 .../clientpositive/list_bucket_dml_3.q.out      |    14 +
 .../clientpositive/list_bucket_dml_4.q.out      |    22 +
 .../clientpositive/list_bucket_dml_5.q.out      |    15 +
 .../clientpositive/list_bucket_dml_6.q.out      |    22 +
 .../clientpositive/list_bucket_dml_7.q.out      |    22 +
 .../clientpositive/list_bucket_dml_8.q.out      |    15 +
 .../clientpositive/list_bucket_dml_9.q.out      |    22 +
 .../list_bucket_query_multiskew_1.q.out         |    24 +
 .../list_bucket_query_multiskew_2.q.out         |    18 +
 .../list_bucket_query_multiskew_3.q.out         |    22 +
 .../list_bucket_query_oneskew_1.q.out           |    18 +
 .../list_bucket_query_oneskew_2.q.out           |    24 +
 .../list_bucket_query_oneskew_3.q.out           |     6 +
 .../clientpositive/literal_decimal.q.out        |    10 +-
 .../results/clientpositive/literal_double.q.out |     4 +
 .../results/clientpositive/literal_ints.q.out   |     4 +
 .../results/clientpositive/literal_string.q.out |     4 +
 .../llap/acid_bucket_pruning.q.out              |     4 +
 .../llap/acid_meta_columns_decode.q.out         |   128 +
 .../clientpositive/llap/acid_no_buckets.q.out   |   170 +
 .../llap/acid_vectorization_original.q.out      |   162 +
 .../llap/alter_table_location2.q.out            |    97 +
 .../llap/alter_table_location3.q.out            |    95 +
 .../clientpositive/llap/approx_distinct.q.out   |   490 +
 .../clientpositive/llap/autoColumnStats_1.q.out |    72 +
 .../clientpositive/llap/autoColumnStats_2.q.out |    78 +
 .../clientpositive/llap/auto_join0.q.out        |     4 +
 .../clientpositive/llap/auto_join1.q.out        |     4 +
 .../clientpositive/llap/auto_join21.q.out       |     4 +
 .../clientpositive/llap/auto_join29.q.out       |    36 +
 .../clientpositive/llap/auto_join30.q.out       |    32 +
 .../clientpositive/llap/auto_join_filters.q.out |    12 +
 .../clientpositive/llap/auto_join_nulls.q.out   |     4 +
 .../llap/auto_smb_mapjoin_14.q.out              |    80 +
 .../llap/auto_sortmerge_join_1.q.out            |    36 +
 .../llap/auto_sortmerge_join_10.q.out           |    12 +
 .../llap/auto_sortmerge_join_11.q.out           |    48 +
 .../llap/auto_sortmerge_join_12.q.out           |    16 +
 .../llap/auto_sortmerge_join_13.q.out           |   141 +-
 .../llap/auto_sortmerge_join_14.q.out           |    16 +-
 .../llap/auto_sortmerge_join_15.q.out           |    16 +-
 .../llap/auto_sortmerge_join_16.q.out           |    68 +-
 .../llap/auto_sortmerge_join_2.q.out            |    24 +
 .../llap/auto_sortmerge_join_3.q.out            |    36 +
 .../llap/auto_sortmerge_join_4.q.out            |    36 +
 .../llap/auto_sortmerge_join_5.q.out            |    18 +
 .../llap/auto_sortmerge_join_6.q.out            |    80 +
 .../llap/auto_sortmerge_join_7.q.out            |    42 +
 .../llap/auto_sortmerge_join_8.q.out            |    42 +
 .../llap/auto_sortmerge_join_9.q.out            |   146 +
 .../results/clientpositive/llap/bucket2.q.out   |     8 +
 .../results/clientpositive/llap/bucket3.q.out   |    10 +
 .../results/clientpositive/llap/bucket4.q.out   |     8 +
 .../results/clientpositive/llap/bucket5.q.out   |     6 +
 .../results/clientpositive/llap/bucket6.q.out   |    12 +
 .../clientpositive/llap/bucket_groupby.q.out    |   330 +-
 .../clientpositive/llap/bucket_many.q.out       |     8 +
 .../llap/bucket_map_join_tez2.q.out             |   303 +-
 .../llap/bucket_map_join_tez_empty.q.out        |     6 +
 .../llap/bucket_num_reducers.q.out              |     4 +
 .../llap/bucket_num_reducers2.q.out             |     4 +
 .../clientpositive/llap/bucketmapjoin1.q.out    |    28 +
 .../clientpositive/llap/bucketmapjoin2.q.out    |    32 +
 .../clientpositive/llap/bucketmapjoin3.q.out    |    20 +
 .../clientpositive/llap/bucketmapjoin4.q.out    |     8 +
 .../clientpositive/llap/bucketmapjoin7.q.out    |    10 +
 .../clientpositive/llap/bucketpruning1.q.out    |   108 +
 .../llap/bucketsortoptimize_insert_2.q.out      |    64 +
 .../llap/bucketsortoptimize_insert_6.q.out      |    70 +
 .../llap/bucketsortoptimize_insert_7.q.out      |    30 +
 .../results/clientpositive/llap/cbo_limit.q.out |     4 +-
 .../clientpositive/llap/cbo_rp_limit.q.out      |     4 +-
 .../clientpositive/llap/cbo_rp_views.q.out      |     2 +-
 .../clientpositive/llap/cbo_simple_select.q.out |    36 +
 .../results/clientpositive/llap/cbo_views.q.out |     2 +-
 .../clientpositive/llap/check_constraint.q.out  |   126 +-
 .../results/clientpositive/llap/cluster.q.out   |   430 +-
 .../llap/colstats_date_min_max.q.out            |    12 +
 .../columnStatsUpdateForStatsOptimizer_1.q.out  |    48 +
 .../llap/column_access_stats.q.out              |    21 +
 .../llap/column_table_stats.q.out               |    44 +
 .../llap/column_table_stats_orc.q.out           |    30 +
 .../clientpositive/llap/constprog_dpp.q.out     |     6 +
 .../llap/constprog_semijoin.q.out               |    52 +
 .../llap/constraints_optimization.q.out         |  2010 ++
 .../llap/convert_decimal64_to_decimal.q.out     |    12 +
 .../llap/correlationoptimizer1.q.out            |   222 +-
 .../llap/correlationoptimizer2.q.out            |   148 +-
 .../llap/correlationoptimizer3.q.out            |    36 +
 .../llap/correlationoptimizer4.q.out            |   104 +
 .../llap/correlationoptimizer6.q.out            |   108 +
 .../results/clientpositive/llap/count.q.out     |    48 +
 .../llap/count_dist_rewrite.q.out               |    36 +
 .../clientpositive/llap/cross_join.q.out        |    24 +
 .../clientpositive/llap/cross_prod_1.q.out      |    44 +
 .../clientpositive/llap/cross_prod_3.q.out      |     6 +
 .../clientpositive/llap/cross_prod_4.q.out      |     4 +
 .../llap/cross_product_check_1.q.out            |    30 +
 .../llap/cross_product_check_2.q.out            |    30 +
 .../test/results/clientpositive/llap/ctas.q.out |    30 +
 .../results/clientpositive/llap/cte_1.q.out     | 24946 +++++++++--------
 .../results/clientpositive/llap/cte_3.q.out     |    12 +
 .../results/clientpositive/llap/cte_5.q.out     |     6 +
 .../results/clientpositive/llap/cte_mat_1.q.out |     4 +
 .../results/clientpositive/llap/cte_mat_2.q.out |     4 +
 .../results/clientpositive/llap/cte_mat_3.q.out |     4 +
 .../results/clientpositive/llap/cte_mat_4.q.out |     8 +
 .../results/clientpositive/llap/cte_mat_5.q.out |     6 +
 .../test/results/clientpositive/llap/cttl.q.out |     4 +-
 .../llap/current_date_timestamp.q.out           |     4 +
 .../results/clientpositive/llap/dec_str.q.out   |    20 +
 .../llap/default_constraint.q.out               |    72 +
 .../clientpositive/llap/deleteAnalyze.q.out     |     4 +
 .../llap/disable_merge_for_bucketing.q.out      |     8 +
 .../clientpositive/llap/dp_counter_mm.q.out     |    16 +-
 .../clientpositive/llap/dp_counter_non_mm.q.out |    16 +-
 .../test/results/clientpositive/llap/dpp.q.out  |    20 +
 .../llap/dynamic_partition_pruning.q.out        |   558 +
 .../llap/dynamic_partition_pruning_2.q.out      |    80 +
 .../llap/dynamic_semijoin_reduction.q.out       |   350 +
 .../llap/dynamic_semijoin_reduction_2.q.out     |    12 +
 .../llap/dynamic_semijoin_reduction_3.q.out     |    30 +
 .../llap/dynamic_semijoin_reduction_4.q.out     |    78 +
 .../llap/dynamic_semijoin_reduction_sw.q.out    |    14 +
 .../llap/dynamic_semijoin_reduction_sw2.q.out   |    14 +
 .../llap/dynamic_semijoin_user_level.q.out      |   210 +
 .../llap/dynpart_sort_opt_vectorization.q.out   |   124 +-
 .../llap/dynpart_sort_optimization.q.out        |   555 +-
 .../llap/dynpart_sort_optimization2.q.out       |    32 +-
 .../llap/dynpart_sort_optimization_acid.q.out   |   134 +-
 .../clientpositive/llap/empty_join.q.out        |     8 +
 .../llap/enforce_constraint_notnull.q.out       |   152 +
 .../clientpositive/llap/except_distinct.q.out   |    16 +-
 .../clientpositive/llap/explainanalyze_2.q.out  |   118 +
 .../clientpositive/llap/explainuser_1.q.out     |   756 +-
 .../clientpositive/llap/explainuser_2.q.out     |   212 +
 .../clientpositive/llap/explainuser_4.q.out     |    28 +
 .../llap/external_jdbc_auth.q.out               |   283 +
 .../llap/external_jdbc_table.q.out              |   536 +
 .../llap/external_jdbc_table2.q.out             |   604 +
 .../llap/external_jdbc_table_partition.q.out    |   319 +
 .../external_jdbc_table_typeconversion.q.out    |   280 +
 .../extrapolate_part_stats_partial_ndv.q.out    |    58 +-
 .../llap/filter_join_breaktask.q.out            |     6 +
 .../clientpositive/llap/filter_union.q.out      |    16 +
 .../llap/fullouter_mapjoin_1_optimized.q.out    |    48 +
 .../results/clientpositive/llap/groupby1.q.out  |     4 +
 .../results/clientpositive/llap/groupby2.q.out  |     4 +
 .../results/clientpositive/llap/groupby3.q.out  |     4 +
 .../llap/groupby_groupingset_bug.q.out          |    12 +
 .../llap/groupby_resolution.q.out               |    40 +
 .../llap/groupby_rollup_empty.q.out             |     4 +
 .../results/clientpositive/llap/having.q.out    |    24 +
 .../llap/hybridgrace_hashjoin_1.q.out           |    64 +
 .../llap/hybridgrace_hashjoin_2.q.out           |   132 +-
 .../llap/identity_project_remove_skip.q.out     |     4 +
 .../results/clientpositive/llap/insert1.q.out   |    22 +
 .../llap/insert1_overwrite_partitions.q.out     |    18 +
 .../clientpositive/llap/insert_into1.q.out      |    40 +
 .../clientpositive/llap/insert_into2.q.out      |    34 +
 .../llap/insert_into_default_keyword.q.out      |   243 +-
 .../insert_values_orig_table_use_metadata.q.out |    30 +
 .../clientpositive/llap/intersect_all.q.out     |  1036 +-
 .../llap/intersect_distinct.q.out               |   546 +-
 .../clientpositive/llap/intersect_merge.q.out   |    48 +
 .../clientpositive/llap/is_distinct_from.q.out  |    24 +
 .../clientpositive/llap/jdbc_handler.q.out      |    24 +-
 .../results/clientpositive/llap/join0.q.out     |     7 +
 .../results/clientpositive/llap/join1.q.out     |     4 +
 .../clientpositive/llap/join32_lessSize.q.out   |   923 +-
 .../results/clientpositive/llap/join46.q.out    |   150 +-
 .../llap/join_constraints_optimization.q.out    |    76 +
 .../llap/join_emit_interval.q.out               |    16 +-
 .../llap/join_is_not_distinct_from.q.out        |    24 +
 .../llap/join_max_hashtable.q.out               |   129 +-
 .../clientpositive/llap/join_nullsafe.q.out     |    24 +
 .../llap/join_reordering_no_stats.q.out         |    56 +
 .../clientpositive/llap/kill_query.q.out        |     2 +
 .../test/results/clientpositive/llap/kryo.q.out |     4 +
 .../clientpositive/llap/lateral_view.q.out      |    30 +-
 .../clientpositive/llap/leftsemijoin.q.out      |     8 +
 .../llap/limit_join_transpose.q.out             |   108 +-
 .../clientpositive/llap/limit_pushdown.q.out    |    56 +
 .../clientpositive/llap/limit_pushdown3.q.out   |    52 +
 .../results/clientpositive/llap/lineage2.q.out  |    28 +-
 .../results/clientpositive/llap/lineage3.q.out  |     2 +-
 .../llap/list_bucket_dml_10.q.out               |     4 +
 .../results/clientpositive/llap/llap_acid.q.out |    34 +
 .../clientpositive/llap/llap_acid_fast.q.out    |    34 +
 .../llap/llap_decimal64_reader.q.out            |    12 +-
 .../clientpositive/llap/llap_nullscan.q.out     |    16 +
 .../clientpositive/llap/llap_partitioned.q.out  |   294 +-
 .../results/clientpositive/llap/llap_smb.q.out  |    88 +-
 .../clientpositive/llap/llap_smb_ptf.q.out      |    20 +-
 .../clientpositive/llap/llap_stats.q.out        |    50 +-
 .../results/clientpositive/llap/llap_udf.q.out  |    24 +
 .../clientpositive/llap/llap_uncompressed.q.out |     8 +
 .../llap/llap_vector_nohybridgrace.q.out        |     8 +
 .../clientpositive/llap/llapdecider.q.out       |    68 +
 .../llap/load_data_using_job.q.out              |  3596 +--
 .../clientpositive/llap/load_dyn_part1.q.out    |    12 +
 .../clientpositive/llap/load_dyn_part2.q.out    |    11 +
 .../clientpositive/llap/load_dyn_part3.q.out    |    11 +
 .../clientpositive/llap/load_dyn_part5.q.out    |    63 +-
 .../clientpositive/llap/lvj_mapjoin.q.out       |     6 +
 .../results/clientpositive/llap/mapjoin2.q.out  |    28 +
 .../results/clientpositive/llap/mapjoin3.q.out  |     6 +
 .../results/clientpositive/llap/mapjoin46.q.out |   190 +-
 .../clientpositive/llap/mapjoin_decimal.q.out   |     6 +
 .../llap/mapjoin_emit_interval.q.out            |    16 +-
 .../clientpositive/llap/mapjoin_hint.q.out      |    40 +
 .../clientpositive/llap/mapjoin_mapjoin.q.out   |    46 +
 .../clientpositive/llap/mapreduce1.q.out        |     4 +
 .../clientpositive/llap/mapreduce2.q.out        |     4 +
 .../llap/materialized_view_create.q.out         |     2 +-
 .../llap/materialized_view_create_rewrite.q.out |    24 +
 .../materialized_view_create_rewrite_2.q.out    |    46 +-
 .../materialized_view_create_rewrite_3.q.out    |    66 +
 .../materialized_view_create_rewrite_4.q.out    |    88 +
 .../materialized_view_create_rewrite_5.q.out    |    62 +
 ...materialized_view_create_rewrite_dummy.q.out |    24 +
 ...erialized_view_create_rewrite_multi_db.q.out |     6 +
 ...ized_view_create_rewrite_rebuild_dummy.q.out |    66 +
 ...alized_view_create_rewrite_time_window.q.out |    42 +
 .../llap/materialized_view_describe.q.out       |     2 +-
 .../llap/materialized_view_partitioned.q.out    |    95 +
 .../llap/materialized_view_partitioned_2.q.out  |    58 +
 .../llap/materialized_view_partitioned_3.q.out  |     9 +-
 .../llap/materialized_view_rewrite_1.q.out      |    74 +-
 .../llap/materialized_view_rewrite_10.q.out     |    24 +
 .../llap/materialized_view_rewrite_2.q.out      |    50 +
 .../llap/materialized_view_rewrite_3.q.out      |    34 +
 .../llap/materialized_view_rewrite_4.q.out      |    52 +
 .../llap/materialized_view_rewrite_5.q.out      |   102 +
 .../llap/materialized_view_rewrite_6.q.out      |    44 +
 .../llap/materialized_view_rewrite_7.q.out      |   254 +-
 .../llap/materialized_view_rewrite_8.q.out      |    66 +
 .../llap/materialized_view_rewrite_9.q.out      |    22 +
 .../llap/materialized_view_rewrite_empty.q.out  |     6 +
 .../materialized_view_rewrite_no_join_opt.q.out |    36 +
 ...aterialized_view_rewrite_no_join_opt_2.q.out |    84 +
 .../llap/materialized_view_rewrite_part_1.q.out |    84 +
 .../llap/materialized_view_rewrite_part_2.q.out |    68 +
 .../llap/materialized_view_rewrite_ssb.q.out    |   150 +
 .../llap/materialized_view_rewrite_ssb_2.q.out  |   150 +
 .../results/clientpositive/llap/merge1.q.out    |    20 +
 .../results/clientpositive/llap/merge2.q.out    |    20 +
 .../results/clientpositive/llap/mergejoin.q.out |   120 +
 .../llap/metadata_only_queries.q.out            |    70 +
 .../metadata_only_queries_with_filters.q.out    |     8 +
 .../clientpositive/llap/metadataonly1.q.out     |    72 +
 .../results/clientpositive/llap/mm_all.q.out    |    10 +
 .../results/clientpositive/llap/mm_bhif.q.out   |     6 +
 .../results/clientpositive/llap/mm_dp.q.out     |  4695 ++++
 .../test/results/clientpositive/llap/mrr.q.out  |    20 +
 .../clientpositive/llap/multiMapJoin1.q.out     |   420 +-
 .../clientpositive/llap/multiMapJoin2.q.out     |    56 +
 .../clientpositive/llap/multi_column_in.q.out   |    12 +
 .../llap/multi_column_in_single.q.out           |    12 +
 .../llap/multi_count_distinct_null.q.out        |    20 +-
 .../clientpositive/llap/multi_insert.q.out      |    88 +
 .../llap/multi_insert_lateral_view.q.out        |    38 +
 .../llap/murmur_hash_migration.q.out            |    32 +
 .../llap/nonmr_fetch_threshold.q.out            |    58 +
 .../clientpositive/llap/offset_limit.q.out      |     4 +
 .../llap/offset_limit_ppd_optimizer.q.out       |    56 +
 .../clientpositive/llap/optimize_join_ptp.q.out |     6 +
 .../clientpositive/llap/optimize_nullscan.q.out |    64 +
 .../clientpositive/llap/orc_analyze.q.out       |     6 +-
 .../results/clientpositive/llap/orc_llap.q.out  |    44 +
 .../clientpositive/llap/orc_llap_counters.q.out |     2 +-
 .../llap/orc_llap_counters1.q.out               |     2 +-
 .../llap/orc_llap_nonvector.q.out               |    12 +
 .../clientpositive/llap/orc_merge1.q.out        |   196 +-
 .../clientpositive/llap/orc_merge10.q.out       |   351 +-
 .../clientpositive/llap/orc_merge2.q.out        |    63 +-
 .../clientpositive/llap/orc_merge3.q.out        |     8 +
 .../clientpositive/llap/orc_merge4.q.out        |     8 +
 .../clientpositive/llap/orc_merge5.q.out        |    12 +
 .../clientpositive/llap/orc_merge6.q.out        |    12 +
 .../clientpositive/llap/orc_merge7.q.out        |   118 +-
 .../clientpositive/llap/orc_merge_diff_fs.q.out |   185 +-
 .../llap/orc_merge_incompat1.q.out              |     4 +
 .../llap/orc_merge_incompat2.q.out              |    61 +-
 .../clientpositive/llap/orc_ppd_date.q.out      |    40 +-
 .../llap/orc_predicate_pushdown.q.out           |    48 +
 .../llap/orc_struct_type_vectorization.q.out    |     8 +
 .../results/clientpositive/llap/parallel.q.out  |     6 +
 .../clientpositive/llap/parallel_colstats.q.out |     6 +
 .../parquet_complex_types_vectorization.q.out   |    24 +
 .../llap/parquet_map_type_vectorization.q.out   |     8 +
 .../llap/parquet_predicate_pushdown.q.out       |    52 +
 .../parquet_struct_type_vectorization.q.out     |     8 +
 .../clientpositive/llap/parquet_types.q.out     |     2 +-
 .../llap/parquet_types_vectorization.q.out      |    30 +-
 .../clientpositive/llap/partialdhj.q.out        |    12 +
 .../clientpositive/llap/partition_ctas.q.out    |   159 +
 .../llap/partition_multilevels.q.out            |   244 +-
 .../clientpositive/llap/partition_pruning.q.out |    22 +
 .../llap/partition_shared_scan.q.out            |    18 +
 .../clientpositive/llap/ppd_union_view.q.out    |    26 +
 .../test/results/clientpositive/llap/ptf.q.out  |    96 +
 .../clientpositive/llap/ptf_matchpath.q.out     |    12 +
 .../clientpositive/llap/ptf_streaming.q.out     |    48 +
 .../llap/q93_with_constraints.q.out             |     8 +
 .../clientpositive/llap/quotedid_smb.q.out      |     6 +
 .../clientpositive/llap/rcfile_createas1.q.out  |    10 +
 .../clientpositive/llap/rcfile_merge2.q.out     |     3 +
 .../clientpositive/llap/rcfile_merge3.q.out     |     8 +
 .../clientpositive/llap/rcfile_merge4.q.out     |     8 +
 .../llap/reduce_deduplicate.q.out               |     8 +
 .../llap/reduce_deduplicate_distinct.q.out      |    20 +
 .../llap/reduce_deduplicate_extended.q.out      |   100 +-
 .../results/clientpositive/llap/reopt_dpp.q.out |    20 +
 .../clientpositive/llap/reopt_semijoin.q.out    |    12 +
 .../clientpositive/llap/resourceplan.q.out      |    96 +-
 .../clientpositive/llap/results_cache_1.q.out   |    38 +-
 .../clientpositive/llap/results_cache_2.q.out   |    18 +
 .../llap/results_cache_capacity.q.out           |    18 +
 .../llap/results_cache_diff_fs.q.out            |     6 +
 .../llap/results_cache_empty_result.q.out       |     6 +
 .../llap/results_cache_invalidation.q.out       |    46 +
 .../llap/results_cache_invalidation2.q.out      |    20 +
 .../llap/results_cache_lifetime.q.out           |     4 +
 .../llap/results_cache_quoted_identifiers.q.out |     6 +
 .../llap/results_cache_temptable.q.out          |    18 +
 .../llap/results_cache_transactional.q.out      |    36 +
 .../llap/results_cache_truncate.q.out           |    28 +
 .../llap/results_cache_with_masking.q.out       |    12 +-
 .../llap/retry_failure_stat_changes.q.out       |    24 +
 .../clientpositive/llap/runtime_stats_hs2.q.out |    12 +
 .../llap/runtime_stats_merge.q.out              |     8 +
 .../results/clientpositive/llap/sample1.q.out   |     6 +
 .../results/clientpositive/llap/sample10.q.out  |    12 +
 .../clientpositive/llap/sample10_mm.q.out       |    24 +
 .../llap/schema_evol_orc_acid_part.q.out        |     6 +
 .../schema_evol_orc_acid_part_llap_io.q.out     |     6 +
 .../llap/schema_evol_orc_acid_table.q.out       |     4 +
 .../schema_evol_orc_acid_table_llap_io.q.out    |     4 +
 .../schema_evol_orc_acidvec_part_llap_io.q.out  |    84 +
 .../llap/schema_evol_orc_acidvec_table.q.out    |    56 +
 .../schema_evol_orc_acidvec_table_llap_io.q.out |    56 +
 .../llap/schema_evol_orc_nonvec_part.q.out      |    60 +-
 ...chema_evol_orc_nonvec_part_all_complex.q.out |    24 +
 ...ol_orc_nonvec_part_all_complex_llap_io.q.out |    24 +
 ...ema_evol_orc_nonvec_part_all_primitive.q.out |    38 +-
 ..._orc_nonvec_part_all_primitive_llap_io.q.out |    38 +-
 .../schema_evol_orc_nonvec_part_llap_io.q.out   |    60 +-
 .../llap/schema_evol_orc_nonvec_table.q.out     |    20 +
 .../schema_evol_orc_nonvec_table_llap_io.q.out  |    20 +
 .../llap/schema_evol_orc_vec_part.q.out         |    60 +-
 .../schema_evol_orc_vec_part_all_complex.q.out  |    24 +
 ..._evol_orc_vec_part_all_complex_llap_io.q.out |    24 +
 ...schema_evol_orc_vec_part_all_primitive.q.out |    38 +-
 ...vol_orc_vec_part_all_primitive_llap_io.q.out |    38 +-
 .../llap/schema_evol_orc_vec_table.q.out        |    20 +
 .../schema_evol_orc_vec_table_llap_io.q.out     |    20 +
 .../clientpositive/llap/schema_evol_stats.q.out |     8 +
 .../llap/schema_evol_text_nonvec_part.q.out     |    60 +-
 ...hema_evol_text_nonvec_part_all_complex.q.out |    24 +
 ...l_text_nonvec_part_all_complex_llap_io.q.out |    24 +
 ...ma_evol_text_nonvec_part_all_primitive.q.out |    38 +-
 ...text_nonvec_part_all_primitive_llap_io.q.out |    74 +-
 .../schema_evol_text_nonvec_part_llap_io.q.out  |    60 +-
 .../llap/schema_evol_text_nonvec_table.q.out    |    20 +
 .../schema_evol_text_nonvec_table_llap_io.q.out |    20 +
 .../llap/schema_evol_text_vec_part.q.out        |    60 +-
 .../schema_evol_text_vec_part_all_complex.q.out |    24 +
 ...evol_text_vec_part_all_complex_llap_io.q.out |    50 +
 ...chema_evol_text_vec_part_all_primitive.q.out |    38 +-
 ...ol_text_vec_part_all_primitive_llap_io.q.out |    74 +-
 .../schema_evol_text_vec_part_llap_io.q.out     |    60 +-
 .../llap/schema_evol_text_vec_table.q.out       |    20 +
 .../schema_evol_text_vec_table_llap_io.q.out    |    62 +-
 .../llap/schema_evol_text_vecrow_part.q.out     |    60 +-
 ...hema_evol_text_vecrow_part_all_complex.q.out |    24 +
 ...l_text_vecrow_part_all_complex_llap_io.q.out |    42 +
 ...ma_evol_text_vecrow_part_all_primitive.q.out |    38 +-
 ...text_vecrow_part_all_primitive_llap_io.q.out |    74 +-
 .../schema_evol_text_vecrow_part_llap_io.q.out  |   120 +-
 .../llap/schema_evol_text_vecrow_table.q.out    |    20 +
 .../schema_evol_text_vecrow_table_llap_io.q.out |    72 +-
 .../llap/selectDistinctStar.q.out               |    40 +
 .../llap/select_dummy_source.q.out              |    28 +
 .../results/clientpositive/llap/semijoin.q.out  |   148 +
 .../results/clientpositive/llap/semijoin6.q.out |    40 +
 .../results/clientpositive/llap/semijoin7.q.out |    40 +
 .../clientpositive/llap/semijoin_hint.q.out     |   316 +
 .../clientpositive/llap/sharedworkext.q.out     |     8 +
 .../results/clientpositive/llap/skewjoin.q.out  |    46 +
 .../clientpositive/llap/skewjoinopt15.q.out     |    24 +
 .../clientpositive/llap/skiphf_aggr.q.out       |     6 +-
 .../results/clientpositive/llap/smb_cache.q.out |    12 +
 .../clientpositive/llap/smb_mapjoin_14.q.out    |    70 +
 .../clientpositive/llap/smb_mapjoin_15.q.out    |    24 +
 .../clientpositive/llap/smb_mapjoin_17.q.out    |    68 +
 .../clientpositive/llap/smb_mapjoin_18.q.out    |    18 +
 .../clientpositive/llap/smb_mapjoin_19.q.out    |     6 +
 .../clientpositive/llap/smb_mapjoin_4.q.out     |   104 +
 .../clientpositive/llap/smb_mapjoin_5.q.out     |   104 +
 .../clientpositive/llap/smb_mapjoin_6.q.out     |    30 +
 .../results/clientpositive/llap/sqlmerge.q.out  |    18 +
 .../clientpositive/llap/sqlmerge_stats.q.out    |  2075 +-
 .../results/clientpositive/llap/stats11.q.out   |    20 +
 .../llap/stats_based_fetch_decision.q.out       |    32 +
 .../clientpositive/llap/stats_date.q.out        |    12 +
 .../clientpositive/llap/stats_noscan_1.q.out    |    20 +
 .../llap/stats_only_external.q.out              |    16 +
 .../clientpositive/llap/stats_only_null.q.out   |    20 +
 .../clientpositive/llap/subquery_corr.q.out     |    12 +
 .../clientpositive/llap/subquery_exists.q.out   |    28 +
 .../clientpositive/llap/subquery_in.q.out       |   204 +-
 .../llap/subquery_in_having.q.out               |    32 +
 .../clientpositive/llap/subquery_multi.q.out    |   110 +-
 .../clientpositive/llap/subquery_notin.q.out    |   532 +-
 .../clientpositive/llap/subquery_null_agg.q.out |     4 +
 .../clientpositive/llap/subquery_scalar.q.out   |   280 +-
 .../clientpositive/llap/subquery_select.q.out   |   244 +-
 .../clientpositive/llap/subquery_views.q.out    |     6 +
 .../results/clientpositive/llap/sysdb.q.out     |    18 +-
 .../clientpositive/llap/temp_table.q.out        |    22 +
 .../llap/tez_bmj_schema_evolution.q.out         |    10 +
 .../results/clientpositive/llap/tez_dml.q.out   |    75 +-
 .../llap/tez_dynpart_hashjoin_1.q.out           |    28 +
 .../llap/tez_dynpart_hashjoin_2.q.out           |    18 +
 .../llap/tez_dynpart_hashjoin_3.q.out           |    24 +-
 .../llap/tez_fixed_bucket_pruning.q.out         |    56 +-
 .../llap/tez_input_counters.q.out               |   388 +-
 .../results/clientpositive/llap/tez_join.q.out  |     6 +
 .../clientpositive/llap/tez_join_hash.q.out     |    20 +
 .../llap/tez_join_result_complex.q.out          |    16 +
 .../clientpositive/llap/tez_join_tests.q.out    |    18 +-
 .../clientpositive/llap/tez_joins_explain.q.out |    18 +-
 .../clientpositive/llap/tez_nway_join.q.out     |    24 +
 .../clientpositive/llap/tez_self_join.q.out     |     6 +
 .../clientpositive/llap/tez_smb_empty.q.out     |    48 +-
 .../clientpositive/llap/tez_smb_main.q.out      |   154 +
 .../llap/tez_smb_reduce_side.q.out              |    32 +-
 .../results/clientpositive/llap/tez_union.q.out |    40 +
 .../clientpositive/llap/tez_union2.q.out        |   632 +-
 .../llap/tez_union_dynamic_partition.q.out      |     3 +
 .../llap/tez_union_dynamic_partition_2.q.out    |     3 +
 .../llap/tez_union_group_by.q.out               |    10 +
 .../llap/tez_union_multiinsert.q.out            |    30 +
 .../llap/tez_vector_dynpart_hashjoin_1.q.out    |    24 +
 .../llap/tez_vector_dynpart_hashjoin_2.q.out    |    18 +
 .../results/clientpositive/llap/topnkey.q.out   |    12 +
 .../llap/udaf_collect_set_2.q.out               |    60 +-
 .../clientpositive/llap/udf_coalesce.q.out      |     8 +
 .../results/clientpositive/llap/union2.q.out    |     4 +
 .../results/clientpositive/llap/union3.q.out    |     4 +
 .../results/clientpositive/llap/union4.q.out    |     4 +
 .../results/clientpositive/llap/union5.q.out    |     4 +
 .../results/clientpositive/llap/union6.q.out    |     6 +
 .../results/clientpositive/llap/union7.q.out    |     6 +
 .../results/clientpositive/llap/union8.q.out    |     4 +
 .../results/clientpositive/llap/union9.q.out    |     4 +
 .../clientpositive/llap/unionDistinct_1.q.out   |   296 +-
 .../clientpositive/llap/unionDistinct_3.q.out   |   784 +-
 .../llap/union_assertion_type.q.out             |    20 +
 .../clientpositive/llap/union_remove_26.q.out   |    40 +
 .../clientpositive/llap/union_top_level.q.out   |    28 +
 .../clientpositive/llap/vector_acid4.q.out      |     4 +
 .../llap/vector_adaptor_usage_mode.q.out        |    48 +
 .../llap/vector_aggregate_9.q.out               |    54 +-
 .../llap/vector_aggregate_without_gby.q.out     |     4 +
 .../llap/vector_annotate_stats_select.q.out     |   136 +
 .../llap/vector_auto_smb_mapjoin_14.q.out       |    80 +
 .../llap/vector_between_columns.q.out           |    12 +
 .../clientpositive/llap/vector_between_in.q.out |    48 +
 .../llap/vector_binary_join_groupby.q.out       |    12 +
 .../clientpositive/llap/vector_bround.q.out     |     4 +
 .../clientpositive/llap/vector_bucket.q.out     |     4 +
 .../llap/vector_case_when_1.q.out               |    48 +-
 .../llap/vector_case_when_2.q.out               |    87 +-
 .../llap/vector_case_when_conversion.q.out      |   616 +
 .../llap/vector_cast_constant.q.out             |     4 +
 .../clientpositive/llap/vector_char_2.q.out     |     8 +
 .../clientpositive/llap/vector_char_4.q.out     |     4 +
 .../llap/vector_char_mapjoin1.q.out             |    16 +
 .../llap/vector_char_simple.q.out               |    12 +
 .../llap/vector_char_varchar_1.q.out            |    12 +
 .../clientpositive/llap/vector_coalesce.q.out   |    40 +-
 .../clientpositive/llap/vector_coalesce_2.q.out |    44 +-
 .../clientpositive/llap/vector_coalesce_3.q.out |    16 +-
 .../clientpositive/llap/vector_coalesce_4.q.out |    14 +-
 .../llap/vector_complex_all.q.out               |    58 +-
 .../llap/vector_complex_join.q.out              |    18 +
 .../clientpositive/llap/vector_count.q.out      |    16 +
 .../llap/vector_count_distinct.q.out            |    82 +-
 .../llap/vector_create_struct_table.q.out       |    12 +
 .../clientpositive/llap/vector_data_types.q.out |    12 +
 .../clientpositive/llap/vector_date_1.q.out     |    96 +-
 .../clientpositive/llap/vector_decimal_1.q.out  |    36 +
 .../llap/vector_decimal_10_0.q.out              |     8 +
 .../clientpositive/llap/vector_decimal_2.q.out  |   108 +
 .../clientpositive/llap/vector_decimal_5.q.out  |     4 +
 .../clientpositive/llap/vector_decimal_6.q.out  |    20 +
 .../llap/vector_decimal_aggregate.q.out         |    16 +
 .../llap/vector_decimal_cast.q.out              |     8 +
 .../llap/vector_decimal_expressions.q.out       |    10 +-
 .../llap/vector_decimal_mapjoin.q.out           |    36 +
 .../llap/vector_decimal_math_funcs.q.out        |     8 +
 .../llap/vector_decimal_precision.q.out         |     8 +
 .../llap/vector_decimal_round.q.out             |    24 +
 .../llap/vector_decimal_round_2.q.out           |    16 +
 .../llap/vector_decimal_trailing.q.out          |     4 +
 .../llap/vector_decimal_udf.q.out               |   264 +
 .../llap/vector_decimal_udf2.q.out              |    16 +
 .../clientpositive/llap/vector_distinct_2.q.out |    18 +-
 .../clientpositive/llap/vector_elt.q.out        |     8 +
 .../llap/vector_full_outer_join.q.out           |    48 +
 .../llap/vector_fullouter_mapjoin_1_fast.q.out  |    48 +
 .../vector_fullouter_mapjoin_1_optimized.q.out  |    48 +
 ...fullouter_mapjoin_1_optimized_passthru.q.out |    48 +
 .../clientpositive/llap/vector_groupby4.q.out   |     4 +
 .../clientpositive/llap/vector_groupby6.q.out   |     4 +
 .../clientpositive/llap/vector_groupby_3.q.out  |    18 +-
 .../llap/vector_groupby_cube1.q.out             |    30 +
 .../llap/vector_groupby_grouping_id1.q.out      |    24 +
 .../llap/vector_groupby_grouping_id2.q.out      |    36 +
 .../llap/vector_groupby_grouping_id3.q.out      |     8 +
 .../llap/vector_groupby_grouping_sets1.q.out    |    28 +
 .../llap/vector_groupby_grouping_sets2.q.out    |    16 +
 .../llap/vector_groupby_grouping_sets3.q.out    |    12 +
 .../vector_groupby_grouping_sets3_dec.q.out     |    12 +
 .../llap/vector_groupby_grouping_sets4.q.out    |    12 +
 .../llap/vector_groupby_grouping_sets5.q.out    |    12 +
 .../llap/vector_groupby_grouping_sets6.q.out    |     8 +
 .../vector_groupby_grouping_sets_grouping.q.out |    60 +
 .../vector_groupby_grouping_sets_limit.q.out    |    24 +
 .../llap/vector_groupby_grouping_window.q.out   |     4 +
 .../llap/vector_groupby_mapjoin.q.out           |    16 +-
 .../llap/vector_groupby_reduce.q.out            |    16 +
 .../llap/vector_groupby_rollup1.q.out           |    22 +
 .../llap/vector_groupby_sort_11.q.out           |    42 +
 .../llap/vector_groupby_sort_8.q.out            |     6 +
 .../llap/vector_grouping_sets.q.out             |    16 +-
 .../clientpositive/llap/vector_if_expr.q.out    |     4 +
 .../clientpositive/llap/vector_if_expr_2.q.out  |     4 +
 .../llap/vector_include_no_sel.q.out            |     6 +
 .../clientpositive/llap/vector_inner_join.q.out |    54 +
 .../clientpositive/llap/vector_interval_1.q.out |   112 +-
 .../clientpositive/llap/vector_interval_2.q.out |   152 +-
 .../llap/vector_interval_arithmetic.q.out       |    92 +-
 .../llap/vector_interval_mapjoin.q.out          |     6 +
 .../clientpositive/llap/vector_join30.q.out     |    60 +
 .../llap/vector_join_filters.q.out              |    20 +
 .../clientpositive/llap/vector_join_nulls.q.out |    20 +
 .../llap/vector_left_outer_join.q.out           |     4 +
 .../llap/vector_left_outer_join2.q.out          |    36 +
 .../llap/vector_leftsemi_mapjoin.q.out          |   872 +
 .../clientpositive/llap/vector_like_2.q.out     |     4 +
 .../llap/vector_llap_io_data_conversion.q.out   |     4 +
 .../llap/vector_llap_text_1.q.out               |    10 +
 .../clientpositive/llap/vector_map_order.q.out  |     4 +
 .../llap/vector_mapjoin_complex_values.q.out    |   355 +
 .../llap/vector_mapjoin_reduce.q.out            |     8 +
 .../llap/vector_mr_diff_schema_alias.q.out      |     8 +
 .../llap/vector_multi_insert.q.out              |     8 +
 .../clientpositive/llap/vector_null_map.q.out   |     8 +
 .../llap/vector_null_projection.q.out           |    10 +
 .../llap/vector_nullsafe_join.q.out             |    48 +
 .../llap/vector_number_compare_projection.q.out |     8 +
 .../clientpositive/llap/vector_nvl.q.out        |    16 +
 .../llap/vector_orc_merge_incompat_schema.q.out |     8 +
 .../llap/vector_orc_nested_column_pruning.q.out |   102 +
 .../llap/vector_orc_null_check.q.out            |     4 +
 .../clientpositive/llap/vector_order_null.q.out |    44 +
 .../clientpositive/llap/vector_orderby_5.q.out  |    20 +-
 .../llap/vector_outer_join0.q.out               |    20 +-
 .../llap/vector_outer_join1.q.out               |    12 +
 .../llap/vector_outer_join2.q.out               |     4 +
 .../llap/vector_outer_join3.q.out               |     9 +
 .../llap/vector_outer_join4.q.out               |     9 +
 .../llap/vector_outer_join5.q.out               |    50 +
 .../llap/vector_outer_join6.q.out               |    14 +
 .../llap/vector_outer_reference_windowed.q.out  |    52 +
 ...ector_parquet_nested_two_level_complex.q.out |    36 +
 .../llap/vector_partition_diff_num_cols.q.out   |    40 +
 .../llap/vector_partitioned_date_time.q.out     |  3130 ++-
 .../clientpositive/llap/vector_ptf_1.q.out      |     4 +
 .../llap/vector_ptf_part_simple.q.out           |   570 +-
 .../clientpositive/llap/vector_reduce1.q.out    |    14 +-
 .../clientpositive/llap/vector_reduce2.q.out    |    14 +-
 .../clientpositive/llap/vector_reduce3.q.out    |    14 +-
 .../llap/vector_reduce_groupby_decimal.q.out    |     4 +
 .../vector_reduce_groupby_duplicate_cols.q.out  |     6 +
 .../llap/vector_retry_failure.q.out             |     4 +
 .../llap/vector_reuse_scratchcols.q.out         |     8 +
 .../llap/vector_string_concat.q.out             |    28 +-
 .../llap/vector_string_decimal.q.out            |     4 +
 .../clientpositive/llap/vector_struct_in.q.out  |    32 +
 .../clientpositive/llap/vector_topnkey.q.out    |    12 +
 .../clientpositive/llap/vector_udf1.q.out       |   116 +
 .../clientpositive/llap/vector_udf2.q.out       |    12 +
 .../llap/vector_udf_adaptor_1.q.out             |    76 +-
 .../llap/vector_udf_character_length.q.out      |    12 +
 .../clientpositive/llap/vector_udf_inline.q.out |     4 +
 .../llap/vector_udf_octet_length.q.out          |     8 +
 .../llap/vector_udf_string_to_boolean.q.out     |     4 +
 .../clientpositive/llap/vector_varchar_4.q.out  |     4 +
 .../llap/vector_varchar_mapjoin1.q.out          |    16 +
 .../llap/vector_varchar_simple.q.out            |    12 +
 .../llap/vector_when_case_null.q.out            |     4 +
 .../clientpositive/llap/vector_windowing.q.out  |   208 +
 .../llap/vector_windowing_expressions.q.out     |    82 +-
 .../llap/vector_windowing_gby.q.out             |     6 +
 .../llap/vector_windowing_gby2.q.out            |    18 +
 .../vector_windowing_multipartitioning.q.out    |    48 +-
 .../llap/vector_windowing_navfn.q.out           |    44 +
 .../llap/vector_windowing_order_null.q.out      |    32 +
 .../vector_windowing_range_multiorder.q.out     | 16386 +++++------
 .../llap/vector_windowing_rank.q.out            |    28 +
 .../llap/vector_windowing_streaming.q.out       |    22 +
 .../llap/vector_windowing_windowspec.q.out      |    44 +
 .../llap/vector_windowing_windowspec4.q.out     |     4 +
 .../clientpositive/llap/vectorization_0.q.out   |    60 +
 .../clientpositive/llap/vectorization_1.q.out   |     4 +
 .../clientpositive/llap/vectorization_10.q.out  |     4 +
 .../clientpositive/llap/vectorization_11.q.out  |     4 +
 .../clientpositive/llap/vectorization_12.q.out  |     4 +
 .../clientpositive/llap/vectorization_13.q.out  |     8 +
 .../clientpositive/llap/vectorization_14.q.out  |     4 +
 .../clientpositive/llap/vectorization_15.q.out  |     4 +
 .../clientpositive/llap/vectorization_16.q.out  |     4 +
 .../clientpositive/llap/vectorization_17.q.out  |     4 +
 .../clientpositive/llap/vectorization_2.q.out   |     4 +
 .../clientpositive/llap/vectorization_3.q.out   |     4 +
 .../clientpositive/llap/vectorization_4.q.out   |     4 +
 .../clientpositive/llap/vectorization_5.q.out   |     4 +
 .../clientpositive/llap/vectorization_6.q.out   |     4 +
 .../clientpositive/llap/vectorization_7.q.out   |     8 +
 .../clientpositive/llap/vectorization_8.q.out   |     8 +
 .../clientpositive/llap/vectorization_9.q.out   |     4 +
 .../llap/vectorization_decimal_date.q.out       |     4 +
 .../llap/vectorization_div0.q.out               |    16 +
 .../vectorization_input_format_excludes.q.out   |    40 +
 .../llap/vectorization_limit.q.out              |    28 +
 .../llap/vectorization_nested_udf.q.out         |     4 +
 .../llap/vectorization_part_project.q.out       |     8 +
 .../llap/vectorization_pushdown.q.out           |     4 +
 .../llap/vectorization_short_regress.q.out      |    80 +
 .../llap/vectorized_bucketmapjoin1.q.out        |    18 +
 .../clientpositive/llap/vectorized_case.q.out   |    52 +-
 .../clientpositive/llap/vectorized_casts.q.out  |     4 +
 .../llap/vectorized_context.q.out               |     8 +
 .../llap/vectorized_date_funcs.q.out            |    62 +-
 .../llap/vectorized_distinct_gby.q.out          |    10 +-
 .../vectorized_dynamic_partition_pruning.q.out  |   516 +
 .../vectorized_dynamic_semijoin_reduction.q.out |    42 +
 ...vectorized_dynamic_semijoin_reduction2.q.out |    48 +
 .../vectorized_insert_into_bucketed_table.q.out |     4 +
 .../clientpositive/llap/vectorized_join46.q.out |   126 +-
 .../llap/vectorized_mapjoin.q.out               |     4 +
 .../llap/vectorized_mapjoin3.q.out              |    18 +
 .../llap/vectorized_math_funcs.q.out            |     4 +
 .../llap/vectorized_multi_output_select.q.out   |     6 +
 .../llap/vectorized_nested_mapjoin.q.out        |     4 +
 .../llap/vectorized_parquet.q.out               |   124 +-
 .../llap/vectorized_parquet_types.q.out         |    24 +
 .../clientpositive/llap/vectorized_ptf.q.out    |    96 +
 .../llap/vectorized_shufflejoin.q.out           |     4 +
 .../llap/vectorized_string_funcs.q.out          |     4 +
 .../llap/vectorized_timestamp.q.out             |    20 +
 .../llap/vectorized_timestamp_funcs.q.out       |    28 +
 .../llap/vectorized_timestamp_ints_casts.q.out  |     8 +
 .../results/clientpositive/llap/windowing.q.out |     4 +
 .../clientpositive/llap/windowing_gby.q.out     |     6 +
 .../results/clientpositive/load_dyn_part1.q.out |    12 +
 .../clientpositive/load_dyn_part10.q.out        |     7 +
 .../clientpositive/load_dyn_part13.q.out        |     3 +
 .../clientpositive/load_dyn_part14.q.out        |     3 +
 .../results/clientpositive/load_dyn_part2.q.out |    11 +
 .../results/clientpositive/load_dyn_part3.q.out |    11 +
 .../results/clientpositive/load_dyn_part4.q.out |    11 +
 .../results/clientpositive/load_dyn_part8.q.out |    12 +
 .../results/clientpositive/load_dyn_part9.q.out |     7 +
 .../clientpositive/louter_join_ppr.q.out        |    40 +
 ql/src/test/results/clientpositive/macro.q.out  |    24 +
 .../results/clientpositive/manyViewJoin.q.out   |   412 +
 .../test/results/clientpositive/mapjoin1.q.out  |    24 +
 .../test/results/clientpositive/mapjoin2.q.out  |    28 +
 .../test/results/clientpositive/mapjoin3.q.out  |     6 +
 .../test/results/clientpositive/mapjoin46.q.out |   138 +
 .../test/results/clientpositive/mapjoin47.q.out |    84 +
 .../clientpositive/mapjoin_distinct.q.out       |    32 +
 .../mapjoin_filter_on_outerjoin.q.out           |    12 +
 .../clientpositive/mapjoin_mapjoin.q.out        |    46 +
 .../clientpositive/mapjoin_memcheck.q.out       |     4 +
 .../clientpositive/mapjoin_subquery.q.out       |    20 +
 .../clientpositive/mapjoin_subquery2.q.out      |     8 +
 .../clientpositive/mapjoin_test_outer.q.out     |    16 +
 .../results/clientpositive/mapreduce1.q.out     |     4 +
 .../results/clientpositive/mapreduce2.q.out     |     4 +
 .../results/clientpositive/mapreduce3.q.out     |     4 +
 .../results/clientpositive/mapreduce4.q.out     |     4 +
 .../results/clientpositive/mapreduce5.q.out     |     4 +
 .../results/clientpositive/mapreduce6.q.out     |     4 +
 .../results/clientpositive/mapreduce7.q.out     |     4 +
 .../results/clientpositive/mapreduce8.q.out     |     4 +
 .../test/results/clientpositive/masking_1.q.out |    42 +
 .../results/clientpositive/masking_10.q.out     |     8 +
 .../results/clientpositive/masking_12.q.out     |    30 +
 .../results/clientpositive/masking_13.q.out     |    10 +
 .../clientpositive/masking_1_newdb.q.out        |     8 +
 .../test/results/clientpositive/masking_2.q.out |    30 +
 .../test/results/clientpositive/masking_3.q.out |    56 +
 .../test/results/clientpositive/masking_4.q.out |    18 +
 .../test/results/clientpositive/masking_5.q.out |    12 +
 .../test/results/clientpositive/masking_6.q.out |    24 +
 .../test/results/clientpositive/masking_7.q.out |    24 +
 .../test/results/clientpositive/masking_8.q.out |    16 +
 .../test/results/clientpositive/masking_9.q.out |     4 +
 .../clientpositive/masking_disablecbo_1.q.out   |    42 +
 .../clientpositive/masking_disablecbo_2.q.out   |    30 +
 .../clientpositive/masking_disablecbo_3.q.out   |    56 +
 .../clientpositive/masking_disablecbo_4.q.out   |    18 +
 .../results/clientpositive/masking_mv.q.out     |    56 +
 ql/src/test/results/clientpositive/merge1.q.out |    20 +
 ql/src/test/results/clientpositive/merge2.q.out |    20 +
 ql/src/test/results/clientpositive/merge3.q.out |    20 +
 ql/src/test/results/clientpositive/merge4.q.out |    24 +
 .../merge_dynamic_partition.q.out               |    16 +
 .../merge_dynamic_partition2.q.out              |     7 +
 .../merge_dynamic_partition3.q.out              |    11 +
 .../merge_dynamic_partition4.q.out              |     7 +
 .../merge_dynamic_partition5.q.out              |     7 +
 .../results/clientpositive/merge_join_1.q.out   |     6 +
 .../test/results/clientpositive/mergejoin.q.out |   120 +
 .../results/clientpositive/mergejoins.q.out     |    16 +
 .../clientpositive/mergejoins_mixed.q.out       |    48 +
 .../clientpositive/metadata_only_queries.q.out  |    70 +
 .../metadata_only_queries_with_filters.q.out    |     8 +
 ql/src/test/results/clientpositive/mm_all.q.out |    10 +
 .../results/clientpositive/msck_repair_0.q.out  |     9 +
 .../results/clientpositive/msck_repair_2.q.out  |     5 +
 .../results/clientpositive/msck_repair_3.q.out  |     5 +
 .../clientpositive/msck_repair_batchsize.q.out  |     9 +
 .../clientpositive/msck_repair_drop.q.out       |   126 +
 .../clientpositive/multi_insert_distinct.q.out  |    18 +
 .../clientpositive/multi_insert_gby.q.out       |    12 +
 .../clientpositive/multi_insert_gby2.q.out      |     6 +
 .../clientpositive/multi_insert_gby3.q.out      |    26 +
 .../clientpositive/multi_insert_gby4.q.out      |     8 +
 .../clientpositive/multi_insert_mixed.q.out     |     8 +
 ...i_insert_move_tasks_share_dependencies.q.out |   136 +
 .../clientpositive/multi_insert_union_src.q.out |     8 +
 .../multi_insert_with_join2.q.out               |    60 +
 .../clientpositive/multi_join_union.q.out       |    10 +
 .../clientpositive/multigroupby_singlemr.q.out  |    32 +
 .../clientpositive/named_column_join.q.out      |     4 +
 .../clientpositive/nested_column_pruning.q.out  |   102 +
 .../test/results/clientpositive/no_hooks.q.out  |     2 +
 .../results/clientpositive/noalias_subq1.q.out  |     4 +
 .../clientpositive/nonReservedKeyWords.q.out    |    12 +
 .../nonblock_op_deduplicate.q.out               |    12 +
 .../results/clientpositive/nonmr_fetch.q.out    |   150 +
 .../clientpositive/nonmr_fetch_threshold.q.out  |    58 +
 .../nonreserved_keywords_insert_into1.q.out     |    12 +
 .../results/clientpositive/notable_alias1.q.out |     4 +
 .../results/clientpositive/notable_alias2.q.out |     4 +
 .../test/results/clientpositive/null_cast.q.out |     4 +
 .../nullability_transitive_inference.q.out      |     6 +
 .../results/clientpositive/nullformat.q.out     |     4 +
 .../results/clientpositive/nullformatCTAS.q.out |     6 +
 .../test/results/clientpositive/nullgroup.q.out |    16 +
 .../results/clientpositive/nullgroup2.q.out     |    16 +
 .../results/clientpositive/nullgroup3.q.out     |    32 +
 .../results/clientpositive/nullgroup4.q.out     |    16 +
 .../nullgroup4_multi_distinct.q.out             |     8 +
 .../results/clientpositive/nullgroup5.q.out     |     8 +
 .../results/clientpositive/nullscript.q.out     |     4 +
 .../clientpositive/num_op_type_conv.q.out       |     4 +
 .../offset_limit_global_optimizer.q.out         |    96 +
 .../results/clientpositive/optional_outer.q.out |    24 +
 .../results/clientpositive/orc_createas1.q.out  |    20 +
 .../clientpositive/orc_int_type_promotion.q.out |     4 +
 .../results/clientpositive/orc_merge1.q.out     |     9 +
 .../results/clientpositive/orc_merge10.q.out    |    13 +
 .../results/clientpositive/orc_merge2.q.out     |     3 +
 .../results/clientpositive/orc_merge3.q.out     |     8 +
 .../results/clientpositive/orc_merge4.q.out     |     8 +
 .../results/clientpositive/orc_merge5.q.out     |    12 +
 .../results/clientpositive/orc_merge6.q.out     |    12 +
 .../clientpositive/orc_merge_diff_fs.q.out      |     9 +
 .../clientpositive/orc_merge_incompat1.q.out    |     4 +
 .../clientpositive/orc_merge_incompat2.q.out    |     7 +
 .../orc_nested_column_pruning.q.out             |   102 +
 .../clientpositive/orc_ppd_str_conversion.q.out |     4 +
 .../orc_struct_type_vectorization.q.out         |     8 +
 ql/src/test/results/clientpositive/order.q.out  |     8 +
 ql/src/test/results/clientpositive/order3.q.out |    24 +
 .../clientpositive/order_by_expr_1.q.out        |    12 +
 .../results/clientpositive/outer_join_ppr.q.out |    20 +
 .../outer_reference_windowed.q.out              |    26 +
 .../test/results/clientpositive/parallel.q.out  |     6 +
 .../clientpositive/parallel_colstats.q.out      |     6 +
 .../results/clientpositive/parallel_join0.q.out |     8 +
 .../results/clientpositive/parallel_join1.q.out |     4 +
 .../clientpositive/parallel_orderby.q.out       |     6 +
 .../parquet_complex_types_vectorization.q.out   |    24 +
 .../results/clientpositive/parquet_join.q.out   |    18 +
 .../parquet_map_type_vectorization.q.out        |     8 +
 .../clientpositive/parquet_no_row_serde.q.out   |     8 +
 .../parquet_struct_type_vectorization.q.out     |     8 +
 ..._non_dictionary_encoding_vectorization.q.out |    24 +
 .../parquet_types_vectorization.q.out           |    28 +
 .../parquet_vectorization_0.q.out               |    60 +
 .../parquet_vectorization_1.q.out               |     4 +
 .../parquet_vectorization_10.q.out              |     4 +
 .../parquet_vectorization_11.q.out              |     4 +
 .../parquet_vectorization_12.q.out              |     4 +
 .../parquet_vectorization_13.q.out              |     8 +
 .../parquet_vectorization_14.q.out              |     4 +
 .../parquet_vectorization_15.q.out              |     4 +
 .../parquet_vectorization_16.q.out              |     4 +
 .../parquet_vectorization_17.q.out              |     4 +
 .../parquet_vectorization_2.q.out               |     4 +
 .../parquet_vectorization_3.q.out               |     4 +
 .../parquet_vectorization_4.q.out               |     4 +
 .../parquet_vectorization_5.q.out               |     4 +
 .../parquet_vectorization_6.q.out               |     4 +
 .../parquet_vectorization_7.q.out               |     8 +
 .../parquet_vectorization_8.q.out               |     8 +
 .../parquet_vectorization_9.q.out               |     4 +
 .../parquet_vectorization_decimal_date.q.out    |     4 +
 .../parquet_vectorization_div0.q.out            |    12 +
 .../parquet_vectorization_limit.q.out           |    28 +
 .../parquet_vectorization_offset_limit.q.out    |     8 +
 .../parquet_vectorization_part_project.q.out    |     8 +
 .../parquet_vectorization_pushdown.q.out        |     4 +
 .../clientpositive/partial_column_stats.q.out   |     6 +
 .../clientpositive/partition_boolexpr.q.out     |    52 +
 .../partition_condition_remover.q.out           |     6 +
 .../partition_wise_fileformat2.q.out            |    20 +
 ql/src/test/results/clientpositive/pcr.q.out    |   186 +
 ql/src/test/results/clientpositive/pcs.q.out    |    86 +
 .../clientpositive/perf/spark/query1.q.out      |    10 +
 .../clientpositive/perf/spark/query10.q.out     |    16 +
 .../clientpositive/perf/spark/query11.q.out     |    10 +
 .../clientpositive/perf/spark/query12.q.out     |     8 +
 .../clientpositive/perf/spark/query13.q.out     |   234 +-
 .../clientpositive/perf/spark/query15.q.out     |    10 +
 .../clientpositive/perf/spark/query16.q.out     |    12 +
 .../clientpositive/perf/spark/query17.q.out     |    14 +
 .../clientpositive/perf/spark/query18.q.out     |    14 +
 .../clientpositive/perf/spark/query19.q.out     |    14 +
 .../clientpositive/perf/spark/query2.q.out      |     8 +
 .../clientpositive/perf/spark/query20.q.out     |     8 +
 .../clientpositive/perf/spark/query21.q.out     |    10 +
 .../clientpositive/perf/spark/query22.q.out     |    10 +
 .../clientpositive/perf/spark/query23.q.out     |    14 +
 .../clientpositive/perf/spark/query24.q.out     |   414 +-
 .../clientpositive/perf/spark/query25.q.out     |    14 +
 .../clientpositive/perf/spark/query26.q.out     |    12 +
 .../clientpositive/perf/spark/query27.q.out     |    12 +
 .../clientpositive/perf/spark/query28.q.out     |     4 +
 .../clientpositive/perf/spark/query29.q.out     |    14 +
 .../clientpositive/perf/spark/query3.q.out      |     8 +
 .../clientpositive/perf/spark/query30.q.out     |    10 +
 .../clientpositive/perf/spark/query31.q.out     |    10 +
 .../clientpositive/perf/spark/query32.q.out     |     8 +
 .../clientpositive/perf/spark/query33.q.out     |    14 +
 .../clientpositive/perf/spark/query34.q.out     |    12 +
 .../clientpositive/perf/spark/query35.q.out     |    16 +
 .../clientpositive/perf/spark/query36.q.out     |    10 +
 .../clientpositive/perf/spark/query37.q.out     |    10 +
 .../clientpositive/perf/spark/query38.q.out     |    12 +
 .../clientpositive/perf/spark/query39.q.out     |    10 +
 .../clientpositive/perf/spark/query4.q.out      |    12 +
 .../clientpositive/perf/spark/query40.q.out     |    14 +-
 .../clientpositive/perf/spark/query42.q.out     |     8 +
 .../clientpositive/perf/spark/query43.q.out     |     8 +
 .../clientpositive/perf/spark/query44.q.out     |     6 +
 .../clientpositive/perf/spark/query45.q.out     |    12 +
 .../clientpositive/perf/spark/query46.q.out     |    14 +
 .../clientpositive/perf/spark/query47.q.out     |   114 +-
 .../clientpositive/perf/spark/query48.q.out     |   134 +-
 .../clientpositive/perf/spark/query49.q.out     |    22 +-
 .../clientpositive/perf/spark/query5.q.out      |    22 +
 .../clientpositive/perf/spark/query50.q.out     |    10 +
 .../clientpositive/perf/spark/query51.q.out     |     8 +
 .../clientpositive/perf/spark/query52.q.out     |     8 +
 .../clientpositive/perf/spark/query53.q.out     |    14 +-
 .../clientpositive/perf/spark/query54.q.out     |   494 +-
 .../clientpositive/perf/spark/query55.q.out     |     8 +
 .../clientpositive/perf/spark/query56.q.out     |    14 +
 .../clientpositive/perf/spark/query57.q.out     |   114 +-
 .../clientpositive/perf/spark/query58.q.out     |    12 +
 .../clientpositive/perf/spark/query59.q.out     |     8 +
 .../clientpositive/perf/spark/query6.q.out      |    12 +
 .../clientpositive/perf/spark/query60.q.out     |    14 +
 .../clientpositive/perf/spark/query61.q.out     |    16 +
 .../clientpositive/perf/spark/query63.q.out     |    14 +-
 .../clientpositive/perf/spark/query65.q.out     |    10 +
 .../clientpositive/perf/spark/query66.q.out     |    14 +
 .../clientpositive/perf/spark/query67.q.out     |    12 +-
 .../clientpositive/perf/spark/query68.q.out     |    14 +
 .../clientpositive/perf/spark/query69.q.out     |    16 +
 .../clientpositive/perf/spark/query7.q.out      |    12 +
 .../clientpositive/perf/spark/query70.q.out     |     8 +
 .../clientpositive/perf/spark/query71.q.out     |    14 +
 .../clientpositive/perf/spark/query72.q.out     |    20 +
 .../clientpositive/perf/spark/query73.q.out     |    12 +
 .../clientpositive/perf/spark/query74.q.out     |    10 +
 .../clientpositive/perf/spark/query75.q.out     |    30 +-
 .../clientpositive/perf/spark/query76.q.out     |    12 +
 .../clientpositive/perf/spark/query77.q.out     |    24 +-
 .../clientpositive/perf/spark/query78.q.out     |    38 +-
 .../clientpositive/perf/spark/query79.q.out     |    12 +
 .../clientpositive/perf/spark/query8.q.out      |    12 +
 .../clientpositive/perf/spark/query80.q.out     |    32 +-
 .../clientpositive/perf/spark/query81.q.out     |    10 +
 .../clientpositive/perf/spark/query82.q.out     |    10 +
 .../clientpositive/perf/spark/query83.q.out     |    12 +
 .../clientpositive/perf/spark/query84.q.out     |    14 +
 .../clientpositive/perf/spark/query85.q.out     |   360 +-
 .../clientpositive/perf/spark/query86.q.out     |     8 +
 .../clientpositive/perf/spark/query87.q.out     |    12 +
 .../clientpositive/perf/spark/query88.q.out     |   314 +-
 .../clientpositive/perf/spark/query89.q.out     |   102 +-
 .../clientpositive/perf/spark/query9.q.out      |     6 +
 .../clientpositive/perf/spark/query90.q.out     |    10 +
 .../clientpositive/perf/spark/query91.q.out     |    16 +
 .../clientpositive/perf/spark/query92.q.out     |     8 +
 .../clientpositive/perf/spark/query93.q.out     |     8 +
 .../clientpositive/perf/spark/query94.q.out     |    12 +
 .../clientpositive/perf/spark/query95.q.out     |    12 +
 .../clientpositive/perf/spark/query96.q.out     |    10 +
 .../clientpositive/perf/spark/query97.q.out     |     8 +
 .../clientpositive/perf/spark/query98.q.out     |     8 +
 .../clientpositive/perf/spark/query99.q.out     |    12 +
 .../clientpositive/perf/tez/cbo_query1.q.out    |    91 +
 .../clientpositive/perf/tez/cbo_query10.q.out   |   178 +
 .../clientpositive/perf/tez/cbo_query11.q.out   |   223 +
 .../clientpositive/perf/tez/cbo_query12.q.out   |    89 +
 .../clientpositive/perf/tez/cbo_query13.q.out   |   141 +
 .../clientpositive/perf/tez/cbo_query14.q.out   |   618 +
 .../clientpositive/perf/tez/cbo_query15.q.out   |    69 +
 .../clientpositive/perf/tez/cbo_query16.q.out   |   104 +
 .../clientpositive/perf/tez/cbo_query17.q.out   |   141 +
 .../clientpositive/perf/tez/cbo_query18.q.out   |   114 +
 .../clientpositive/perf/tez/cbo_query19.q.out   |    92 +
 .../clientpositive/perf/tez/cbo_query2.q.out    |   170 +
 .../clientpositive/perf/tez/cbo_query20.q.out   |    81 +
 .../clientpositive/perf/tez/cbo_query21.q.out   |    90 +
 .../clientpositive/perf/tez/cbo_query22.q.out   |    72 +
 .../clientpositive/perf/tez/cbo_query23.q.out   |   281 +
 .../clientpositive/perf/tez/cbo_query24.q.out   |   174 +
 .../clientpositive/perf/tez/cbo_query25.q.out   |   146 +
 .../clientpositive/perf/tez/cbo_query26.q.out   |    76 +
 .../clientpositive/perf/tez/cbo_query27.q.out   |    81 +
 .../clientpositive/perf/tez/cbo_query28.q.out   |   146 +
 .../clientpositive/perf/tez/cbo_query29.q.out   |   144 +
 .../clientpositive/perf/tez/cbo_query3.q.out    |    64 +
 .../clientpositive/perf/tez/cbo_query30.q.out   |   112 +
 .../clientpositive/perf/tez/cbo_query31.q.out   |   199 +
 .../clientpositive/perf/tez/cbo_query32.q.out   |    89 +
 .../clientpositive/perf/tez/cbo_query33.q.out   |   238 +
 .../clientpositive/perf/tez/cbo_query34.q.out   |    99 +
 .../clientpositive/perf/tez/cbo_query35.q.out   |   175 +
 .../clientpositive/perf/tez/cbo_query36.q.out   |    91 +
 .../clientpositive/perf/tez/cbo_query37.q.out   |    63 +
 .../clientpositive/perf/tez/cbo_query38.q.out   |   111 +
 .../clientpositive/perf/tez/cbo_query39.q.out   |   168 +
 .../clientpositive/perf/tez/cbo_query4.q.out    |   324 +
 .../clientpositive/perf/tez/cbo_query40.q.out   |    91 +
 .../clientpositive/perf/tez/cbo_query42.q.out   |    68 +
 .../clientpositive/perf/tez/cbo_query43.q.out   |    61 +
 .../clientpositive/perf/tez/cbo_query44.q.out   |   115 +
 .../clientpositive/perf/tez/cbo_query45.q.out   |    89 +
 .../clientpositive/perf/tez/cbo_query46.q.out   |   115 +
 .../clientpositive/perf/tez/cbo_query47.q.out   |   177 +
 .../clientpositive/perf/tez/cbo_query48.q.out   |   164 +
 .../clientpositive/perf/tez/cbo_query49.q.out   |   330 +
 .../clientpositive/perf/tez/cbo_query5.q.out    |   342 +
 .../clientpositive/perf/tez/cbo_query50.q.out   |   151 +
 .../clientpositive/perf/tez/cbo_query51.q.out   |   125 +
 .../clientpositive/perf/tez/cbo_query52.q.out   |    67 +
 .../clientpositive/perf/tez/cbo_query53.q.out   |    87 +
 .../clientpositive/perf/tez/cbo_query54.q.out   |   213 +
 .../clientpositive/perf/tez/cbo_query55.q.out   |    51 +
 .../clientpositive/perf/tez/cbo_query56.q.out   |   224 +
 .../clientpositive/perf/tez/cbo_query57.q.out   |   171 +
 .../clientpositive/perf/tez/cbo_query58.q.out   |   240 +
 .../clientpositive/perf/tez/cbo_query59.q.out   |   136 +
 .../clientpositive/perf/tez/cbo_query6.q.out    |   109 +
 .../clientpositive/perf/tez/cbo_query60.q.out   |   244 +
 .../clientpositive/perf/tez/cbo_query61.q.out   |   164 +
 .../clientpositive/perf/tez/cbo_query63.q.out   |    89 +
 .../clientpositive/perf/tez/cbo_query64.q.out   |   438 +
 .../clientpositive/perf/tez/cbo_query65.q.out   |    99 +
 .../clientpositive/perf/tez/cbo_query66.q.out   |   508 +
 .../clientpositive/perf/tez/cbo_query67.q.out   |   120 +
 .../clientpositive/perf/tez/cbo_query68.q.out   |   129 +
 .../clientpositive/perf/tez/cbo_query69.q.out   |   156 +
 .../clientpositive/perf/tez/cbo_query7.q.out    |    76 +
 .../clientpositive/perf/tez/cbo_query70.q.out   |   119 +
 .../clientpositive/perf/tez/cbo_query71.q.out   |   130 +
 .../clientpositive/perf/tez/cbo_query72.q.out   |   130 +
 .../clientpositive/perf/tez/cbo_query73.q.out   |    93 +
 .../clientpositive/perf/tez/cbo_query74.q.out   |   191 +
 .../clientpositive/perf/tez/cbo_query75.q.out   |   278 +
 .../clientpositive/perf/tez/cbo_query76.q.out   |   101 +
 .../clientpositive/perf/tez/cbo_query77.q.out   |   316 +
 .../clientpositive/perf/tez/cbo_query78.q.out   |   183 +
 .../clientpositive/perf/tez/cbo_query79.q.out   |    82 +
 .../clientpositive/perf/tez/cbo_query8.q.out    |   266 +
 .../clientpositive/perf/tez/cbo_query80.q.out   |   301 +
 .../clientpositive/perf/tez/cbo_query81.q.out   |   113 +
 .../clientpositive/perf/tez/cbo_query82.q.out   |    63 +
 .../clientpositive/perf/tez/cbo_query83.q.out   |   222 +
 .../clientpositive/perf/tez/cbo_query84.q.out   |    84 +
 .../clientpositive/perf/tez/cbo_query85.q.out   |   219 +
 .../clientpositive/perf/tez/cbo_query86.q.out   |    77 +
 .../clientpositive/perf/tez/cbo_query87.q.out   |   114 +
 .../clientpositive/perf/tez/cbo_query88.q.out   |   347 +
 .../clientpositive/perf/tez/cbo_query89.q.out   |    88 +
 .../clientpositive/perf/tez/cbo_query9.q.out    |   200 +
 .../clientpositive/perf/tez/cbo_query90.q.out   |    92 +
 .../clientpositive/perf/tez/cbo_query91.q.out   |   110 +
 .../clientpositive/perf/tez/cbo_query92.q.out   |    94 +
 .../clientpositive/perf/tez/cbo_query93.q.out   |    59 +
 .../clientpositive/perf/tez/cbo_query94.q.out   |   100 +
 .../clientpositive/perf/tez/cbo_query95.q.out   |   120 +
 .../clientpositive/perf/tez/cbo_query96.q.out   |    61 +
 .../clientpositive/perf/tez/cbo_query97.q.out   |    81 +
 .../clientpositive/perf/tez/cbo_query98.q.out   |    87 +
 .../clientpositive/perf/tez/cbo_query99.q.out   |   106 +
 .../perf/tez/constraints/cbo_query1.q.out       |    90 +
 .../perf/tez/constraints/cbo_query10.q.out      |   177 +
 .../perf/tez/constraints/cbo_query11.q.out      |   215 +
 .../perf/tez/constraints/cbo_query12.q.out      |    89 +
 .../perf/tez/constraints/cbo_query13.q.out      |   137 +
 .../perf/tez/constraints/cbo_query14.q.out      |   612 +
 .../perf/tez/constraints/cbo_query15.q.out      |    68 +
 .../perf/tez/constraints/cbo_query16.q.out      |   102 +
 .../perf/tez/constraints/cbo_query17.q.out      |   139 +
 .../perf/tez/constraints/cbo_query18.q.out      |   111 +
 .../perf/tez/constraints/cbo_query19.q.out      |    90 +
 .../perf/tez/constraints/cbo_query2.q.out       |   170 +
 .../perf/tez/constraints/cbo_query20.q.out      |    81 +
 .../perf/tez/constraints/cbo_query21.q.out      |    88 +
 .../perf/tez/constraints/cbo_query22.q.out      |    66 +
 .../perf/tez/constraints/cbo_query23.q.out      |   245 +
 .../perf/tez/constraints/cbo_query24.q.out      |   171 +
 .../perf/tez/constraints/cbo_query25.q.out      |   144 +
 .../perf/tez/constraints/cbo_query26.q.out      |    75 +
 .../perf/tez/constraints/cbo_query27.q.out      |    80 +
 .../perf/tez/constraints/cbo_query28.q.out      |   146 +
 .../perf/tez/constraints/cbo_query29.q.out      |   142 +
 .../perf/tez/constraints/cbo_query3.q.out       |    64 +
 .../perf/tez/constraints/cbo_query30.q.out      |   112 +
 .../perf/tez/constraints/cbo_query31.q.out      |   199 +
 .../perf/tez/constraints/cbo_query32.q.out      |    89 +
 .../perf/tez/constraints/cbo_query33.q.out      |   238 +
 .../perf/tez/constraints/cbo_query34.q.out      |    98 +
 .../perf/tez/constraints/cbo_query35.q.out      |   173 +
 .../perf/tez/constraints/cbo_query36.q.out      |    90 +
 .../perf/tez/constraints/cbo_query37.q.out      |    62 +
 .../perf/tez/constraints/cbo_query38.q.out      |   108 +
 .../perf/tez/constraints/cbo_query39.q.out      |   156 +
 .../perf/tez/constraints/cbo_query4.q.out       |   312 +
 .../perf/tez/constraints/cbo_query40.q.out      |    89 +
 .../perf/tez/constraints/cbo_query42.q.out      |    68 +
 .../perf/tez/constraints/cbo_query43.q.out      |    61 +
 .../perf/tez/constraints/cbo_query44.q.out      |   113 +
 .../perf/tez/constraints/cbo_query45.q.out      |    81 +
 .../perf/tez/constraints/cbo_query46.q.out      |   113 +
 .../perf/tez/constraints/cbo_query47.q.out      |   177 +
 .../perf/tez/constraints/cbo_query48.q.out      |   160 +
 .../perf/tez/constraints/cbo_query49.q.out      |   330 +
 .../perf/tez/constraints/cbo_query5.q.out       |   339 +
 .../perf/tez/constraints/cbo_query50.q.out      |   146 +
 .../perf/tez/constraints/cbo_query51.q.out      |   125 +
 .../perf/tez/constraints/cbo_query52.q.out      |    67 +
 .../perf/tez/constraints/cbo_query53.q.out      |    83 +
 .../perf/tez/constraints/cbo_query54.q.out      |   212 +
 .../perf/tez/constraints/cbo_query55.q.out      |    51 +
 .../perf/tez/constraints/cbo_query56.q.out      |   221 +
 .../perf/tez/constraints/cbo_query57.q.out      |   171 +
 .../perf/tez/constraints/cbo_query58.q.out      |   237 +
 .../perf/tez/constraints/cbo_query59.q.out      |   134 +
 .../perf/tez/constraints/cbo_query6.q.out       |   108 +
 .../perf/tez/constraints/cbo_query60.q.out      |   241 +
 .../perf/tez/constraints/cbo_query61.q.out      |   164 +
 .../perf/tez/constraints/cbo_query63.q.out      |    85 +
 .../perf/tez/constraints/cbo_query64.q.out      |   390 +
 .../perf/tez/constraints/cbo_query65.q.out      |    97 +
 .../perf/tez/constraints/cbo_query66.q.out      |   506 +
 .../perf/tez/constraints/cbo_query67.q.out      |   118 +
 .../perf/tez/constraints/cbo_query68.q.out      |   127 +
 .../perf/tez/constraints/cbo_query69.q.out      |   155 +
 .../perf/tez/constraints/cbo_query7.q.out       |    75 +
 .../perf/tez/constraints/cbo_query70.q.out      |   119 +
 .../perf/tez/constraints/cbo_query71.q.out      |   130 +
 .../perf/tez/constraints/cbo_query72.q.out      |   125 +
 .../perf/tez/constraints/cbo_query73.q.out      |    92 +
 .../perf/tez/constraints/cbo_query74.q.out      |   187 +
 .../perf/tez/constraints/cbo_query75.q.out      |   272 +
 .../perf/tez/constraints/cbo_query76.q.out      |    95 +
 .../perf/tez/constraints/cbo_query77.q.out      |   304 +
 .../perf/tez/constraints/cbo_query78.q.out      |   183 +
 .../perf/tez/constraints/cbo_query79.q.out      |    81 +
 .../perf/tez/constraints/cbo_query8.q.out       |   266 +
 .../perf/tez/constraints/cbo_query80.q.out      |   295 +
 .../perf/tez/constraints/cbo_query81.q.out      |   113 +
 .../perf/tez/constraints/cbo_query82.q.out      |    62 +
 .../perf/tez/constraints/cbo_query83.q.out      |   219 +
 .../perf/tez/constraints/cbo_query84.q.out      |    83 +
 .../perf/tez/constraints/cbo_query85.q.out      |   214 +
 .../perf/tez/constraints/cbo_query86.q.out      |    76 +
 .../perf/tez/constraints/cbo_query87.q.out      |   111 +
 .../perf/tez/constraints/cbo_query88.q.out      |   347 +
 .../perf/tez/constraints/cbo_query89.q.out      |    87 +
 .../perf/tez/constraints/cbo_query9.q.out       |   200 +
 .../perf/tez/constraints/cbo_query90.q.out      |    92 +
 .../perf/tez/constraints/cbo_query91.q.out      |   109 +
 .../perf/tez/constraints/cbo_query92.q.out      |    94 +
 .../perf/tez/constraints/cbo_query93.q.out      |    58 +
 .../perf/tez/constraints/cbo_query94.q.out      |    98 +
 .../perf/tez/constraints/cbo_query95.q.out      |   112 +
 .../perf/tez/constraints/cbo_query96.q.out      |    61 +
 .../perf/tez/constraints/cbo_query97.q.out      |    81 +
 .../perf/tez/constraints/cbo_query98.q.out      |    87 +
 .../perf/tez/constraints/cbo_query99.q.out      |   102 +
 .../perf/tez/constraints/query1.q.out           |   177 +
 .../perf/tez/constraints/query10.q.out          |   379 +
 .../perf/tez/constraints/query11.q.out          |   427 +
 .../perf/tez/constraints/query12.q.out          |   169 +
 .../perf/tez/constraints/query13.q.out          |   255 +
 .../perf/tez/constraints/query14.q.out          |  1400 +
 .../perf/tez/constraints/query15.q.out          |   142 +
 .../perf/tez/constraints/query16.q.out          |   244 +
 .../perf/tez/constraints/query17.q.out          |   319 +
 .../perf/tez/constraints/query18.q.out          |   239 +
 .../perf/tez/constraints/query19.q.out          |   196 +
 .../perf/tez/constraints/query2.q.out           |   228 +
 .../perf/tez/constraints/query20.q.out          |   161 +
 .../perf/tez/constraints/query21.q.out          |   145 +
 .../perf/tez/constraints/query22.q.out          |   112 +
 .../perf/tez/constraints/query23.q.out          |   540 +
 .../perf/tez/constraints/query24.q.out          |   363 +
 .../perf/tez/constraints/query25.q.out          |   321 +
 .../perf/tez/constraints/query26.q.out          |   171 +
 .../perf/tez/constraints/query27.q.out          |   189 +
 .../perf/tez/constraints/query28.q.out          |   296 +
 .../perf/tez/constraints/query29.q.out          |   328 +
 .../perf/tez/constraints/query3.q.out           |   135 +
 .../perf/tez/constraints/query30.q.out          |   221 +
 .../perf/tez/constraints/query31.q.out          |   492 +
 .../perf/tez/constraints/query32.q.out          |   210 +
 .../perf/tez/constraints/query33.q.out          |   450 +
 .../perf/tez/constraints/query34.q.out          |   203 +
 .../perf/tez/constraints/query35.q.out          |   361 +
 .../perf/tez/constraints/query36.q.out          |   182 +
 .../perf/tez/constraints/query37.q.out          |   146 +
 .../perf/tez/constraints/query38.q.out          |   261 +
 .../perf/tez/constraints/query39.q.out          |   236 +
 .../perf/tez/constraints/query4.q.out           |   623 +
 .../perf/tez/constraints/query40.q.out          |   183 +
 .../perf/tez/constraints/query42.q.out          |   139 +
 .../perf/tez/constraints/query43.q.out          |   135 +
 .../perf/tez/constraints/query44.q.out          |   193 +
 .../perf/tez/constraints/query45.q.out          |   183 +
 .../perf/tez/constraints/query46.q.out          |   240 +
 .../perf/tez/constraints/query47.q.out          |   266 +
 .../perf/tez/constraints/query48.q.out          |   252 +
 .../perf/tez/constraints/query49.q.out          |   555 +
 .../perf/tez/constraints/query5.q.out           |   531 +
 .../perf/tez/constraints/query50.q.out          |   242 +
 .../perf/tez/constraints/query51.q.out          |   222 +
 .../perf/tez/constraints/query52.q.out          |   139 +
 .../perf/tez/constraints/query53.q.out          |   161 +
 .../perf/tez/constraints/query54.q.out          |   439 +
 .../perf/tez/constraints/query55.q.out          |   123 +
 .../perf/tez/constraints/query56.q.out          |   470 +
 .../perf/tez/constraints/query57.q.out          |   260 +
 .../perf/tez/constraints/query58.q.out          |   397 +
 .../perf/tez/constraints/query59.q.out          |   234 +
 .../perf/tez/constraints/query6.q.out           |   236 +
 .../perf/tez/constraints/query60.q.out          |   496 +
 .../perf/tez/constraints/query61.q.out          |   388 +
 .../perf/tez/constraints/query63.q.out          |   163 +
 .../perf/tez/constraints/query64.q.out          |   758 +
 .../perf/tez/constraints/query65.q.out          |   220 +
 .../perf/tez/constraints/query66.q.out          |   702 +
 .../perf/tez/constraints/query67.q.out          |   196 +
 .../perf/tez/constraints/query68.q.out          |   254 +
 .../perf/tez/constraints/query69.q.out          |   359 +
 .../perf/tez/constraints/query7.q.out           |   171 +
 .../perf/tez/constraints/query70.q.out          |   216 +
 .../perf/tez/constraints/query71.q.out          |   297 +
 .../perf/tez/constraints/query72.q.out          |   297 +
 .../perf/tez/constraints/query73.q.out          |   197 +
 .../perf/tez/constraints/query74.q.out          |   397 +
 .../perf/tez/constraints/query75.q.out          |   662 +
 .../perf/tez/constraints/query76.q.out          |   197 +
 .../perf/tez/constraints/query77.q.out          |   504 +
 .../perf/tez/constraints/query78.q.out          |   345 +
 .../perf/tez/constraints/query79.q.out          |   175 +
 .../perf/tez/constraints/query8.q.out           |   397 +
 .../perf/tez/constraints/query80.q.out          |   609 +
 .../perf/tez/constraints/query81.q.out          |   220 +
 .../perf/tez/constraints/query82.q.out          |   146 +
 .../perf/tez/constraints/query83.q.out          |   338 +
 .../perf/tez/constraints/query84.q.out          |   153 +
 .../perf/tez/constraints/query85.q.out          |   320 +
 .../perf/tez/constraints/query86.q.out          |   145 +
 .../perf/tez/constraints/query87.q.out          |   288 +
 .../perf/tez/constraints/query88.q.out          |   946 +
 .../perf/tez/constraints/query89.q.out          |   178 +
 .../perf/tez/constraints/query9.q.out           |   450 +
 .../perf/tez/constraints/query90.q.out          |   263 +
 .../perf/tez/constraints/query91.q.out          |   196 +
 .../perf/tez/constraints/query92.q.out          |   221 +
 .../perf/tez/constraints/query93.q.out          |   131 +
 .../perf/tez/constraints/query94.q.out          |   240 +
 .../perf/tez/constraints/query95.q.out          |   271 +
 .../perf/tez/constraints/query96.q.out          |   155 +
 .../perf/tez/constraints/query97.q.out          |   166 +
 .../perf/tez/constraints/query98.q.out          |   165 +
 .../perf/tez/constraints/query99.q.out          |   195 +
 .../clientpositive/perf/tez/query1.q.out        |    80 +-
 .../clientpositive/perf/tez/query10.q.out       |   406 +-
 .../clientpositive/perf/tez/query11.q.out       |   512 +-
 .../clientpositive/perf/tez/query12.q.out       |    54 +-
 .../clientpositive/perf/tez/query13.q.out       |   302 +-
 .../clientpositive/perf/tez/query14.q.out       |  2074 +-
 .../clientpositive/perf/tez/query15.q.out       |    64 +-
 .../clientpositive/perf/tez/query16.q.out       |   187 +-
 .../clientpositive/perf/tez/query17.q.out       |   277 +-
 .../clientpositive/perf/tez/query18.q.out       |   248 +-
 .../clientpositive/perf/tez/query19.q.out       |   196 +-
 .../clientpositive/perf/tez/query2.q.out        |   209 +-
 .../clientpositive/perf/tez/query20.q.out       |    54 +-
 .../clientpositive/perf/tez/query21.q.out       |    54 +-
 .../clientpositive/perf/tez/query22.q.out       |    52 +-
 .../clientpositive/perf/tez/query23.q.out       |   749 +-
 .../clientpositive/perf/tez/query24.q.out       |   538 +-
 .../clientpositive/perf/tez/query25.q.out       |   265 +-
 .../clientpositive/perf/tez/query26.q.out       |   124 +-
 .../clientpositive/perf/tez/query27.q.out       |   108 +-
 .../clientpositive/perf/tez/query28.q.out       |   300 +-
 .../clientpositive/perf/tez/query29.q.out       |   290 +-
 .../clientpositive/perf/tez/query3.q.out        |    48 +-
 .../clientpositive/perf/tez/query30.q.out       |    94 +-
 .../clientpositive/perf/tez/query31.q.out       |   712 +-
 .../clientpositive/perf/tez/query32.q.out       |   167 +-
 .../clientpositive/perf/tez/query33.q.out       |   414 +-
 .../clientpositive/perf/tez/query34.q.out       |   190 +-
 .../clientpositive/perf/tez/query35.q.out       |   392 +-
 .../clientpositive/perf/tez/query36.q.out       |   100 +-
 .../clientpositive/perf/tez/query37.q.out       |   166 +-
 .../clientpositive/perf/tez/query38.q.out       |   202 +-
 .../clientpositive/perf/tez/query39.q.out       |    80 +-
 .../clientpositive/perf/tez/query4.q.out        |   774 +-
 .../clientpositive/perf/tez/query40.q.out       |   106 +-
 .../clientpositive/perf/tez/query42.q.out       |    50 +-
 .../clientpositive/perf/tez/query43.q.out       |    52 +-
 .../clientpositive/perf/tez/query44.q.out       |    74 +-
 .../clientpositive/perf/tez/query45.q.out       |   186 +-
 .../clientpositive/perf/tez/query46.q.out       |   226 +-
 .../clientpositive/perf/tez/query47.q.out       |   290 +-
 .../clientpositive/perf/tez/query48.q.out       |   240 +-
 .../clientpositive/perf/tez/query49.q.out       |   174 +-
 .../clientpositive/perf/tez/query5.q.out        |   324 +-
 .../clientpositive/perf/tez/query50.q.out       |   136 +-
 .../clientpositive/perf/tez/query51.q.out       |    70 +-
 .../clientpositive/perf/tez/query52.q.out       |    50 +-
 .../clientpositive/perf/tez/query53.q.out       |    98 +-
 .../clientpositive/perf/tez/query54.q.out       |   580 +-
 .../clientpositive/perf/tez/query55.q.out       |    50 +-
 .../clientpositive/perf/tez/query56.q.out       |   154 +-
 .../clientpositive/perf/tez/query57.q.out       |   290 +-
 .../clientpositive/perf/tez/query58.q.out       |   442 +-
 .../clientpositive/perf/tez/query59.q.out       |   213 +-
 .../clientpositive/perf/tez/query6.q.out        |   300 +-
 .../clientpositive/perf/tez/query60.q.out       |   160 +-
 .../clientpositive/perf/tez/query61.q.out       |   196 +-
 .../clientpositive/perf/tez/query63.q.out       |    98 +-
 .../clientpositive/perf/tez/query64.q.out       |   989 +-
 .../clientpositive/perf/tez/query65.q.out       |   301 +-
 .../clientpositive/perf/tez/query66.q.out       |   196 +-
 .../clientpositive/perf/tez/query67.q.out       |   120 +-
 .../clientpositive/perf/tez/query68.q.out       |   226 +-
 .../clientpositive/perf/tez/query69.q.out       |   412 +-
 .../clientpositive/perf/tez/query7.q.out        |   124 +-
 .../clientpositive/perf/tez/query70.q.out       |   218 +-
 .../clientpositive/perf/tez/query71.q.out       |   112 +-
 .../clientpositive/perf/tez/query72.q.out       |   310 +-
 .../clientpositive/perf/tez/query73.q.out       |   190 +-
 .../clientpositive/perf/tez/query74.q.out       |   498 +-
 .../clientpositive/perf/tez/query75.q.out       |   230 +-
 .../clientpositive/perf/tez/query76.q.out       |   249 +-
 .../clientpositive/perf/tez/query77.q.out       |   306 +-
 .../clientpositive/perf/tez/query78.q.out       |   132 +-
 .../clientpositive/perf/tez/query79.q.out       |   176 +-
 .../clientpositive/perf/tez/query8.q.out        |   108 +-
 .../clientpositive/perf/tez/query80.q.out       |   354 +-
 .../clientpositive/perf/tez/query81.q.out       |    96 +-
 .../clientpositive/perf/tez/query82.q.out       |   166 +-
 .../clientpositive/perf/tez/query83.q.out       |   298 +-
 .../clientpositive/perf/tez/query84.q.out       |   154 +-
 .../clientpositive/perf/tez/query85.q.out       |   254 +-
 .../clientpositive/perf/tez/query86.q.out       |    86 +-
 .../clientpositive/perf/tez/query87.q.out       |   228 +-
 .../clientpositive/perf/tez/query88.q.out       |  1400 +-
 .../clientpositive/perf/tez/query89.q.out       |   120 +-
 .../clientpositive/perf/tez/query9.q.out        |   138 +-
 .../clientpositive/perf/tez/query90.q.out       |    86 +-
 .../clientpositive/perf/tez/query91.q.out       |    92 +-
 .../clientpositive/perf/tez/query92.q.out       |   173 +-
 .../clientpositive/perf/tez/query93.q.out       |    58 +-
 .../clientpositive/perf/tez/query94.q.out       |   187 +-
 .../clientpositive/perf/tez/query95.q.out       |   424 +-
 .../clientpositive/perf/tez/query96.q.out       |    60 +-
 .../clientpositive/perf/tez/query97.q.out       |    52 +-
 .../clientpositive/perf/tez/query98.q.out       |    52 +-
 .../clientpositive/perf/tez/query99.q.out       |   138 +-
 .../test/results/clientpositive/plan_json.q.out |     4 +
 .../results/clientpositive/pointlookup.q.out    |    12 +
 .../results/clientpositive/pointlookup2.q.out   |    88 +
 .../results/clientpositive/pointlookup3.q.out   |    76 +
 .../results/clientpositive/pointlookup4.q.out   |    16 +
 .../results/clientpositive/pointlookup5.q.out   |   134 +
 .../clientpositive/position_alias_test_1.q.out  |     8 +
 ql/src/test/results/clientpositive/ppd1.q.out   |     8 +
 ql/src/test/results/clientpositive/ppd2.q.out   |    28 +
 .../results/clientpositive/ppd_clusterby.q.out  |    16 +
 .../clientpositive/ppd_constant_expr.q.out      |     8 +
 .../clientpositive/ppd_constant_where.q.out     |     4 +
 .../clientpositive/ppd_deterministic_expr.q.out |    28 +
 .../test/results/clientpositive/ppd_gby.q.out   |     8 +
 .../test/results/clientpositive/ppd_gby2.q.out  |     8 +
 .../results/clientpositive/ppd_gby_join.q.out   |     8 +
 .../test/results/clientpositive/ppd_join.q.out  |     8 +
 .../test/results/clientpositive/ppd_join2.q.out |     8 +
 .../test/results/clientpositive/ppd_join3.q.out |     8 +
 .../test/results/clientpositive/ppd_join4.q.out |     4 +
 .../test/results/clientpositive/ppd_join5.q.out |    12 +
 .../clientpositive/ppd_join_filter.q.out        |    16 +
 .../clientpositive/ppd_multi_insert.q.out       |    20 +
 .../clientpositive/ppd_outer_join1.q.out        |     8 +
 .../clientpositive/ppd_outer_join2.q.out        |     8 +
 .../clientpositive/ppd_outer_join3.q.out        |     8 +
 .../clientpositive/ppd_outer_join4.q.out        |     8 +
 .../clientpositive/ppd_outer_join5.q.out        |    24 +
 .../results/clientpositive/ppd_random.q.out     |     8 +
 .../clientpositive/ppd_repeated_alias.q.out     |    22 +
 .../results/clientpositive/ppd_transform.q.out  |    18 +
 .../results/clientpositive/ppd_udf_case.q.out   |    16 +
 .../results/clientpositive/ppd_udf_col.q.out    |    64 +
 .../test/results/clientpositive/ppd_udtf.q.out  |     4 +
 .../test/results/clientpositive/ppd_union.q.out |     8 +
 ql/src/test/results/clientpositive/ppd_vc.q.out |    26 +
 .../results/clientpositive/ppd_windowing1.q.out |    96 +
 .../clientpositive/ppr_allchildsarenull.q.out   |    20 +
 .../results/clientpositive/ppr_pushdown3.q.out  |    36 +
 .../results/clientpositive/ptf_matchpath.q.out  |    12 +
 .../results/clientpositive/ptfgroupbyjoin.q.out |    18 +
 .../test/results/clientpositive/push_or.q.out   |     8 +
 .../query_result_fileformat.q.out               |     8 +
 ql/src/test/results/clientpositive/quote1.q.out |     8 +
 ql/src/test/results/clientpositive/quote2.q.out |     4 +
 .../results/clientpositive/quotedid_basic.q.out |    20 +
 .../clientpositive/quotedid_partition.q.out     |     6 +
 .../results/clientpositive/quotedid_skew.q.out  |     6 +
 .../clientpositive/rand_partitionpruner1.q.out  |     4 +
 .../clientpositive/rand_partitionpruner2.q.out  |     8 +
 .../clientpositive/rand_partitionpruner3.q.out  |    12 +
 .../clientpositive/rcfile_null_value.q.out      |     4 +
 .../reduceSinkDeDuplication_pRS_key_empty.q.out |   Bin 10695 -> 10953 bytes
 .../reduce_deduplicate_exclude_join.q.out       |     4 +
 .../reduce_deduplicate_extended2.q.out          |    24 +
 .../test/results/clientpositive/regex_col.q.out |   108 +
 .../results/clientpositive/regexp_extract.q.out |     8 +
 .../test/results/clientpositive/reloadJar.q.out |     4 +
 .../clientpositive/remove_exprs_stats.q.out     |    88 +
 ql/src/test/results/clientpositive/repair.q.out |     3 +
 .../clientpositive/router_join_ppr.q.out        |    40 +
 .../test/results/clientpositive/row__id.q.out   |    20 +
 .../runtime_skewjoin_mapjoin_spark.q.out        |     6 +
 .../test/results/clientpositive/sample1.q.out   |     6 +
 .../test/results/clientpositive/sample3.q.out   |     4 +
 .../test/results/clientpositive/sample5.q.out   |     4 +
 .../test/results/clientpositive/sample6.q.out   |    32 +
 .../test/results/clientpositive/sample7.q.out   |     4 +
 .../test/results/clientpositive/sample8.q.out   |    24 +
 .../test/results/clientpositive/sample9.q.out   |     4 +
 .../sample_islocalmode_hook_use_metadata.q.out  |     6 +
 .../results/clientpositive/script_pipe.q.out    |     8 +
 .../clientpositive/select_as_omitted.q.out      |     4 +
 .../clientpositive/select_column_pruning.q.out  |     4 +
 .../clientpositive/select_dummy_source.q.out    |    28 +
 .../clientpositive/select_transform_hint.q.out  |    12 +
 .../clientpositive/select_unquote_and.q.out     |     8 +
 .../clientpositive/select_unquote_not.q.out     |     8 +
 .../clientpositive/select_unquote_or.q.out      |     8 +
 .../test/results/clientpositive/semijoin2.q.out |     6 +
 .../test/results/clientpositive/semijoin3.q.out |     6 +
 .../test/results/clientpositive/semijoin4.q.out |    95 +-
 .../test/results/clientpositive/semijoin5.q.out |    70 +-
 .../results/clientpositive/serde_opencsv.q.out  |     4 +
 .../results/clientpositive/serde_regex.q.out    |     8 +
 .../clientpositive/serde_user_properties.q.out  |    28 +
 .../set_processor_namespaces.q.out              |     4 +
 .../clientpositive/set_variable_sub.q.out       |    12 +
 .../results/clientpositive/setop_subq.q.out     |    20 +
 .../results/clientpositive/show_columns.q.out   |     2 +
 .../results/clientpositive/show_functions.q.out |     3 +
 .../show_materialized_views.q.out               |    20 +-
 .../results/clientpositive/show_tables.q.out    |     4 +
 .../clientpositive/show_tblproperties.q.out     |    10 +-
 .../test/results/clientpositive/showparts.q.out |     2 +
 .../test/results/clientpositive/skewjoin.q.out  |    46 +
 .../clientpositive/skewjoin_mapjoin1.q.out      |    24 +
 .../clientpositive/skewjoin_mapjoin10.q.out     |    24 +
 .../clientpositive/skewjoin_mapjoin11.q.out     |     6 +
 .../clientpositive/skewjoin_mapjoin2.q.out      |    12 +
 .../clientpositive/skewjoin_mapjoin3.q.out      |     6 +
 .../clientpositive/skewjoin_mapjoin4.q.out      |     8 +
 .../clientpositive/skewjoin_mapjoin5.q.out      |    12 +
 .../clientpositive/skewjoin_mapjoin6.q.out      |     6 +
 .../clientpositive/skewjoin_mapjoin7.q.out      |     6 +
 .../clientpositive/skewjoin_mapjoin8.q.out      |     8 +
 .../clientpositive/skewjoin_mapjoin9.q.out      |     8 +
 .../clientpositive/skewjoin_noskew.q.out        |     6 +
 .../clientpositive/skewjoin_onesideskew.q.out   |     8 +
 .../skewjoin_union_remove_1.q.out               |    24 +
 .../skewjoin_union_remove_2.q.out               |     8 +
 .../results/clientpositive/skewjoinopt1.q.out   |    24 +
 .../results/clientpositive/skewjoinopt10.q.out  |     6 +
 .../results/clientpositive/skewjoinopt11.q.out  |     6 +
 .../results/clientpositive/skewjoinopt12.q.out  |     6 +
 .../results/clientpositive/skewjoinopt13.q.out  |     8 +
 .../results/clientpositive/skewjoinopt14.q.out  |     8 +
 .../results/clientpositive/skewjoinopt16.q.out  |     6 +
 .../results/clientpositive/skewjoinopt17.q.out  |    12 +
 .../results/clientpositive/skewjoinopt18.q.out  |     6 +
 .../results/clientpositive/skewjoinopt19.q.out  |     6 +
 .../results/clientpositive/skewjoinopt2.q.out   |    24 +
 .../results/clientpositive/skewjoinopt20.q.out  |     6 +
 .../results/clientpositive/skewjoinopt21.q.out  |     6 +
 .../results/clientpositive/skewjoinopt3.q.out   |    12 +
 .../results/clientpositive/skewjoinopt4.q.out   |    12 +
 .../results/clientpositive/skewjoinopt5.q.out   |     6 +
 .../results/clientpositive/skewjoinopt6.q.out   |     6 +
 .../results/clientpositive/skewjoinopt7.q.out   |     8 +
 .../results/clientpositive/skewjoinopt8.q.out   |     8 +
 .../results/clientpositive/skewjoinopt9.q.out   |    12 +
 .../results/clientpositive/smb_mapjoin9.q.out   |    24 +
 .../results/clientpositive/smb_mapjoin_1.q.out  |    48 +
 .../results/clientpositive/smb_mapjoin_10.q.out |     8 +
 .../results/clientpositive/smb_mapjoin_11.q.out |    22 +
 .../results/clientpositive/smb_mapjoin_12.q.out |    24 +
 .../results/clientpositive/smb_mapjoin_13.q.out |    12 +
 .../results/clientpositive/smb_mapjoin_16.q.out |     6 +
 .../results/clientpositive/smb_mapjoin_2.q.out  |    48 +
 .../results/clientpositive/smb_mapjoin_20.q.out |    18 +
 .../results/clientpositive/smb_mapjoin_21.q.out |    36 +
 .../results/clientpositive/smb_mapjoin_22.q.out |     8 +
 .../results/clientpositive/smb_mapjoin_25.q.out |    16 +
 .../results/clientpositive/smb_mapjoin_3.q.out  |    48 +
 .../results/clientpositive/smb_mapjoin_46.q.out |   102 +
 .../results/clientpositive/smb_mapjoin_47.q.out |    78 +
 .../results/clientpositive/smb_mapjoin_7.q.out  |     6 +
 ql/src/test/results/clientpositive/sort.q.out   |     4 +
 .../clientpositive/sort_merge_join_desc_1.q.out |     6 +
 .../clientpositive/sort_merge_join_desc_2.q.out |     6 +
 .../clientpositive/sort_merge_join_desc_3.q.out |     6 +
 .../clientpositive/sort_merge_join_desc_4.q.out |     6 +
 .../clientpositive/sort_merge_join_desc_5.q.out |    10 +
 .../clientpositive/sort_merge_join_desc_6.q.out |    10 +
 .../clientpositive/sort_merge_join_desc_7.q.out |    14 +
 .../clientpositive/sort_merge_join_desc_8.q.out |    12 +
 ql/src/test/results/clientpositive/source.q.out |     8 +
 .../spark/add_part_multiple.q.out               |     4 +
 .../spark/annotate_stats_join.q.out             |    70 +
 .../clientpositive/spark/auto_join0.q.out       |     4 +
 .../clientpositive/spark/auto_join1.q.out       |     4 +
 .../clientpositive/spark/auto_join10.q.out      |     4 +
 .../clientpositive/spark/auto_join11.q.out      |     4 +
 .../clientpositive/spark/auto_join12.q.out      |     4 +
 .../clientpositive/spark/auto_join13.q.out      |     4 +
 .../clientpositive/spark/auto_join14.q.out      |    10 +
 .../clientpositive/spark/auto_join15.q.out      |     4 +
 .../clientpositive/spark/auto_join16.q.out      |     4 +
 .../clientpositive/spark/auto_join17.q.out      |     4 +
 .../clientpositive/spark/auto_join18.q.out      |     6 +
 .../spark/auto_join18_multi_distinct.q.out      |     6 +
 .../clientpositive/spark/auto_join19.q.out      |    14 +
 .../clientpositive/spark/auto_join2.q.out       |     4 +
 .../clientpositive/spark/auto_join20.q.out      |     8 +
 .../clientpositive/spark/auto_join21.q.out      |     4 +
 .../clientpositive/spark/auto_join22.q.out      |     4 +
 .../clientpositive/spark/auto_join23.q.out      |     4 +
 .../clientpositive/spark/auto_join24.q.out      |     4 +
 .../clientpositive/spark/auto_join26.q.out      |     6 +
 .../clientpositive/spark/auto_join27.q.out      |     4 +
 .../clientpositive/spark/auto_join28.q.out      |    16 +
 .../clientpositive/spark/auto_join29.q.out      |    36 +
 .../clientpositive/spark/auto_join3.q.out       |     4 +
 .../clientpositive/spark/auto_join30.q.out      |    32 +
 .../clientpositive/spark/auto_join31.q.out      |     4 +
 .../clientpositive/spark/auto_join32.q.out      |    24 +
 .../clientpositive/spark/auto_join4.q.out       |     4 +
 .../clientpositive/spark/auto_join5.q.out       |     4 +
 .../clientpositive/spark/auto_join6.q.out       |     4 +
 .../clientpositive/spark/auto_join7.q.out       |     4 +
 .../clientpositive/spark/auto_join8.q.out       |     4 +
 .../clientpositive/spark/auto_join9.q.out       |     8 +
 .../spark/auto_join_filters.q.out               |    12 +
 .../clientpositive/spark/auto_join_nulls.q.out  |     4 +
 .../spark/auto_join_reordering_values.q.out     |     6 +
 .../clientpositive/spark/auto_join_stats.q.out  |    14 +
 .../clientpositive/spark/auto_join_stats2.q.out |    14 +
 .../spark/auto_join_without_localtask.q.out     |    12 +
 .../spark/auto_smb_mapjoin_14.q.out             |    80 +
 .../spark/auto_sortmerge_join_1.q.out           |    36 +
 .../spark/auto_sortmerge_join_12.q.out          |    16 +
 .../spark/auto_sortmerge_join_13.q.out          |    24 +
 .../spark/auto_sortmerge_join_14.q.out          |    12 +
 .../spark/auto_sortmerge_join_15.q.out          |    12 +
 .../spark/auto_sortmerge_join_16.q.out          |    36 +
 .../spark/auto_sortmerge_join_16.q.out_spark    |    36 +
 .../spark/auto_sortmerge_join_2.q.out           |    24 +
 .../spark/auto_sortmerge_join_3.q.out           |    36 +
 .../spark/auto_sortmerge_join_4.q.out           |    36 +
 .../spark/auto_sortmerge_join_5.q.out           |    18 +
 .../spark/auto_sortmerge_join_6.q.out           |    80 +
 .../spark/auto_sortmerge_join_7.q.out           |    42 +
 .../spark/auto_sortmerge_join_8.q.out           |    42 +
 .../spark/auto_sortmerge_join_9.q.out           |   146 +
 .../results/clientpositive/spark/bucket2.q.out  |     8 +
 .../results/clientpositive/spark/bucket3.q.out  |    10 +
 .../results/clientpositive/spark/bucket4.q.out  |     8 +
 .../clientpositive/spark/bucket4.q.out_spark    |     8 +
 .../results/clientpositive/spark/bucket5.q.out  |     6 +
 .../results/clientpositive/spark/bucket6.q.out  |    12 +
 .../spark/bucket_map_join_1.q.out               |     6 +
 .../spark/bucket_map_join_2.q.out               |     6 +
 .../spark/bucket_map_join_spark1.q.out          |    20 +
 .../spark/bucket_map_join_spark2.q.out          |    20 +
 .../spark/bucket_map_join_spark3.q.out          |    20 +
 .../spark/bucket_map_join_spark4.q.out          |    16 +
 .../spark/bucket_map_join_tez1.q.out            |   328 +
 .../spark/bucket_map_join_tez2.q.out            |   132 +
 .../clientpositive/spark/bucketmapjoin1.q.out   |    28 +
 .../clientpositive/spark/bucketmapjoin10.q.out  |    14 +
 .../clientpositive/spark/bucketmapjoin11.q.out  |    28 +
 .../clientpositive/spark/bucketmapjoin12.q.out  |    20 +
 .../clientpositive/spark/bucketmapjoin13.q.out  |    42 +
 .../clientpositive/spark/bucketmapjoin2.q.out   |    32 +
 .../clientpositive/spark/bucketmapjoin3.q.out   |    20 +
 .../clientpositive/spark/bucketmapjoin4.q.out   |     8 +
 .../clientpositive/spark/bucketmapjoin5.q.out   |    20 +
 .../clientpositive/spark/bucketmapjoin7.q.out   |    10 +
 .../spark/bucketmapjoin7.q.out_spark            |    10 +
 .../clientpositive/spark/bucketmapjoin8.q.out   |    20 +
 .../clientpositive/spark/bucketmapjoin9.q.out   |    20 +
 .../spark/bucketmapjoin_negative.q.out          |     8 +
 .../spark/bucketmapjoin_negative2.q.out         |    10 +
 .../spark/bucketmapjoin_negative3.q.out         |    48 +
 .../spark/bucketsortoptimize_insert_2.q.out     |    64 +
 .../spark/bucketsortoptimize_insert_4.q.out     |    20 +
 .../spark/bucketsortoptimize_insert_6.q.out     |    70 +
 .../spark/bucketsortoptimize_insert_7.q.out     |    30 +
 .../spark/bucketsortoptimize_insert_8.q.out     |    20 +
 .../spark/cbo_simple_select.q.out               |    36 +
 .../spark/column_access_stats.q.out             |    21 +
 .../spark/constprog_partitioner.q.out           |     8 +
 .../spark/constprog_semijoin.q.out              |    52 +
 .../results/clientpositive/spark/count.q.out    |    48 +
 .../clientpositive/spark/cross_join.q.out       |    24 +
 .../spark/cross_product_check_1.q.out           |    30 +
 .../spark/cross_product_check_2.q.out           |    30 +
 .../results/clientpositive/spark/ctas.q.out     |    30 +
 .../spark/disable_merge_for_bucketing.q.out     |     8 +
 .../disable_merge_for_bucketing.q.out_spark     |     8 +
 .../spark/dynamic_rdd_cache.q.out               |    32 +
 .../spark/escape_clusterby1.q.out               |     8 +
 .../spark/escape_distributeby1.q.out            |     8 +
 .../clientpositive/spark/escape_orderby1.q.out  |     8 +
 .../clientpositive/spark/escape_sortby1.q.out   |     8 +
 .../spark/explaindenpendencydiffengs.q.out      |     8 +
 .../spark/filter_join_breaktask.q.out           |     6 +
 .../spark/gen_udf_example_add10.q.out           |     4 +
 .../results/clientpositive/spark/groupby1.q.out |     4 +
 .../clientpositive/spark/groupby10.q.out        |    18 +
 .../clientpositive/spark/groupby11.q.out        |     6 +
 .../clientpositive/spark/groupby1_map.q.out     |     4 +
 .../spark/groupby1_map_nomap.q.out              |     4 +
 .../spark/groupby1_map_skew.q.out               |     4 +
 .../clientpositive/spark/groupby1_noskew.q.out  |     4 +
 .../results/clientpositive/spark/groupby2.q.out |     4 +
 .../clientpositive/spark/groupby2_map.q.out     |     4 +
 .../spark/groupby2_map_multi_distinct.q.out     |     8 +
 .../spark/groupby2_map_skew.q.out               |     4 +
 .../clientpositive/spark/groupby2_noskew.q.out  |     4 +
 .../spark/groupby2_noskew_multi_distinct.q.out  |     4 +
 .../results/clientpositive/spark/groupby3.q.out |     4 +
 .../clientpositive/spark/groupby3_map.q.out     |     4 +
 .../spark/groupby3_map_multi_distinct.q.out     |     4 +
 .../spark/groupby3_map_skew.q.out               |     4 +
 .../clientpositive/spark/groupby3_noskew.q.out  |     4 +
 .../spark/groupby3_noskew_multi_distinct.q.out  |     4 +
 .../results/clientpositive/spark/groupby4.q.out |     4 +
 .../clientpositive/spark/groupby4_map.q.out     |     4 +
 .../spark/groupby4_map_skew.q.out               |     4 +
 .../clientpositive/spark/groupby4_noskew.q.out  |     4 +
 .../results/clientpositive/spark/groupby5.q.out |     4 +
 .../clientpositive/spark/groupby5_map.q.out     |     4 +
 .../spark/groupby5_map_skew.q.out               |     4 +
 .../clientpositive/spark/groupby5_noskew.q.out  |     4 +
 .../results/clientpositive/spark/groupby6.q.out |     4 +
 .../clientpositive/spark/groupby6_map.q.out     |     4 +
 .../spark/groupby6_map_skew.q.out               |     4 +
 .../clientpositive/spark/groupby6_noskew.q.out  |     4 +
 .../clientpositive/spark/groupby7_map.q.out     |     6 +
 .../groupby7_map_multi_single_reducer.q.out     |     6 +
 .../spark/groupby7_map_skew.q.out               |     6 +
 .../clientpositive/spark/groupby7_noskew.q.out  |     6 +
 .../groupby7_noskew_multi_single_reducer.q.out  |     6 +
 .../results/clientpositive/spark/groupby8.q.out |    12 +
 .../clientpositive/spark/groupby8_map.q.out     |     6 +
 .../spark/groupby8_map_skew.q.out               |     6 +
 .../clientpositive/spark/groupby8_noskew.q.out  |     6 +
 .../results/clientpositive/spark/groupby9.q.out |    30 +
 .../spark/groupby_complex_types.q.out           |     8 +
 ...pby_complex_types_multi_single_reducer.q.out |     6 +
 .../clientpositive/spark/groupby_cube1.q.out    |    30 +
 .../clientpositive/spark/groupby_map_ppr.q.out  |     8 +
 .../spark/groupby_map_ppr_multi_distinct.q.out  |     8 +
 .../groupby_multi_insert_common_distinct.q.out  |     6 +
 .../spark/groupby_multi_single_reducer.q.out    |    20 +
 .../spark/groupby_multi_single_reducer2.q.out   |     6 +
 .../spark/groupby_multi_single_reducer3.q.out   |    24 +
 .../clientpositive/spark/groupby_position.q.out |    28 +
 .../clientpositive/spark/groupby_ppr.q.out      |     8 +
 .../spark/groupby_ppr_multi_distinct.q.out      |    16 +
 .../spark/groupby_resolution.q.out              |    40 +
 .../clientpositive/spark/groupby_rollup1.q.out  |    22 +
 .../spark/groupby_sort_1_23.q.out               |    80 +
 .../spark/groupby_sort_skew_1_23.q.out          |    80 +
 .../results/clientpositive/spark/having.q.out   |    24 +
 .../spark/identity_project_remove_skip.q.out    |     4 +
 .../spark/infer_bucket_sort_map_operators.q.out |    22 +
 .../spark/infer_bucket_sort_num_buckets.q.out   |     7 +
 .../clientpositive/spark/innerjoin.q.out        |     8 +
 .../results/clientpositive/spark/input12.q.out  |     8 +
 .../results/clientpositive/spark/input13.q.out  |    10 +
 .../results/clientpositive/spark/input14.q.out  |     4 +
 .../results/clientpositive/spark/input17.q.out  |     4 +
 .../results/clientpositive/spark/input18.q.out  |     4 +
 .../clientpositive/spark/input1_limit.q.out     |     6 +
 .../clientpositive/spark/input_part2.q.out      |    10 +
 .../results/clientpositive/spark/insert1.q.out  |    22 +
 .../clientpositive/spark/insert_into1.q.out     |    40 +
 .../clientpositive/spark/insert_into2.q.out     |    34 +
 .../clientpositive/spark/insert_into3.q.out     |    12 +
 .../results/clientpositive/spark/join0.q.out    |     7 +
 .../results/clientpositive/spark/join1.q.out    |     4 +
 .../results/clientpositive/spark/join10.q.out   |     4 +
 .../results/clientpositive/spark/join11.q.out   |     4 +
 .../results/clientpositive/spark/join12.q.out   |     4 +
 .../results/clientpositive/spark/join13.q.out   |     4 +
 .../results/clientpositive/spark/join14.q.out   |    10 +
 .../results/clientpositive/spark/join15.q.out   |     4 +
 .../results/clientpositive/spark/join16.q.out   |     4 +
 .../results/clientpositive/spark/join17.q.out   |     4 +
 .../results/clientpositive/spark/join18.q.out   |     6 +
 .../spark/join18_multi_distinct.q.out           |     6 +
 .../results/clientpositive/spark/join19.q.out   |     4 +
 .../results/clientpositive/spark/join2.q.out    |     4 +
 .../results/clientpositive/spark/join20.q.out   |     8 +
 .../results/clientpositive/spark/join21.q.out   |     4 +
 .../results/clientpositive/spark/join22.q.out   |     4 +
 .../results/clientpositive/spark/join23.q.out   |     4 +
 .../results/clientpositive/spark/join25.q.out   |     6 +
 .../results/clientpositive/spark/join26.q.out   |    10 +
 .../results/clientpositive/spark/join27.q.out   |     6 +
 .../results/clientpositive/spark/join28.q.out   |    10 +
 .../results/clientpositive/spark/join29.q.out   |     6 +
 .../results/clientpositive/spark/join3.q.out    |     4 +
 .../results/clientpositive/spark/join30.q.out   |     6 +
 .../results/clientpositive/spark/join31.q.out   |     6 +
 .../results/clientpositive/spark/join32.q.out   |    10 +
 .../clientpositive/spark/join32_lessSize.q.out  |    56 +
 .../results/clientpositive/spark/join33.q.out   |    10 +
 .../results/clientpositive/spark/join34.q.out   |     6 +
 .../results/clientpositive/spark/join35.q.out   |     6 +
 .../results/clientpositive/spark/join36.q.out   |     6 +
 .../results/clientpositive/spark/join37.q.out   |     6 +
 .../results/clientpositive/spark/join38.q.out   |     6 +
 .../results/clientpositive/spark/join39.q.out   |     4 +
 .../results/clientpositive/spark/join4.q.out    |     4 +
 .../results/clientpositive/spark/join40.q.out   |    24 +
 .../results/clientpositive/spark/join41.q.out   |     8 +
 .../results/clientpositive/spark/join5.q.out    |     4 +
 .../results/clientpositive/spark/join6.q.out    |     4 +
 .../results/clientpositive/spark/join7.q.out    |     4 +
 .../results/clientpositive/spark/join8.q.out    |     4 +
 .../results/clientpositive/spark/join9.q.out    |     8 +
 .../clientpositive/spark/join_alt_syntax.q.out  |    24 +
 .../spark/join_cond_pushdown_1.q.out            |    16 +
 .../spark/join_cond_pushdown_2.q.out            |     8 +
 .../spark/join_cond_pushdown_3.q.out            |    16 +
 .../spark/join_cond_pushdown_4.q.out            |     8 +
 .../spark/join_cond_pushdown_unqual1.q.out      |    32 +
 .../spark/join_cond_pushdown_unqual2.q.out      |    16 +
 .../spark/join_cond_pushdown_unqual3.q.out      |    32 +
 .../spark/join_cond_pushdown_unqual4.q.out      |    16 +
 .../spark/join_filters_overlap.q.out            |    20 +
 .../clientpositive/spark/join_hive_626.q.out    |     8 +
 .../clientpositive/spark/join_map_ppr.q.out     |    20 +
 .../spark/join_merge_multi_expressions.q.out    |    12 +
 .../clientpositive/spark/join_merging.q.out     |     8 +
 .../clientpositive/spark/join_nullsafe.q.out    |    24 +
 .../results/clientpositive/spark/join_rc.q.out  |     6 +
 .../clientpositive/spark/join_reorder.q.out     |    44 +
 .../clientpositive/spark/join_reorder2.q.out    |    20 +
 .../clientpositive/spark/join_reorder3.q.out    |    20 +
 .../clientpositive/spark/join_reorder4.q.out    |    24 +
 .../clientpositive/spark/join_star.q.out        |    48 +
 .../clientpositive/spark/join_thrift.q.out      |     4 +
 .../results/clientpositive/spark/join_vc.q.out  |     8 +
 .../clientpositive/spark/join_view.q.out        |     8 +
 .../spark/lateral_view_explode2.q.out           |     4 +
 .../clientpositive/spark/leftsemijoin.q.out     |     8 +
 .../clientpositive/spark/limit_pushdown.q.out   |    56 +
 .../clientpositive/spark/limit_pushdown2.q.out  |    44 +
 .../spark/list_bucket_dml_10.q.out              |     4 +
 .../spark/list_bucket_dml_2.q.out               |    14 +
 .../clientpositive/spark/load_dyn_part1.q.out   |    12 +
 .../clientpositive/spark/load_dyn_part10.q.out  |     7 +
 .../clientpositive/spark/load_dyn_part13.q.out  |     3 +
 .../clientpositive/spark/load_dyn_part14.q.out  |     3 +
 .../clientpositive/spark/load_dyn_part2.q.out   |    11 +
 .../clientpositive/spark/load_dyn_part3.q.out   |    11 +
 .../clientpositive/spark/load_dyn_part4.q.out   |    11 +
 .../clientpositive/spark/load_dyn_part5.q.out   |     3 +
 .../clientpositive/spark/load_dyn_part8.q.out   |    12 +
 .../clientpositive/spark/load_dyn_part9.q.out   |     7 +
 .../clientpositive/spark/louter_join_ppr.q.out  |    40 +
 .../results/clientpositive/spark/mapjoin1.q.out |    24 +
 .../clientpositive/spark/mapjoin_decimal.q.out  |     6 +
 .../clientpositive/spark/mapjoin_distinct.q.out |    32 +
 .../spark/mapjoin_filter_on_outerjoin.q.out     |    12 +
 .../clientpositive/spark/mapjoin_mapjoin.q.out  |    46 +
 .../clientpositive/spark/mapjoin_memcheck.q.out |     4 +
 .../clientpositive/spark/mapjoin_subquery.q.out |    20 +
 .../spark/mapjoin_subquery2.q.out               |     8 +
 .../spark/mapjoin_test_outer.q.out              |    16 +
 .../clientpositive/spark/mapreduce1.q.out       |     4 +
 .../clientpositive/spark/mapreduce2.q.out       |     4 +
 .../results/clientpositive/spark/merge1.q.out   |    20 +
 .../results/clientpositive/spark/merge2.q.out   |    20 +
 .../clientpositive/spark/mergejoins.q.out       |    16 +
 .../clientpositive/spark/mergejoins_mixed.q.out |    48 +
 .../spark/metadata_only_queries.q.out           |    70 +
 .../metadata_only_queries_with_filters.q.out    |     8 +
 .../clientpositive/spark/multi_insert.q.out     |    88 +
 .../clientpositive/spark/multi_insert_gby.q.out |    12 +
 .../spark/multi_insert_gby2.q.out               |     6 +
 .../spark/multi_insert_gby3.q.out               |    26 +
 .../spark/multi_insert_lateral_view.q.out       |    38 +
 .../spark/multi_insert_mixed.q.out              |     8 +
 ...i_insert_move_tasks_share_dependencies.q.out |   136 +
 .../clientpositive/spark/multi_join_union.q.out |    10 +
 .../spark/multigroupby_singlemr.q.out           |    32 +
 .../clientpositive/spark/nullgroup.q.out        |    16 +
 .../clientpositive/spark/nullgroup2.q.out       |    16 +
 .../clientpositive/spark/nullgroup4.q.out       |    16 +
 .../spark/nullgroup4_multi_distinct.q.out       |     8 +
 .../spark/optimize_nullscan.q.out               |    64 +
 .../clientpositive/spark/orc_merge1.q.out       |     9 +
 .../clientpositive/spark/orc_merge2.q.out       |     3 +
 .../clientpositive/spark/orc_merge3.q.out       |     8 +
 .../clientpositive/spark/orc_merge4.q.out       |     8 +
 .../clientpositive/spark/orc_merge5.q.out       |    12 +
 .../clientpositive/spark/orc_merge6.q.out       |    12 +
 .../clientpositive/spark/orc_merge7.q.out       |    10 +
 .../spark/orc_merge_diff_fs.q.out               |     9 +
 .../spark/orc_merge_incompat1.q.out             |     4 +
 .../spark/orc_merge_incompat2.q.out             |     7 +
 .../results/clientpositive/spark/order.q.out    |     8 +
 .../clientpositive/spark/outer_join_ppr.q.out   |    20 +
 .../results/clientpositive/spark/parallel.q.out |     6 +
 .../clientpositive/spark/parallel_join0.q.out   |     7 +
 .../clientpositive/spark/parallel_join1.q.out   |     4 +
 .../clientpositive/spark/parallel_orderby.q.out |     6 +
 .../clientpositive/spark/parquet_join.q.out     |    18 +
 .../spark/parquet_vectorization_0.q.out         |    60 +
 .../spark/parquet_vectorization_1.q.out         |     4 +
 .../spark/parquet_vectorization_10.q.out        |     4 +
 .../spark/parquet_vectorization_11.q.out        |     4 +
 .../spark/parquet_vectorization_12.q.out        |     4 +
 .../spark/parquet_vectorization_13.q.out        |     8 +
 .../spark/parquet_vectorization_14.q.out        |     4 +
 .../spark/parquet_vectorization_15.q.out        |     4 +
 .../spark/parquet_vectorization_16.q.out        |     4 +
 .../spark/parquet_vectorization_17.q.out        |     4 +
 .../spark/parquet_vectorization_2.q.out         |     4 +
 .../spark/parquet_vectorization_3.q.out         |     4 +
 .../spark/parquet_vectorization_4.q.out         |     4 +
 .../spark/parquet_vectorization_5.q.out         |     4 +
 .../spark/parquet_vectorization_6.q.out         |     4 +
 .../spark/parquet_vectorization_7.q.out         |     8 +
 .../spark/parquet_vectorization_8.q.out         |     8 +
 .../spark/parquet_vectorization_9.q.out         |     4 +
 .../parquet_vectorization_decimal_date.q.out    |     4 +
 .../spark/parquet_vectorization_div0.q.out      |    12 +
 .../spark/parquet_vectorization_limit.q.out     |    28 +
 .../parquet_vectorization_offset_limit.q.out    |     8 +
 .../parquet_vectorization_part_project.q.out    |     8 +
 .../spark/parquet_vectorization_pushdown.q.out  |     4 +
 .../test/results/clientpositive/spark/pcr.q.out |   186 +
 .../clientpositive/spark/ppd_gby_join.q.out     |     8 +
 .../results/clientpositive/spark/ppd_join.q.out |     8 +
 .../clientpositive/spark/ppd_join2.q.out        |     8 +
 .../clientpositive/spark/ppd_join3.q.out        |     8 +
 .../clientpositive/spark/ppd_join4.q.out        |     4 +
 .../clientpositive/spark/ppd_join5.q.out        |    12 +
 .../clientpositive/spark/ppd_join_filter.q.out  |    16 +
 .../clientpositive/spark/ppd_multi_insert.q.out |    20 +
 .../clientpositive/spark/ppd_outer_join1.q.out  |     8 +
 .../clientpositive/spark/ppd_outer_join2.q.out  |     8 +
 .../clientpositive/spark/ppd_outer_join3.q.out  |     8 +
 .../clientpositive/spark/ppd_outer_join4.q.out  |     8 +
 .../clientpositive/spark/ppd_outer_join5.q.out  |    24 +
 .../clientpositive/spark/ppd_transform.q.out    |    18 +
 .../test/results/clientpositive/spark/ptf.q.out |    96 +
 .../clientpositive/spark/ptf_matchpath.q.out    |    12 +
 .../clientpositive/spark/ptf_streaming.q.out    |    48 +
 .../clientpositive/spark/quotedid_smb.q.out     |     6 +
 .../spark/reduce_deduplicate.q.out              |     8 +
 .../spark/reduce_deduplicate_exclude_join.q.out |     4 +
 .../clientpositive/spark/router_join_ppr.q.out  |    40 +
 .../spark/runtime_skewjoin_mapjoin_spark.q.out  |     6 +
 .../results/clientpositive/spark/sample1.q.out  |     6 +
 .../results/clientpositive/spark/sample10.q.out |    12 +
 .../results/clientpositive/spark/sample2.q.out  |     4 +
 .../results/clientpositive/spark/sample3.q.out  |     4 +
 .../results/clientpositive/spark/sample4.q.out  |     4 +
 .../results/clientpositive/spark/sample5.q.out  |     4 +
 .../results/clientpositive/spark/sample6.q.out  |    32 +
 .../results/clientpositive/spark/sample7.q.out  |     4 +
 .../results/clientpositive/spark/sample8.q.out  |    24 +
 .../results/clientpositive/spark/sample9.q.out  |     4 +
 .../clientpositive/spark/script_pipe.q.out      |     8 +
 .../results/clientpositive/spark/semijoin.q.out |   148 +
 .../results/clientpositive/spark/skewjoin.q.out |    46 +
 .../clientpositive/spark/skewjoin_noskew.q.out  |     6 +
 .../spark/skewjoin_union_remove_1.q.out         |    24 +
 .../spark/skewjoin_union_remove_2.q.out         |     8 +
 .../clientpositive/spark/skewjoinopt1.q.out     |    24 +
 .../clientpositive/spark/skewjoinopt10.q.out    |     6 +
 .../clientpositive/spark/skewjoinopt11.q.out    |     6 +
 .../clientpositive/spark/skewjoinopt12.q.out    |     6 +
 .../clientpositive/spark/skewjoinopt13.q.out    |     8 +
 .../clientpositive/spark/skewjoinopt14.q.out    |     8 +
 .../clientpositive/spark/skewjoinopt15.q.out    |    24 +
 .../clientpositive/spark/skewjoinopt16.q.out    |     6 +
 .../clientpositive/spark/skewjoinopt17.q.out    |    12 +
 .../clientpositive/spark/skewjoinopt18.q.out    |     6 +
 .../clientpositive/spark/skewjoinopt19.q.out    |     6 +
 .../clientpositive/spark/skewjoinopt2.q.out     |    24 +
 .../clientpositive/spark/skewjoinopt20.q.out    |     6 +
 .../clientpositive/spark/skewjoinopt3.q.out     |    12 +
 .../clientpositive/spark/skewjoinopt4.q.out     |    12 +
 .../clientpositive/spark/skewjoinopt5.q.out     |     6 +
 .../clientpositive/spark/skewjoinopt6.q.out     |     6 +
 .../clientpositive/spark/skewjoinopt7.q.out     |     8 +
 .../clientpositive/spark/skewjoinopt8.q.out     |     8 +
 .../clientpositive/spark/skewjoinopt9.q.out     |    12 +
 .../clientpositive/spark/smb_mapjoin_1.q.out    |    48 +
 .../clientpositive/spark/smb_mapjoin_10.q.out   |     8 +
 .../clientpositive/spark/smb_mapjoin_11.q.out   |    22 +
 .../clientpositive/spark/smb_mapjoin_12.q.out   |    24 +
 .../clientpositive/spark/smb_mapjoin_13.q.out   |    12 +
 .../clientpositive/spark/smb_mapjoin_14.q.out   |    70 +
 .../clientpositive/spark/smb_mapjoin_15.q.out   |    24 +
 .../clientpositive/spark/smb_mapjoin_16.q.out   |     6 +
 .../clientpositive/spark/smb_mapjoin_17.q.out   |    68 +
 .../clientpositive/spark/smb_mapjoin_18.q.out   |    18 +
 .../clientpositive/spark/smb_mapjoin_19.q.out   |     6 +
 .../clientpositive/spark/smb_mapjoin_2.q.out    |    48 +
 .../clientpositive/spark/smb_mapjoin_20.q.out   |    18 +
 .../clientpositive/spark/smb_mapjoin_21.q.out   |    36 +
 .../clientpositive/spark/smb_mapjoin_22.q.out   |     8 +
 .../clientpositive/spark/smb_mapjoin_25.q.out   |    16 +
 .../clientpositive/spark/smb_mapjoin_3.q.out    |    48 +
 .../clientpositive/spark/smb_mapjoin_4.q.out    |   104 +
 .../clientpositive/spark/smb_mapjoin_5.q.out    |   104 +
 .../clientpositive/spark/smb_mapjoin_6.q.out    |    30 +
 .../clientpositive/spark/smb_mapjoin_7.q.out    |     6 +
 .../results/clientpositive/spark/sort.q.out     |     4 +
 .../spark/spark_combine_equivalent_work_2.q.out |     8 +
 .../spark/spark_constprog_dpp.q.out             |     6 +
 .../spark/spark_dynamic_partition_pruning.q.out |   586 +
 .../spark_dynamic_partition_pruning_2.q.out     |    80 +
 .../spark_dynamic_partition_pruning_3.q.out     |   122 +
 .../spark_dynamic_partition_pruning_4.q.out     |   206 +
 .../spark_dynamic_partition_pruning_5.q.out     |    24 +
 .../spark_dynamic_partition_pruning_6.q.out     |    44 +
 .../spark_dynamic_partition_pruning_7.q.out     |    28 +
 ...dynamic_partition_pruning_mapjoin_only.q.out |    36 +
 ...ic_partition_pruning_recursive_mapjoin.q.out |   112 +
 .../spark/spark_explain_groupbyshuffle.q.out    |     8 +
 .../spark/spark_explainuser_1.q.out             |   756 +-
 .../spark/spark_in_process_launcher.q.out       |     4 +
 .../spark/spark_local_queries.q.out             |     4 +
 .../spark_multi_insert_parallel_orderby.q.out   |    22 +
 .../spark/spark_union_merge.q.out               |     8 +
 .../spark/spark_use_op_stats.q.out              |    10 +
 .../spark/spark_use_ts_stats_for_mapjoin.q.out  |    20 +
 ...k_vectorized_dynamic_partition_pruning.q.out |   572 +
 .../results/clientpositive/spark/stats0.q.out   |    16 +
 .../results/clientpositive/spark/stats1.q.out   |     6 +
 .../results/clientpositive/spark/stats10.q.out  |    16 +
 .../results/clientpositive/spark/stats12.q.out  |    12 +
 .../results/clientpositive/spark/stats13.q.out  |     8 +
 .../results/clientpositive/spark/stats2.q.out   |    31 +
 .../results/clientpositive/spark/stats3.q.out   |     4 +
 .../results/clientpositive/spark/stats5.q.out   |     4 +
 .../results/clientpositive/spark/stats7.q.out   |    12 +
 .../results/clientpositive/spark/stats8.q.out   |    52 +
 .../results/clientpositive/spark/stats9.q.out   |     4 +
 .../clientpositive/spark/stats_noscan_1.q.out   |    20 +
 .../clientpositive/spark/stats_noscan_2.q.out   |    10 +
 .../clientpositive/spark/stats_only_null.q.out  |    20 +
 .../clientpositive/spark/subquery_exists.q.out  |    28 +
 .../clientpositive/spark/subquery_in.q.out      |   156 +
 .../clientpositive/spark/subquery_multi.q.out   |    98 +
 .../spark/subquery_multiinsert.q.out            |    12 +
 .../clientpositive/spark/subquery_notin.q.out   |   130 +
 .../spark/subquery_null_agg.q.out               |     4 +
 .../clientpositive/spark/subquery_scalar.q.out  |   196 +
 .../clientpositive/spark/subquery_select.q.out  |   126 +
 .../clientpositive/spark/subquery_views.q.out   |     6 +
 .../clientpositive/spark/temp_table.q.out       |    22 +
 .../clientpositive/spark/temp_table_join1.q.out |    14 +
 .../clientpositive/spark/tez_join_tests.q.out   |     6 +
 .../spark/tez_joins_explain.q.out               |     6 +
 .../clientpositive/spark/transform1.q.out       |    12 +
 .../clientpositive/spark/transform_ppr1.q.out   |    14 +
 .../clientpositive/spark/transform_ppr2.q.out   |    10 +
 .../clientpositive/spark/udf_example_add.q.out  |     4 +
 .../clientpositive/spark/udf_in_file.q.out      |     4 +
 .../results/clientpositive/spark/union.q.out    |     4 +
 .../results/clientpositive/spark/union10.q.out  |     4 +
 .../results/clientpositive/spark/union11.q.out  |     4 +
 .../results/clientpositive/spark/union12.q.out  |     8 +
 .../results/clientpositive/spark/union13.q.out  |     4 +
 .../results/clientpositive/spark/union14.q.out  |     6 +
 .../results/clientpositive/spark/union15.q.out  |     6 +
 .../results/clientpositive/spark/union16.q.out  |     4 +
 .../results/clientpositive/spark/union17.q.out  |     6 +
 .../results/clientpositive/spark/union18.q.out  |     6 +
 .../results/clientpositive/spark/union19.q.out  |     6 +
 .../results/clientpositive/spark/union2.q.out   |     4 +
 .../results/clientpositive/spark/union20.q.out  |     4 +
 .../results/clientpositive/spark/union21.q.out  |     6 +
 .../results/clientpositive/spark/union22.q.out  |    10 +
 .../results/clientpositive/spark/union23.q.out  |     4 +
 .../results/clientpositive/spark/union24.q.out  |    30 +
 .../results/clientpositive/spark/union25.q.out  |    12 +
 .../results/clientpositive/spark/union26.q.out  |     8 +
 .../results/clientpositive/spark/union27.q.out  |     8 +
 .../results/clientpositive/spark/union28.q.out  |     4 +
 .../results/clientpositive/spark/union29.q.out  |     4 +
 .../results/clientpositive/spark/union3.q.out   |     4 +
 .../results/clientpositive/spark/union30.q.out  |     4 +
 .../results/clientpositive/spark/union31.q.out  |    24 +
 .../results/clientpositive/spark/union32.q.out  |    30 +
 .../results/clientpositive/spark/union33.q.out  |     8 +
 .../results/clientpositive/spark/union34.q.out  |    20 +
 .../results/clientpositive/spark/union4.q.out   |     4 +
 .../results/clientpositive/spark/union5.q.out   |     4 +
 .../results/clientpositive/spark/union6.q.out   |     6 +
 .../results/clientpositive/spark/union7.q.out   |     6 +
 .../results/clientpositive/spark/union8.q.out   |     4 +
 .../results/clientpositive/spark/union9.q.out   |     4 +
 .../spark/union_lateralview.q.out               |     8 +
 .../clientpositive/spark/union_ppr.q.out        |     8 +
 .../clientpositive/spark/union_remove_1.q.out   |     4 +
 .../clientpositive/spark/union_remove_10.q.out  |     4 +
 .../clientpositive/spark/union_remove_11.q.out  |     4 +
 .../clientpositive/spark/union_remove_12.q.out  |     4 +
 .../clientpositive/spark/union_remove_13.q.out  |     4 +
 .../clientpositive/spark/union_remove_14.q.out  |     4 +
 .../clientpositive/spark/union_remove_15.q.out  |     3 +
 .../clientpositive/spark/union_remove_16.q.out  |     3 +
 .../clientpositive/spark/union_remove_17.q.out  |     3 +
 .../clientpositive/spark/union_remove_18.q.out  |     3 +
 .../clientpositive/spark/union_remove_19.q.out  |    12 +
 .../clientpositive/spark/union_remove_2.q.out   |     4 +
 .../clientpositive/spark/union_remove_20.q.out  |     4 +
 .../clientpositive/spark/union_remove_21.q.out  |     4 +
 .../clientpositive/spark/union_remove_22.q.out  |     8 +
 .../clientpositive/spark/union_remove_23.q.out  |     4 +
 .../clientpositive/spark/union_remove_24.q.out  |     4 +
 .../clientpositive/spark/union_remove_25.q.out  |    18 +
 .../clientpositive/spark/union_remove_3.q.out   |     4 +
 .../clientpositive/spark/union_remove_4.q.out   |     4 +
 .../clientpositive/spark/union_remove_5.q.out   |     4 +
 .../clientpositive/spark/union_remove_6.q.out   |     6 +
 .../spark/union_remove_6_subq.q.out             |    14 +
 .../clientpositive/spark/union_remove_7.q.out   |     4 +
 .../clientpositive/spark/union_remove_8.q.out   |     4 +
 .../clientpositive/spark/union_remove_9.q.out   |     4 +
 .../clientpositive/spark/union_top_level.q.out  |    28 +
 .../spark/vector_between_in.q.out               |    48 +
 .../spark/vector_cast_constant.q.out            |     4 +
 .../clientpositive/spark/vector_char_4.q.out    |     4 +
 .../spark/vector_count_distinct.q.out           |    64 +
 .../spark/vector_data_types.q.out               |    12 +
 .../spark/vector_decimal_aggregate.q.out        |    16 +
 .../spark/vector_decimal_mapjoin.q.out          |    36 +
 .../spark/vector_distinct_2.q.out               |     4 +
 .../clientpositive/spark/vector_elt.q.out       |     8 +
 .../clientpositive/spark/vector_groupby_3.q.out |     4 +
 .../spark/vector_inner_join.q.out               |    54 +
 .../spark/vector_left_outer_join.q.out          |     4 +
 .../spark/vector_mapjoin_reduce.q.out           |     8 +
 .../clientpositive/spark/vector_orderby_5.q.out |     4 +
 .../spark/vector_outer_join0.q.out              |    12 +
 .../spark/vector_outer_join1.q.out              |    12 +
 .../spark/vector_outer_join2.q.out              |     4 +
 .../spark/vector_outer_join3.q.out              |    12 +
 .../spark/vector_outer_join4.q.out              |    12 +
 .../spark/vector_outer_join5.q.out              |    60 +
 .../spark/vector_string_concat.q.out            |     8 +
 .../clientpositive/spark/vector_varchar_4.q.out |     4 +
 .../clientpositive/spark/vectorization_0.q.out  |    60 +
 .../clientpositive/spark/vectorization_1.q.out  |     4 +
 .../clientpositive/spark/vectorization_10.q.out |     4 +
 .../clientpositive/spark/vectorization_11.q.out |     4 +
 .../clientpositive/spark/vectorization_12.q.out |     4 +
 .../clientpositive/spark/vectorization_13.q.out |     8 +
 .../clientpositive/spark/vectorization_14.q.out |     4 +
 .../clientpositive/spark/vectorization_15.q.out |     4 +
 .../clientpositive/spark/vectorization_16.q.out |     4 +
 .../clientpositive/spark/vectorization_17.q.out |     4 +
 .../clientpositive/spark/vectorization_2.q.out  |     4 +
 .../clientpositive/spark/vectorization_3.q.out  |     4 +
 .../clientpositive/spark/vectorization_4.q.out  |     4 +
 .../clientpositive/spark/vectorization_5.q.out  |     4 +
 .../clientpositive/spark/vectorization_6.q.out  |     4 +
 .../clientpositive/spark/vectorization_9.q.out  |     4 +
 .../spark/vectorization_decimal_date.q.out      |     4 +
 .../spark/vectorization_div0.q.out              |    16 +
 .../vectorization_input_format_excludes.q.out   |    40 +
 .../spark/vectorization_nested_udf.q.out        |     4 +
 .../vectorization_parquet_projection.q.out      |    26 +
 .../spark/vectorization_part_project.q.out      |     8 +
 .../spark/vectorization_pushdown.q.out          |     4 +
 .../spark/vectorization_short_regress.q.out     |    80 +
 .../clientpositive/spark/vectorized_case.q.out  |    52 +-
 .../spark/vectorized_mapjoin.q.out              |     4 +
 .../spark/vectorized_math_funcs.q.out           |     4 +
 .../spark/vectorized_nested_mapjoin.q.out       |     4 +
 .../clientpositive/spark/vectorized_ptf.q.out   |    96 +
 .../spark/vectorized_shufflejoin.q.out          |     4 +
 .../spark/vectorized_string_funcs.q.out         |     4 +
 .../spark/vectorized_timestamp_funcs.q.out      |    28 +
 .../clientpositive/spark/windowing.q.out        |     4 +
 .../special_character_in_tabnames_2.q.out       |     4 +
 .../clientpositive/stat_estimate_drill.q.out    |    28 +
 .../stat_estimate_related_col.q.out             |    40 +
 ql/src/test/results/clientpositive/stats0.q.out |    16 +
 ql/src/test/results/clientpositive/stats1.q.out |     6 +
 .../test/results/clientpositive/stats10.q.out   |    16 +
 .../test/results/clientpositive/stats12.q.out   |    12 +
 .../test/results/clientpositive/stats13.q.out   |     8 +
 ql/src/test/results/clientpositive/stats2.q.out |    31 +
 ql/src/test/results/clientpositive/stats3.q.out |     4 +
 ql/src/test/results/clientpositive/stats4.q.out |    12 +
 ql/src/test/results/clientpositive/stats5.q.out |     4 +
 ql/src/test/results/clientpositive/stats7.q.out |    12 +
 ql/src/test/results/clientpositive/stats8.q.out |    52 +
 ql/src/test/results/clientpositive/stats9.q.out |     4 +
 .../clientpositive/stats_empty_dyn_part.q.out   |     3 +
 .../clientpositive/stats_empty_partition2.q.out |    10 +
 .../results/clientpositive/stats_nonpart.q.out  |    24 +
 .../results/clientpositive/stats_noscan_1.q.out |    20 +
 .../results/clientpositive/stats_noscan_2.q.out |    10 +
 .../clientpositive/stats_null_optimizer.q.out   |     4 +
 .../clientpositive/stats_only_null.q.out        |    20 +
 .../results/clientpositive/stats_part.q.out     |    48 +
 .../results/clientpositive/stats_part2.q.out    |    70 +
 .../clientpositive/stats_partial_size.q.out     |     8 +
 .../results/clientpositive/stats_ppr_all.q.out  |    32 +
 .../results/clientpositive/stats_sizebug.q.out  |     4 +
 .../results/clientpositive/statsoptimizer.q.out |     4 +
 .../results/clientpositive/str_to_map.q.out     |    16 +
 .../test/results/clientpositive/structin.q.out  |     8 +
 ql/src/test/results/clientpositive/subq.q.out   |     4 +
 ql/src/test/results/clientpositive/subq2.q.out  |     4 +
 .../subq_where_serialization.q.out              |     4 +
 .../results/clientpositive/subquery_alias.q.out |     8 +
 .../clientpositive/subquery_exists.q.out        |    28 +
 .../clientpositive/subquery_exists_having.q.out |     8 +
 .../clientpositive/subquery_multiinsert.q.out   |    12 +
 .../clientpositive/subquery_notexists.q.out     |    16 +
 .../subquery_notexists_having.q.out             |     8 +
 .../clientpositive/subquery_notin_having.q.out  |    24 +
 .../subquery_unqual_corr_expr.q.out             |     8 +
 .../subquery_unqualcolumnrefs.q.out             |    18 +
 .../symlink_text_input_format.q.out             |    28 +
 .../results/clientpositive/tablevalues.q.out    |    48 +
 .../temp_table_display_colstats_tbllvl.q.out    |    18 +
 .../clientpositive/temp_table_join1.q.out       |    14 +
 .../clientpositive/temp_table_truncate.q.out    |     4 +
 .../test_teradatabinaryfile.q.out               |     2 +-
 .../tez/acid_vectorization_original_tez.q.out   |    16 +
 .../clientpositive/tez/explainanalyze_1.q.out   |    56 +
 .../clientpositive/tez/explainanalyze_3.q.out   |    88 +
 .../clientpositive/tez/explainanalyze_4.q.out   |    24 +
 .../clientpositive/tez/explainanalyze_5.q.out   |    24 +
 .../clientpositive/tez/explainuser_3.q.out      |    92 +
 .../tez/hybridgrace_hashjoin_1.q.out            |    64 +
 .../tez/hybridgrace_hashjoin_2.q.out            |   128 +
 .../tez/multi_count_distinct.q.out              |     8 +
 .../results/clientpositive/tez/tez-tag.q.out    |    18 +
 .../results/clientpositive/tez/topnkey.q.out    |    12 +
 .../tez/vector_join_part_col_char.q.out         |    14 +
 .../tez/vector_non_string_partition.q.out       |    12 +
 .../clientpositive/tez/vector_topnkey.q.out     |    12 +
 .../test/results/clientpositive/timestamp.q.out |     8 +
 .../clientpositive/timestamp_ints_casts.q.out   |     8 +
 .../clientpositive/timestamp_literal.q.out      |    12 +
 .../results/clientpositive/timestamptz.q.out    |    16 +
 .../test/results/clientpositive/topnkey.q.out   |    12 +
 .../results/clientpositive/transform1.q.out     |    12 +
 .../results/clientpositive/transform_ppr1.q.out |    14 +
 .../results/clientpositive/transform_ppr2.q.out |    10 +
 .../truncate_column_list_bucket.q.out           |    12 +
 .../results/clientpositive/truncate_table.q.out |    16 +
 .../clientpositive/tumbled_window_tests.q.out   |   135 +
 .../results/clientpositive/type_cast_1.q.out    |     4 +
 .../results/clientpositive/type_widening.q.out  |    24 +
 .../udaf_binarysetfunctions.q.out               |     4 +
 .../udaf_binarysetfunctions_no_cbo.q.out        |     4 +
 .../clientpositive/udaf_number_format.q.out     |     4 +
 .../udaf_percentile_approx_23.q.out             |     8 +
 ql/src/test/results/clientpositive/udf1.q.out   |     4 +
 ql/src/test/results/clientpositive/udf2.q.out   |     4 +
 ql/src/test/results/clientpositive/udf3.q.out   |     4 +
 ql/src/test/results/clientpositive/udf4.q.out   |     4 +
 ql/src/test/results/clientpositive/udf5.q.out   |     8 +
 ql/src/test/results/clientpositive/udf6.q.out   |     8 +
 ql/src/test/results/clientpositive/udf7.q.out   |     4 +
 ql/src/test/results/clientpositive/udf8.q.out   |     4 +
 ql/src/test/results/clientpositive/udf9.q.out   |     4 +
 .../results/clientpositive/udf_10_trims.q.out   |     4 +
 ql/src/test/results/clientpositive/udf_E.q.out  |     8 +
 ql/src/test/results/clientpositive/udf_PI.q.out |     8 +
 .../test/results/clientpositive/udf_abs.q.out   |     8 +
 .../results/clientpositive/udf_add_months.q.out |     4 +
 .../clientpositive/udf_aes_decrypt.q.out        |     4 +
 .../clientpositive/udf_aes_encrypt.q.out        |     4 +
 .../test/results/clientpositive/udf_array.q.out |     4 +
 .../test/results/clientpositive/udf_ascii.q.out |     4 +
 .../results/clientpositive/udf_between.q.out    |    16 +
 .../clientpositive/udf_bitwise_shiftleft.q.out  |     4 +
 .../clientpositive/udf_bitwise_shiftright.q.out |     4 +
 .../udf_bitwise_shiftrightunsigned.q.out        |     4 +
 .../test/results/clientpositive/udf_case.q.out  |     4 +
 .../udf_case_column_pruning.q.out               |     4 +
 .../clientpositive/udf_case_thrift.q.out        |     4 +
 .../test/results/clientpositive/udf_cbrt.q.out  |     4 +
 .../clientpositive/udf_character_length.q.out   |    12 +
 .../udf_compare_java_string.q.out               |     2 +
 .../results/clientpositive/udf_concat_ws.q.out  |     8 +
 .../test/results/clientpositive/udf_count.q.out |    20 +
 .../test/results/clientpositive/udf_crc32.q.out |     4 +
 .../clientpositive/udf_current_database.q.out   |    16 +
 .../clientpositive/udf_date_format.q.out        |     4 +
 .../results/clientpositive/udf_decode.q.out     |     4 +
 .../results/clientpositive/udf_degrees.q.out    |     8 +
 .../test/results/clientpositive/udf_elt.q.out   |     4 +
 .../clientpositive/udf_example_add.q.out        |     4 +
 .../results/clientpositive/udf_explode.q.out    |    16 +
 .../results/clientpositive/udf_factorial.q.out  |     4 +
 .../clientpositive/udf_find_in_set.q.out        |     4 +
 .../clientpositive/udf_folder_constants.q.out   |     6 +
 .../clientpositive/udf_format_number.q.out      |     4 +
 .../clientpositive/udf_from_utc_timestamp.q.out |     4 +
 .../clientpositive/udf_get_json_object.q.out    |     4 +
 .../results/clientpositive/udf_greatest.q.out   |     4 +
 .../test/results/clientpositive/udf_hash.q.out  |     4 +
 .../test/results/clientpositive/udf_hour.q.out  |     4 +
 ql/src/test/results/clientpositive/udf_if.q.out |     8 +
 .../results/clientpositive/udf_in_file.q.out    |     4 +
 .../results/clientpositive/udf_inline.q.out     |     4 +
 .../test/results/clientpositive/udf_instr.q.out |     4 +
 .../clientpositive/udf_isnull_isnotnull.q.out   |     8 +
 .../clientpositive/udf_isops_simplify.q.out     |   356 +
 .../clientpositive/udf_java_method.q.out        |     4 +
 .../results/clientpositive/udf_last_day.q.out   |     4 +
 .../test/results/clientpositive/udf_least.q.out |     4 +
 .../results/clientpositive/udf_length.q.out     |     8 +
 .../clientpositive/udf_levenshtein.q.out        |     4 +
 .../test/results/clientpositive/udf_like.q.out  |     4 +
 .../results/clientpositive/udf_locate.q.out     |     4 +
 .../clientpositive/udf_logic_java_boolean.q.out |     2 +
 .../test/results/clientpositive/udf_lower.q.out |     4 +
 .../test/results/clientpositive/udf_lpad.q.out  |     4 +
 .../test/results/clientpositive/udf_map.q.out   |     4 +
 .../test/results/clientpositive/udf_mask.q.out  |     4 +
 .../clientpositive/udf_mask_first_n.q.out       |     4 +
 .../results/clientpositive/udf_mask_hash.q.out  |     4 +
 .../clientpositive/udf_mask_last_n.q.out        |     4 +
 .../clientpositive/udf_mask_show_first_n.q.out  |     4 +
 .../clientpositive/udf_mask_show_last_n.q.out   |     4 +
 .../test/results/clientpositive/udf_md5.q.out   |     4 +
 .../results/clientpositive/udf_minute.q.out     |     4 +
 .../clientpositive/udf_months_between.q.out     |     4 +
 .../clientpositive/udf_named_struct.q.out       |     4 +
 .../results/clientpositive/udf_next_day.q.out   |     4 +
 .../results/clientpositive/udf_notequal.q.out   |     8 +
 .../results/clientpositive/udf_nullif.q.out     |    12 +
 .../test/results/clientpositive/udf_nvl.q.out   |     4 +
 .../clientpositive/udf_octet_length.q.out       |     8 +
 .../results/clientpositive/udf_parse_url.q.out  |     4 +
 .../results/clientpositive/udf_printf.q.out     |     4 +
 .../results/clientpositive/udf_quarter.q.out    |     4 +
 .../results/clientpositive/udf_radians.q.out    |     8 +
 .../results/clientpositive/udf_reflect.q.out    |     4 +
 .../results/clientpositive/udf_reflect2.q.out   |     4 +
 .../results/clientpositive/udf_repeat.q.out     |     4 +
 .../results/clientpositive/udf_reverse.q.out    |     4 +
 .../test/results/clientpositive/udf_rpad.q.out  |     4 +
 .../results/clientpositive/udf_second.q.out     |     4 +
 .../test/results/clientpositive/udf_sha1.q.out  |     4 +
 .../test/results/clientpositive/udf_sha2.q.out  |     4 +
 .../test/results/clientpositive/udf_sign.q.out  |     8 +
 .../test/results/clientpositive/udf_size.q.out  |     4 +
 .../results/clientpositive/udf_sort_array.q.out |     4 +
 .../results/clientpositive/udf_soundex.q.out    |     4 +
 .../test/results/clientpositive/udf_space.q.out |     4 +
 .../test/results/clientpositive/udf_split.q.out |     4 +
 .../results/clientpositive/udf_struct.q.out     |     4 +
 .../clientpositive/udf_substring_index.q.out    |     4 +
 .../results/clientpositive/udf_testlength.q.out |     2 +
 .../clientpositive/udf_testlength2.q.out        |     2 +
 .../results/clientpositive/udf_to_string.q.out  |    18 +
 .../clientpositive/udf_to_unix_timestamp.q.out  |     8 +
 .../clientpositive/udf_to_utc_timestamp.q.out   |     4 +
 .../test/results/clientpositive/udf_trunc.q.out |    48 +
 .../clientpositive/udf_trunc_number.q.out       |    24 +
 .../test/results/clientpositive/udf_union.q.out |     4 +
 .../test/results/clientpositive/udf_when.q.out  |     4 +
 .../clientpositive/udf_width_bucket.q.out       |     4 +
 .../results/clientpositive/udtf_explode.q.out   |    16 +
 .../clientpositive/udtf_json_tuple.q.out        |    16 +
 .../clientpositive/udtf_parse_url_tuple.q.out   |    16 +
 .../results/clientpositive/udtf_stack.q.out     |    12 +
 .../results/clientpositive/unicode_data.q.out   |     6 +
 ql/src/test/results/clientpositive/union.q.out  |     4 +
 .../test/results/clientpositive/union10.q.out   |     4 +
 .../test/results/clientpositive/union11.q.out   |     4 +
 .../test/results/clientpositive/union12.q.out   |     8 +
 .../test/results/clientpositive/union13.q.out   |     4 +
 .../test/results/clientpositive/union14.q.out   |     6 +
 .../test/results/clientpositive/union15.q.out   |     6 +
 .../test/results/clientpositive/union16.q.out   |     4 +
 .../test/results/clientpositive/union17.q.out   |     6 +
 .../test/results/clientpositive/union18.q.out   |     6 +
 .../test/results/clientpositive/union19.q.out   |     6 +
 ql/src/test/results/clientpositive/union2.q.out |     4 +
 .../test/results/clientpositive/union20.q.out   |     4 +
 .../test/results/clientpositive/union21.q.out   |     6 +
 .../test/results/clientpositive/union22.q.out   |    10 +
 .../test/results/clientpositive/union23.q.out   |     4 +
 .../test/results/clientpositive/union24.q.out   |    30 +
 .../test/results/clientpositive/union25.q.out   |    12 +
 .../test/results/clientpositive/union26.q.out   |     8 +
 .../test/results/clientpositive/union27.q.out   |     8 +
 .../test/results/clientpositive/union28.q.out   |     4 +
 .../test/results/clientpositive/union29.q.out   |     4 +
 ql/src/test/results/clientpositive/union3.q.out |     4 +
 .../test/results/clientpositive/union30.q.out   |     4 +
 .../test/results/clientpositive/union31.q.out   |    24 +
 .../test/results/clientpositive/union32.q.out   |    30 +
 .../test/results/clientpositive/union33.q.out   |     8 +
 .../test/results/clientpositive/union34.q.out   |    20 +
 .../test/results/clientpositive/union37.q.out   |    24 +
 ql/src/test/results/clientpositive/union4.q.out |     4 +
 ql/src/test/results/clientpositive/union5.q.out |     4 +
 ql/src/test/results/clientpositive/union6.q.out |     6 +
 ql/src/test/results/clientpositive/union7.q.out |     6 +
 ql/src/test/results/clientpositive/union8.q.out |     4 +
 ql/src/test/results/clientpositive/union9.q.out |     4 +
 .../clientpositive/union_lateralview.q.out      |     8 +
 .../results/clientpositive/union_offcbo.q.out   |    30 +
 .../results/clientpositive/union_paren.q.out    |     4 +
 .../clientpositive/union_pos_alias.q.out        |    16 +
 .../test/results/clientpositive/union_ppr.q.out |     8 +
 .../results/clientpositive/union_remove_1.q.out |     4 +
 .../clientpositive/union_remove_10.q.out        |     4 +
 .../clientpositive/union_remove_11.q.out        |     4 +
 .../clientpositive/union_remove_12.q.out        |     4 +
 .../clientpositive/union_remove_13.q.out        |     4 +
 .../clientpositive/union_remove_14.q.out        |     4 +
 .../clientpositive/union_remove_15.q.out        |     3 +
 .../clientpositive/union_remove_16.q.out        |     3 +
 .../clientpositive/union_remove_17.q.out        |     3 +
 .../clientpositive/union_remove_18.q.out        |     3 +
 .../clientpositive/union_remove_19.q.out        |    12 +
 .../results/clientpositive/union_remove_2.q.out |     4 +
 .../clientpositive/union_remove_20.q.out        |     4 +
 .../clientpositive/union_remove_21.q.out        |     4 +
 .../clientpositive/union_remove_22.q.out        |     8 +
 .../clientpositive/union_remove_23.q.out        |     4 +
 .../clientpositive/union_remove_24.q.out        |     4 +
 .../clientpositive/union_remove_25.q.out        |    18 +
 .../results/clientpositive/union_remove_3.q.out |     4 +
 .../results/clientpositive/union_remove_4.q.out |     4 +
 .../results/clientpositive/union_remove_5.q.out |     4 +
 .../results/clientpositive/union_remove_6.q.out |     6 +
 .../clientpositive/union_remove_6_subq.q.out    |    14 +
 .../results/clientpositive/union_remove_7.q.out |     4 +
 .../results/clientpositive/union_remove_8.q.out |     4 +
 .../results/clientpositive/union_remove_9.q.out |     4 +
 .../clientpositive/union_remove_plan.q.out      |     4 +
 .../clientpositive/unionall_unbalancedppd.q.out |    12 +
 .../clientpositive/updateBasicStats.q.out       |    70 +
 .../clientpositive/vector_aggregate_9.q.out     |    12 +
 .../vector_aggregate_without_gby.q.out          |     4 +
 .../clientpositive/vector_between_columns.q.out |    12 +
 .../vector_binary_join_groupby.q.out            |    12 +
 .../results/clientpositive/vector_bround.q.out  |     4 +
 .../results/clientpositive/vector_bucket.q.out  |     4 +
 .../clientpositive/vector_case_when_1.q.out     |    47 +-
 .../clientpositive/vector_case_when_2.q.out     |    51 +-
 .../clientpositive/vector_cast_constant.q.out   |     4 +
 .../results/clientpositive/vector_char_2.q.out  |     8 +
 .../results/clientpositive/vector_char_4.q.out  |     4 +
 .../clientpositive/vector_char_mapjoin1.q.out   |    16 +
 .../clientpositive/vector_char_simple.q.out     |    12 +
 .../clientpositive/vector_coalesce.q.out        |    40 +-
 .../clientpositive/vector_coalesce_2.q.out      |    44 +-
 .../clientpositive/vector_coalesce_3.q.out      |    12 +-
 .../clientpositive/vector_coalesce_4.q.out      |    12 +-
 .../results/clientpositive/vector_const.q.out   |     4 +
 .../results/clientpositive/vector_count.q.out   |    16 +
 .../vector_custom_udf_configure.q.out           |     4 +
 .../clientpositive/vector_data_types.q.out      |    12 +
 .../results/clientpositive/vector_date_1.q.out  |    28 +
 .../clientpositive/vector_decimal_1.q.out       |    36 +
 .../clientpositive/vector_decimal_10_0.q.out    |     8 +
 .../clientpositive/vector_decimal_5.q.out       |     4 +
 .../clientpositive/vector_decimal_6.q.out       |    20 +
 .../vector_decimal_aggregate.q.out              |    16 +
 .../clientpositive/vector_decimal_cast.q.out    |     8 +
 .../vector_decimal_expressions.q.out            |    10 +-
 .../clientpositive/vector_decimal_mapjoin.q.out |    36 +
 .../vector_decimal_math_funcs.q.out             |     8 +
 .../vector_decimal_precision.q.out              |     8 +
 .../clientpositive/vector_decimal_round.q.out   |    24 +
 .../clientpositive/vector_decimal_round_2.q.out |    16 +
 .../vector_decimal_trailing.q.out               |     4 +
 .../clientpositive/vector_decimal_udf2.q.out    |    16 +
 .../vector_delete_orig_table.q.out              |     4 +
 .../clientpositive/vector_distinct_2.q.out      |     4 +
 .../results/clientpositive/vector_elt.q.out     |     8 +
 .../clientpositive/vector_empty_where.q.out     |    16 +
 .../clientpositive/vector_gather_stats.q.out    |     8 +
 .../clientpositive/vector_groupby4.q.out        |     4 +
 .../clientpositive/vector_groupby6.q.out        |     4 +
 .../clientpositive/vector_groupby_3.q.out       |     4 +
 .../clientpositive/vector_groupby_mapjoin.q.out |     4 +
 .../clientpositive/vector_groupby_reduce.q.out  |    16 +
 .../clientpositive/vector_grouping_sets.q.out   |    12 +
 .../results/clientpositive/vector_if_expr.q.out |     4 +
 .../clientpositive/vector_include_no_sel.q.out  |     6 +
 .../clientpositive/vector_interval_1.q.out      |    32 +
 .../vector_interval_arithmetic.q.out            |    32 +
 .../vector_interval_mapjoin.q.out               |     6 +
 .../vector_join_part_col_char.q.out             |    14 +
 .../clientpositive/vector_left_outer_join.q.out |     4 +
 .../vector_left_outer_join2.q.out               |    36 +
 .../clientpositive/vector_map_order.q.out       |     4 +
 .../vector_mr_diff_schema_alias.q.out           |     8 +
 .../clientpositive/vector_multi_insert.q.out    |     8 +
 .../vector_non_constant_in_expr.q.out           |     4 +
 .../vector_non_string_partition.q.out           |    12 +
 .../clientpositive/vector_null_projection.q.out |    10 +
 .../results/clientpositive/vector_nvl.q.out     |    16 +
 .../clientpositive/vector_orderby_5.q.out       |     4 +
 .../clientpositive/vector_outer_join0.q.out     |    12 +
 .../clientpositive/vector_outer_join1.q.out     |    12 +
 .../clientpositive/vector_outer_join2.q.out     |     4 +
 .../clientpositive/vector_outer_join3.q.out     |    12 +
 .../clientpositive/vector_outer_join4.q.out     |    12 +
 .../clientpositive/vector_outer_join6.q.out     |    16 +
 .../vector_outer_join_no_keys.q.out             |    12 +
 .../results/clientpositive/vector_reduce1.q.out |     4 +
 .../results/clientpositive/vector_reduce2.q.out |     4 +
 .../results/clientpositive/vector_reduce3.q.out |     4 +
 .../vector_reduce_groupby_decimal.q.out         |     4 +
 .../vector_reduce_groupby_duplicate_cols.q.out  |     6 +
 .../clientpositive/vector_string_concat.q.out   |     8 +
 .../clientpositive/vector_struct_in.q.out       |    32 +
 .../vector_tablesample_rows.q.out               |    18 +
 .../results/clientpositive/vector_topnkey.q.out |    12 +
 .../results/clientpositive/vector_udf3.q.out    |     4 +
 .../vector_udf_character_length.q.out           |    12 +
 .../vector_udf_octet_length.q.out               |     8 +
 .../clientpositive/vector_varchar_4.q.out       |     4 +
 .../vector_varchar_mapjoin1.q.out               |    16 +
 .../clientpositive/vector_varchar_simple.q.out  |    12 +
 .../clientpositive/vector_when_case_null.q.out  |     4 +
 .../clientpositive/vectorization_1.q.out        |     4 +
 .../clientpositive/vectorization_10.q.out       |     4 +
 .../clientpositive/vectorization_11.q.out       |     4 +
 .../clientpositive/vectorization_12.q.out       |     4 +
 .../clientpositive/vectorization_13.q.out       |     8 +
 .../clientpositive/vectorization_14.q.out       |     4 +
 .../clientpositive/vectorization_15.q.out       |     4 +
 .../clientpositive/vectorization_16.q.out       |     4 +
 .../clientpositive/vectorization_17.q.out       |     4 +
 .../clientpositive/vectorization_2.q.out        |     4 +
 .../clientpositive/vectorization_3.q.out        |     4 +
 .../clientpositive/vectorization_4.q.out        |     4 +
 .../clientpositive/vectorization_5.q.out        |     4 +
 .../clientpositive/vectorization_6.q.out        |     4 +
 .../clientpositive/vectorization_7.q.out        |     8 +
 .../clientpositive/vectorization_8.q.out        |     8 +
 .../clientpositive/vectorization_9.q.out        |     4 +
 .../vectorization_decimal_date.q.out            |     4 +
 .../clientpositive/vectorization_limit.q.out    |    28 +
 .../vectorization_nested_udf.q.out              |     4 +
 .../vectorization_numeric_overflows.q.out       |    40 +
 .../vectorization_offset_limit.q.out            |     8 +
 .../vectorization_parquet_projection.q.out      |    26 +
 .../vectorization_part_project.q.out            |     8 +
 .../clientpositive/vectorization_pushdown.q.out |     4 +
 .../vectorized_bucketmapjoin1.q.out             |    18 +
 .../clientpositive/vectorized_case.q.out        |    52 +-
 .../clientpositive/vectorized_casts.q.out       |     4 +
 .../clientpositive/vectorized_context.q.out     |     8 +
 .../clientpositive/vectorized_date_funcs.q.out  |    20 +
 .../vectorized_distinct_gby.q.out               |     8 +
 .../clientpositive/vectorized_join46_mr.q.out   |   102 +
 .../clientpositive/vectorized_mapjoin.q.out     |     4 +
 .../clientpositive/vectorized_mapjoin2.q.out    |     6 +
 .../clientpositive/vectorized_mapjoin3.q.out    |    18 +
 .../clientpositive/vectorized_math_funcs.q.out  |     4 +
 .../vectorized_parquet_types.q.out              |    24 +
 .../clientpositive/vectorized_shufflejoin.q.out |     4 +
 .../vectorized_string_funcs.q.out               |     4 +
 .../clientpositive/vectorized_timestamp.q.out   |    20 +
 .../vectorized_timestamp_funcs.q.out            |    28 +
 .../vectorized_timestamp_ints_casts.q.out       |     8 +
 .../view_authorization_sqlstd.q.out             |     6 +
 .../test/results/clientpositive/view_cbo.q.out  |    10 +
 .../results/clientpositive/windowing_gby2.q.out |    18 +
 .../clientpositive/windowing_navfn.q.out        |     4 +
 .../clientpositive/windowing_streaming.q.out    |    12 +
 serde/pom.xml                                   |    20 +
 .../hadoop/hive/serde2/MultiDelimitSerDe.java   |   308 +
 .../PrimitiveObjectInspectorUtils.java          |     4 +
 service-rpc/pom.xml                             |    60 +-
 .../service/rpc/thrift/TOpenSessionReq.java     |     7 +-
 .../org/apache/hive/tmpl/QueryProfileTmpl.jamon |    91 +-
 .../apache/hive/service/auth/HttpAuthUtils.java |    24 +-
 .../cli/operation/GetTablesOperation.java       |     3 +-
 .../hive/service/cli/operation/Operation.java   |     4 +
 .../service/cli/operation/OperationManager.java |    29 +-
 .../service/cli/operation/SQLOperation.java     |    16 +-
 .../service/cli/session/HiveSessionImpl.java    |     1 +
 .../hive/service/server/KillQueryImpl.java      |   123 +-
 .../hive-webapps/hiveserver2/hiveserver2.jsp    |     1 +
 .../hive-webapps/hiveserver2/llap.html          |     1 +
 .../hive-webapps/hiveserver2/logconf.jsp        |   140 +
 .../static/css/query-plan-graph.css             |    22 +
 .../resources/hive-webapps/static/js/logconf.js |    40 +
 .../hive-webapps/static/js/query-plan-graph.js  |   533 +
 .../resources/hive-webapps/static/js/vis.min.js |    63 +
 .../apache/hadoop/hive/shims/Hadoop23Shims.java |    17 +-
 .../apache/hadoop/hive/shims/HadoopShims.java   |    16 +
 .../hive/spark/client/SparkClientUtilities.java |     7 +-
 .../spark/client/SparkSubmitSparkClient.java    |     5 +-
 .../hive/spark/client/TestSparkClient.java      |    11 +
 .../hive/metastore/api/CommitTxnKeyValue.java   |   589 +
 .../hive/metastore/api/CommitTxnRequest.java    |   119 +-
 .../metastore/api/GetPartitionsFilterSpec.java  |   560 +
 .../api/GetPartitionsProjectionSpec.java        |   652 +
 .../metastore/api/GetPartitionsRequest.java     |  1188 +
 .../metastore/api/GetPartitionsResponse.java    |   449 +
 .../api/NotificationEventsCountRequest.java     |   206 +-
 .../hive/metastore/api/PartitionFilterMode.java |    48 +
 .../apache/hadoop/hive/metastore/api/Table.java |   357 +-
 .../hive/metastore/api/ThriftHiveMetastore.java |  4027 ++-
 .../gen-php/metastore/ThriftHiveMetastore.php   |  1613 +-
 .../src/gen/thrift/gen-php/metastore/Types.php  |   991 +-
 .../hive_metastore/ThriftHiveMetastore-remote   |     7 +
 .../hive_metastore/ThriftHiveMetastore.py       |  1132 +-
 .../gen/thrift/gen-py/hive_metastore/ttypes.py  |   722 +-
 .../gen/thrift/gen-rb/hive_metastore_types.rb   |   174 +-
 .../gen/thrift/gen-rb/thrift_hive_metastore.rb  |    61 +
 .../hive/metastore/HiveMetaStoreClient.java     |    36 +-
 .../hadoop/hive/metastore/IMetaStoreClient.java |    47 +
 .../hive/metastore/LockComponentBuilder.java    |   126 +
 .../hive/metastore/LockRequestBuilder.java      |   185 +
 .../metastore/PartitionExpressionProxy.java     |     9 +-
 .../hive/metastore/ReplChangeManager.java       |    20 +-
 .../hive/metastore/conf/MetastoreConf.java      |    41 +-
 .../hadoop/hive/metastore/utils/LogUtils.java   |   149 +
 .../hive/metastore/utils/MetaStoreUtils.java    |    55 +-
 .../src/main/thrift/hive_metastore.thrift       |   119 +-
 .../findbugs/findbugs-exclude.xml               |    24 +
 .../hadoop/hive/metastore/DatabaseProduct.java  |     2 +-
 .../DefaultPartitionExpressionProxy.java        |     2 +-
 .../hadoop/hive/metastore/HiveAlterHandler.java |     7 +-
 .../hadoop/hive/metastore/HiveMetaStore.java    |   156 +-
 .../hive/metastore/LockComponentBuilder.java    |   126 -
 .../hive/metastore/LockRequestBuilder.java      |   185 -
 .../hive/metastore/MetaStoreDirectSql.java      |   795 +-
 .../hive/metastore/MetastoreDirectSqlUtils.java |   571 +
 .../hadoop/hive/metastore/ObjectStore.java      |   380 +-
 .../hive/metastore/PartFilterExprUtil.java      |     4 +-
 .../metastore/PartitionProjectionEvaluator.java |   893 +
 .../apache/hadoop/hive/metastore/RawStore.java  |    37 +
 .../hive/metastore/StatObjectConverter.java     |   153 +-
 .../hive/metastore/cache/CachedStore.java       |   140 +-
 .../hive/metastore/cache/SharedCache.java       |     8 +-
 .../merge/DateColumnStatsMerger.java            |    33 +-
 .../hive/metastore/messaging/EventMessage.java  |    64 +-
 .../metastore/messaging/MessageBuilder.java     |   425 +
 .../metastore/messaging/MessageEncoder.java     |    27 +
 .../metastore/messaging/MessageFactory.java     |   364 +-
 .../metastore/messaging/MessageSerializer.java  |    24 +
 .../event/filters/DatabaseAndTableFilter.java   |     8 +-
 .../messaging/json/JSONAcidWriteMessage.java    |     9 +-
 .../json/JSONAddForeignKeyMessage.java          |     5 +-
 .../json/JSONAddNotNullConstraintMessage.java   |     5 +-
 .../messaging/json/JSONAddPartitionMessage.java |    11 +-
 .../json/JSONAddPrimaryKeyMessage.java          |     5 +-
 .../json/JSONAddUniqueConstraintMessage.java    |     5 +-
 .../messaging/json/JSONAlterCatalogMessage.java |     9 +-
 .../json/JSONAlterDatabaseMessage.java          |     9 +-
 .../json/JSONAlterPartitionMessage.java         |    15 +-
 .../messaging/json/JSONAlterTableMessage.java   |     9 +-
 .../messaging/json/JSONCommitTxnMessage.java    |     5 +-
 .../json/JSONCreateDatabaseMessage.java         |     5 +-
 .../json/JSONCreateFunctionMessage.java         |     5 +-
 .../messaging/json/JSONCreateTableMessage.java  |     5 +-
 .../json/JSONDropPartitionMessage.java          |     5 +-
 .../messaging/json/JSONDropTableMessage.java    |     5 +-
 .../messaging/json/JSONInsertMessage.java       |     9 +-
 .../messaging/json/JSONMessageEncoder.java      |    70 +
 .../messaging/json/JSONMessageFactory.java      |   401 -
 .../messaging/json/gzip/DeSerializer.java       |   199 +
 .../json/gzip/GzipJSONMessageEncoder.java       |    68 +
 .../messaging/json/gzip/Serializer.java         |    50 +
 .../hadoop/hive/metastore/model/MSerDeInfo.java |     3 +
 .../metastore/model/MStorageDescriptor.java     |     9 +-
 .../hadoop/hive/metastore/model/MTable.java     |    10 +-
 .../hive/metastore/tools/SQLGenerator.java      |   110 +-
 .../hadoop/hive/metastore/txn/TxnHandler.java   |   609 +-
 .../hadoop/hive/metastore/txn/TxnStore.java     |     4 +
 .../hadoop/hive/metastore/utils/LogUtils.java   |   140 -
 .../metastore/utils/MetaStoreServerUtils.java   |   282 +-
 .../src/main/resources/package.jdo              |     8 +-
 .../DummyRawStoreControlledCommit.java          |    53 +-
 .../DummyRawStoreForJdoConnection.java          |     9 +
 .../HiveMetaStoreClientPreCatalog.java          |    20 +
 .../InjectableBehaviourObjectStore.java         |    24 +
 .../hive/metastore/MetaStoreTestUtils.java      |    11 +
 .../MockPartitionExpressionForMetastore.java    |     2 +-
 ...PartitionsUsingProjectionAndFilterSpecs.java |   904 +
 .../hive/metastore/TestHiveMetaStore.java       |   196 +-
 .../TestHiveMetaStorePartitionSpecs.java        |     2 +
 .../hive/metastore/TestHiveMetaStoreTxns.java   |   107 +
 .../hadoop/hive/metastore/TestOldSchema.java    |     2 +-
 .../TestPartitionProjectionEvaluator.java       |   250 +
 .../TestTablesCreateDropAlterTruncate.java      |    11 +
 .../merge/DateColumnStatsMergerTest.java        |   108 +
 .../merge/DecimalColumnStatsMergerTest.java     |     2 -
 .../utils/TestMetaStoreServerUtils.java         |   443 +-
 .../hive/streaming/AbstractRecordWriter.java    |    65 +-
 .../streaming/AbstractStreamingTransaction.java |   160 +
 .../apache/hive/streaming/ConnectionStats.java  |    38 +-
 .../hive/streaming/HiveStreamingConnection.java |   704 +-
 .../hive/streaming/InvalidTransactionState.java |     5 +-
 .../apache/hive/streaming/PartitionInfo.java    |     1 +
 .../org/apache/hive/streaming/RecordWriter.java |    38 +-
 .../hive/streaming/StreamingConnection.java     |    56 +
 .../hive/streaming/StreamingTransaction.java    |   125 +
 .../apache/hive/streaming/TransactionBatch.java |   448 +
 .../apache/hive/streaming/TransactionError.java |     7 +-
 .../streaming/UnManagedSingleTransaction.java   |   136 +
 .../org/apache/hive/streaming/package-info.java |    22 +
 .../java/org/apache/hive/streaming/package.html |     3 +-
 .../apache/hive/streaming/TestStreaming.java    |   470 +-
 .../ptest2/conf/deployed/master-mr2.properties  |     2 +-
 3805 files changed, 219342 insertions(+), 55021 deletions(-)
----------------------------------------------------------------------



[69/75] [abbrv] hive git commit: HIVE-20746: HiveProtoHookLogger does not close file at end of day. (Harish JP, reviewd by Anishek Agarwal)

Posted by se...@apache.org.
HIVE-20746: HiveProtoHookLogger does not close file at end of day. (Harish JP, reviewd by Anishek Agarwal)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a99be34a
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a99be34a
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a99be34a

Branch: refs/heads/master-tez092
Commit: a99be34a0ef668babaae1ef0dfbf200e259bc907
Parents: 3cbc13e
Author: Anishek Agarwal <an...@gmail.com>
Authored: Thu Oct 25 11:18:59 2018 +0530
Committer: Anishek Agarwal <an...@gmail.com>
Committed: Thu Oct 25 11:18:59 2018 +0530

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/conf/HiveConf.java   |  5 +-
 .../hive/ql/hooks/HiveProtoLoggingHook.java     | 68 ++++++++++++--------
 .../hive/ql/hooks/TestHiveProtoLoggingHook.java | 37 +++++++++++
 3 files changed, 82 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/a99be34a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
index ed6d3d8..e226a1f 100644
--- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
+++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
@@ -643,8 +643,9 @@ public class HiveConf extends Configuration {
 
     HIVE_PROTO_EVENTS_BASE_PATH("hive.hook.proto.base-directory", "",
             "Base directory into which the proto event messages are written by HiveProtoLoggingHook."),
-    HIVE_PROTO_EVENTS_QUEUE_CAPACITY("hive.hook.proto.queue.capacity", 64,
-            "Queue capacity for the proto events logging threads."),
+    HIVE_PROTO_EVENTS_ROLLOVER_CHECK_INTERVAL("hive.hook.proto.rollover-interval", "600s",
+            new TimeValidator(TimeUnit.SECONDS, 0L, true, 3600 * 24L, true),
+            "Frequency at which the file rollover check is triggered."),
     HIVE_PROTO_EVENTS_CLEAN_FREQ("hive.hook.proto.events.clean.freq", "1d",
             new TimeValidator(TimeUnit.DAYS),
             "Frequency at which timer task runs to purge expired proto event files."),

http://git-wip-us.apache.org/repos/asf/hive/blob/a99be34a/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java b/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
index 5a613b8..0a09675 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java
@@ -93,11 +93,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.Executors;
 import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -162,7 +161,6 @@ public class HiveProtoLoggingHook implements ExecuteWithHookContext {
             .collect(Collectors.toSet());
   }
 
-  private static final int HIVE_HOOK_PROTO_QUEUE_CAPACITY_DEFAULT = 64;
   private static final int WAIT_TIME = 5;
 
   public enum EventType {
@@ -182,7 +180,7 @@ public class HiveProtoLoggingHook implements ExecuteWithHookContext {
     private final Clock clock;
     private final String logFileName;
     private final DatePartitionedLogger<HiveHookEventProto> logger;
-    private final ExecutorService logWriter;
+    private final ScheduledExecutorService logWriter;
     private int logFileCount = 0;
     private ProtoMessageWriter<HiveHookEventProto> writer;
     private LocalDate writerDate;
@@ -215,13 +213,14 @@ public class HiveProtoLoggingHook implements ExecuteWithHookContext {
         return;
       }
 
-      int queueCapacity = conf.getInt(ConfVars.HIVE_PROTO_EVENTS_QUEUE_CAPACITY.varname,
-          HIVE_HOOK_PROTO_QUEUE_CAPACITY_DEFAULT);
-
       ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
           .setNameFormat("Hive Hook Proto Log Writer %d").build();
-      logWriter = new ThreadPoolExecutor(1, 1, 0, TimeUnit.MILLISECONDS,
-          new LinkedBlockingQueue<Runnable>(queueCapacity), threadFactory);
+      logWriter = Executors.newSingleThreadScheduledExecutor(threadFactory);
+
+      long rolloverInterval = conf.getTimeVar(
+          HiveConf.ConfVars.HIVE_PROTO_EVENTS_ROLLOVER_CHECK_INTERVAL, TimeUnit.MICROSECONDS);
+      logWriter.scheduleWithFixedDelay(() -> handleTick(), rolloverInterval, rolloverInterval,
+          TimeUnit.MICROSECONDS);
     }
 
     void shutdown() {
@@ -277,29 +276,45 @@ public class HiveProtoLoggingHook implements ExecuteWithHookContext {
       }
     }
 
+    private void handleTick() {
+      try {
+        maybeRolloverWriterForDay();
+      } catch (IOException e) {
+        LOG.error("Got IOException while trying to rollover: ", e);
+      }
+    }
+
+    private boolean maybeRolloverWriterForDay() throws IOException {
+      if (writer == null || !logger.getNow().toLocalDate().equals(writerDate)) {
+        if (writer != null) {
+          // Day change over case, reset the logFileCount.
+          logFileCount = 0;
+          IOUtils.closeQuietly(writer);
+          writer = null;
+        }
+        // increment log file count, if creating a new writer.
+        writer = logger.getWriter(logFileName + "_" + ++logFileCount);
+        writerDate = logger.getDateFromDir(writer.getPath().getParent().getName());
+        return true;
+      }
+      return false;
+    }
+
     private static final int MAX_RETRIES = 2;
     private void writeEvent(HiveHookEventProto event) {
       for (int retryCount = 0; retryCount <= MAX_RETRIES; ++retryCount) {
         try {
-          if (writer == null || !logger.getNow().toLocalDate().equals(writerDate)) {
-            if (writer != null) {
-              // Day change over case, reset the logFileCount.
-              logFileCount = 0;
-              IOUtils.closeQuietly(writer);
-            }
-            // increment log file count, if creating a new writer.
-            writer = logger.getWriter(logFileName + "_" + ++logFileCount);
-            writerDate = logger.getDateFromDir(writer.getPath().getParent().getName());
-          }
-          writer.writeProto(event);
           if (eventPerFile) {
-            if (writer != null) {
-              LOG.debug("Event per file enabled. Closing proto event file: {}", writer.getPath());
-              IOUtils.closeQuietly(writer);
+            LOG.debug("Event per file enabled. Closing proto event file: {}", writer.getPath());
+            if (!maybeRolloverWriterForDay()) {
+              writer = logger.getWriter(logFileName + "_" + ++logFileCount);
             }
-            // rollover to next file
-            writer = logger.getWriter(logFileName + "_" + ++logFileCount);
+            writer.writeProto(event);
+            IOUtils.closeQuietly(writer);
+            writer = null;
           } else {
+            maybeRolloverWriterForDay();
+            writer.writeProto(event);
             writer.hflush();
           }
           return;
@@ -311,6 +326,7 @@ public class HiveProtoLoggingHook implements ExecuteWithHookContext {
             LOG.warn("Error writing proto message for query {}, eventType: {}, retryCount: {}," +
                 " error: {} ", event.getHiveQueryId(), event.getEventType(), retryCount,
                 e.getMessage());
+            LOG.trace("Exception", e);
           } else {
             LOG.error("Error writing proto message for query {}, eventType: {}: ",
                 event.getHiveQueryId(), event.getEventType(), e);

http://git-wip-us.apache.org/repos/asf/hive/blob/a99be34a/ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveProtoLoggingHook.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveProtoLoggingHook.java b/ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveProtoLoggingHook.java
index a5939fa..450a0b5 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveProtoLoggingHook.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/hooks/TestHiveProtoLoggingHook.java
@@ -22,11 +22,14 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.ql.QueryPlan;
 import org.apache.hadoop.hive.ql.QueryState;
 import org.apache.hadoop.hive.ql.exec.mr.ExecDriver;
@@ -224,6 +227,40 @@ public class TestHiveProtoLoggingHook {
     assertOtherInfo(event, OtherInfoType.PERF, null);
   }
 
+  @Test
+  public void testRolloverFiles() throws Exception {
+    long waitTime = 100;
+    context.setHookType(HookType.PRE_EXEC_HOOK);
+    conf.setTimeDuration(ConfVars.HIVE_PROTO_EVENTS_ROLLOVER_CHECK_INTERVAL.varname, waitTime,
+        TimeUnit.MICROSECONDS);
+    Path path = new Path(tmpFolder);
+    FileSystem fs = path.getFileSystem(conf);
+    AtomicLong time = new AtomicLong();
+    EventLogger evtLogger = new EventLogger(conf, () -> time.get());
+    evtLogger.handle(context);
+    int statusLen = 0;
+    // Loop to ensure that we give some grace for scheduling issues.
+    for (int i = 0; i < 3; ++i) {
+      Thread.sleep(waitTime + 100);
+      statusLen = fs.listStatus(path).length;
+      if (statusLen > 0) {
+        break;
+      }
+    }
+    Assert.assertEquals(1, statusLen);
+
+    // Move to next day and ensure a new file gets created.
+    time.set(24 * 60 * 60 * 1000 + 1000);
+    for (int i = 0; i < 3; ++i) {
+      Thread.sleep(waitTime + 100);
+      statusLen = fs.listStatus(path).length;
+      if (statusLen > 1) {
+        break;
+      }
+    }
+    Assert.assertEquals(2, statusLen);
+  }
+
   private ProtoMessageReader<HiveHookEventProto> getTestReader(HiveConf conf, String tmpFolder)
       throws IOException {
     Path path = new Path(tmpFolder);


[68/75] [abbrv] hive git commit: HIVE-20788: Extended SJ reduction may backtrack columns incorrectly when creating filters (Jesus Camacho Rodriguez, reviewed by Deepak Jaiswal)

Posted by se...@apache.org.
HIVE-20788: Extended SJ reduction may backtrack columns incorrectly when creating filters (Jesus Camacho Rodriguez, reviewed by Deepak Jaiswal)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/3cbc13e9
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/3cbc13e9
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/3cbc13e9

Branch: refs/heads/master-tez092
Commit: 3cbc13e92b9c22fabf9eac72eaec9352eb9b43d2
Parents: 94d4991
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Mon Oct 22 18:30:18 2018 -0700
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Wed Oct 24 16:11:48 2018 -0700

----------------------------------------------------------------------
 .../hive/ql/ppd/SyntheticJoinPredicate.java     |  17 +-
 .../queries/clientpositive/perf/cbo_query24.q   |   3 +-
 .../test/queries/clientpositive/perf/query24.q  |   3 +-
 .../clientpositive/perf/spark/query24.q.out     | 400 ++++++++---------
 .../clientpositive/perf/tez/cbo_query23.q.out   |   8 +-
 .../clientpositive/perf/tez/cbo_query24.q.out   | 103 ++---
 .../perf/tez/constraints/cbo_query24.q.out      | 101 ++---
 .../perf/tez/constraints/cbo_query6.q.out       |   2 +-
 .../perf/tez/constraints/query18.q.out          | 108 ++---
 .../perf/tez/constraints/query24.q.out          | 436 ++++++++++---------
 .../perf/tez/constraints/query33.q.out          | 202 ++++-----
 .../perf/tez/constraints/query56.q.out          | 236 +++++-----
 .../perf/tez/constraints/query6.q.out           | 132 +++---
 .../perf/tez/constraints/query60.q.out          | 242 +++++-----
 .../perf/tez/constraints/query95.q.out          | 128 +++---
 .../clientpositive/perf/tez/query18.q.out       | 112 ++---
 .../clientpositive/perf/tez/query23.q.out       | 340 +++++++--------
 .../clientpositive/perf/tez/query24.q.out       | 436 ++++++++++---------
 .../clientpositive/perf/tez/query59.q.out       |  74 ++--
 .../clientpositive/perf/tez/query95.q.out       | 180 ++++----
 20 files changed, 1664 insertions(+), 1599 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/java/org/apache/hadoop/hive/ql/ppd/SyntheticJoinPredicate.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ppd/SyntheticJoinPredicate.java b/ql/src/java/org/apache/hadoop/hive/ql/ppd/SyntheticJoinPredicate.java
index 1f533bc..e97e447 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ppd/SyntheticJoinPredicate.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ppd/SyntheticJoinPredicate.java
@@ -308,7 +308,22 @@ public class SyntheticJoinPredicate extends Transform {
       CommonJoinOperator<JoinDesc> joinOp = (CommonJoinOperator) currentOp;
 
       // 2. Backtrack expression to join output
-      final ExprNodeDesc joinExprNode = ExprNodeDescUtils.backtrack(currentNode, op, joinOp);
+      ExprNodeDesc expr = currentNode;
+      if (currentOp != op) {
+        if (expr instanceof ExprNodeColumnDesc) {
+          // Expression refers to output of current operator, but backtrack methods works
+          // from the input columns, hence we need to make resolution for current operator
+          // here. If the operator was already the join, there is nothing to do
+          if (op.getColumnExprMap() != null) {
+            expr = op.getColumnExprMap().get(((ExprNodeColumnDesc) expr).getColumn());
+          }
+        } else {
+          // TODO: We can extend to other expression types
+          // We are done
+          return true;
+        }
+      }
+      final ExprNodeDesc joinExprNode = ExprNodeDescUtils.backtrack(expr, op, joinOp);
       if (joinExprNode == null || !(joinExprNode instanceof ExprNodeColumnDesc)) {
         // TODO: We can extend to other expression types
         // We are done

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/queries/clientpositive/perf/cbo_query24.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query24.q b/ql/src/test/queries/clientpositive/perf/cbo_query24.q
index 02bcbaf..8994de7 100644
--- a/ql/src/test/queries/clientpositive/perf/cbo_query24.q
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query24.q
@@ -24,7 +24,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/queries/clientpositive/perf/query24.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/query24.q b/ql/src/test/queries/clientpositive/perf/query24.q
index 007d7ee..b3cdaef 100644
--- a/ql/src/test/queries/clientpositive/perf/query24.q
+++ b/ql/src/test/queries/clientpositive/perf/query24.q
@@ -24,7 +24,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/spark/query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/spark/query24.q.out b/ql/src/test/results/clientpositive/perf/spark/query24.q.out
index 4e2e8e7..91fe702 100644
--- a/ql/src/test/results/clientpositive/perf/spark/query24.q.out
+++ b/ql/src/test/results/clientpositive/perf/spark/query24.q.out
@@ -1,4 +1,4 @@
-Warning: Map Join MAPJOIN[104][bigTable=?] in task 'Stage-1:MAPRED' is a cross product
+Warning: Map Join MAPJOIN[107][bigTable=?] in task 'Stage-1:MAPRED' is a cross product
 PREHOOK: query: explain
 with ssales as
 (select c_last_name
@@ -23,7 +23,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -79,7 +80,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -138,8 +140,8 @@ STAGE PLANS:
                       Statistics: Num rows: 852 Data size: 1628138 Basic stats: COMPLETE Column stats: NONE
                       Spark HashTable Sink Operator
                         keys:
-                          0 _col2 (type: int)
-                          1 _col0 (type: int)
+                          0 _col2 (type: string)
+                          1 _col4 (type: string)
             Execution mode: vectorized
             Local Work:
               Map Reduce Local Work
@@ -147,43 +149,43 @@ STAGE PLANS:
   Stage: Stage-2
     Spark
       Edges:
-        Reducer 13 <- Map 12 (PARTITION-LEVEL SORT, 975), Map 20 (PARTITION-LEVEL SORT, 975)
-        Reducer 14 <- Map 21 (PARTITION-LEVEL SORT, 486), Reducer 13 (PARTITION-LEVEL SORT, 486)
-        Reducer 15 <- Map 22 (PARTITION-LEVEL SORT, 564), Reducer 14 (PARTITION-LEVEL SORT, 564)
-        Reducer 16 <- Map 23 (PARTITION-LEVEL SORT, 899), Reducer 15 (PARTITION-LEVEL SORT, 899)
-        Reducer 17 <- Reducer 16 (GROUP, 640)
+        Reducer 13 <- Map 12 (PARTITION-LEVEL SORT, 887), Map 20 (PARTITION-LEVEL SORT, 887)
+        Reducer 14 <- Map 21 (PARTITION-LEVEL SORT, 989), Reducer 13 (PARTITION-LEVEL SORT, 989)
+        Reducer 15 <- Map 22 (PARTITION-LEVEL SORT, 442), Reducer 14 (PARTITION-LEVEL SORT, 442)
+        Reducer 16 <- Map 23 (PARTITION-LEVEL SORT, 516), Reducer 15 (PARTITION-LEVEL SORT, 516)
+        Reducer 17 <- Reducer 16 (GROUP, 529)
         Reducer 18 <- Reducer 17 (GROUP, 1)
 #### A masked pattern was here ####
       Vertices:
         Map 12 
             Map Operator Tree:
                 TableScan
-                  alias: store_sales
-                  filterExpr: (ss_ticket_number is not null and ss_item_sk is not null and ss_store_sk is not null and ss_customer_sk is not null) (type: boolean)
-                  Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
+                  alias: customer_address
+                  filterExpr: (ca_address_sk is not null and ca_zip is not null) (type: boolean)
+                  Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
                   Filter Operator
-                    predicate: (ss_customer_sk is not null and ss_item_sk is not null and ss_store_sk is not null and ss_ticket_number is not null) (type: boolean)
-                    Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
+                    predicate: (ca_address_sk is not null and ca_zip is not null) (type: boolean)
+                    Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: ss_item_sk (type: int), ss_customer_sk (type: int), ss_store_sk (type: int), ss_ticket_number (type: int), ss_sales_price (type: decimal(7,2))
-                      outputColumnNames: _col0, _col1, _col2, _col3, _col4
-                      Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
+                      expressions: ca_address_sk (type: int), ca_state (type: string), ca_zip (type: string), ca_country (type: string)
+                      outputColumnNames: _col0, _col1, _col2, _col3
+                      Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
                       Map Join Operator
                         condition map:
                              Inner Join 0 to 1
                         keys:
-                          0 _col2 (type: int)
-                          1 _col0 (type: int)
-                        outputColumnNames: _col0, _col1, _col3, _col4, _col6, _col8, _col9
+                          0 _col2 (type: string)
+                          1 _col4 (type: string)
+                        outputColumnNames: _col0, _col1, _col3, _col4, _col5, _col7
                         input vertices:
                           1 Map 19
-                        Statistics: Num rows: 633595212 Data size: 55895953508 Basic stats: COMPLETE Column stats: NONE
+                        Statistics: Num rows: 44000000 Data size: 44654715780 Basic stats: COMPLETE Column stats: NONE
                         Reduce Output Operator
-                          key expressions: _col1 (type: int)
+                          key expressions: _col0 (type: int)
                           sort order: +
-                          Map-reduce partition columns: _col1 (type: int)
-                          Statistics: Num rows: 633595212 Data size: 55895953508 Basic stats: COMPLETE Column stats: NONE
-                          value expressions: _col0 (type: int), _col3 (type: int), _col4 (type: decimal(7,2)), _col6 (type: string), _col8 (type: string), _col9 (type: string)
+                          Map-reduce partition columns: _col0 (type: int)
+                          Statistics: Num rows: 44000000 Data size: 44654715780 Basic stats: COMPLETE Column stats: NONE
+                          value expressions: _col1 (type: string), _col3 (type: string), _col4 (type: int), _col5 (type: string), _col7 (type: string)
             Execution mode: vectorized
             Local Work:
               Map Reduce Local Work
@@ -191,25 +193,45 @@ STAGE PLANS:
             Map Operator Tree:
                 TableScan
                   alias: customer
-                  filterExpr: (c_customer_sk is not null and c_birth_country is not null) (type: boolean)
+                  filterExpr: (c_customer_sk is not null and c_current_addr_sk is not null) (type: boolean)
                   Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
                   Filter Operator
-                    predicate: (c_birth_country is not null and c_customer_sk is not null) (type: boolean)
+                    predicate: (c_current_addr_sk is not null and c_customer_sk is not null) (type: boolean)
                     Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: c_customer_sk (type: int), c_first_name (type: string), c_last_name (type: string), c_birth_country (type: string)
-                      outputColumnNames: _col0, _col1, _col2, _col3
+                      expressions: c_customer_sk (type: int), c_current_addr_sk (type: int), c_first_name (type: string), c_last_name (type: string), c_birth_country (type: string)
+                      outputColumnNames: _col0, _col1, _col2, _col3, _col4
                       Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
                       Reduce Output Operator
-                        key expressions: _col0 (type: int)
+                        key expressions: _col1 (type: int)
                         sort order: +
-                        Map-reduce partition columns: _col0 (type: int)
+                        Map-reduce partition columns: _col1 (type: int)
                         Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: string), _col2 (type: string), _col3 (type: string)
+                        value expressions: _col0 (type: int), _col2 (type: string), _col3 (type: string), _col4 (type: string)
             Execution mode: vectorized
         Map 21 
             Map Operator Tree:
                 TableScan
+                  alias: store_sales
+                  filterExpr: (ss_ticket_number is not null and ss_item_sk is not null and ss_store_sk is not null and ss_customer_sk is not null) (type: boolean)
+                  Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
+                  Filter Operator
+                    predicate: (ss_customer_sk is not null and ss_item_sk is not null and ss_store_sk is not null and ss_ticket_number is not null) (type: boolean)
+                    Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
+                    Select Operator
+                      expressions: ss_item_sk (type: int), ss_customer_sk (type: int), ss_store_sk (type: int), ss_ticket_number (type: int), ss_sales_price (type: decimal(7,2))
+                      outputColumnNames: _col0, _col1, _col2, _col3, _col4
+                      Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
+                      Reduce Output Operator
+                        key expressions: _col1 (type: int), _col2 (type: int)
+                        sort order: ++
+                        Map-reduce partition columns: _col1 (type: int), _col2 (type: int)
+                        Statistics: Num rows: 575995635 Data size: 50814502088 Basic stats: COMPLETE Column stats: NONE
+                        value expressions: _col0 (type: int), _col3 (type: int), _col4 (type: decimal(7,2))
+            Execution mode: vectorized
+        Map 22 
+            Map Operator Tree:
+                TableScan
                   alias: item
                   filterExpr: i_item_sk is not null (type: boolean)
                   Statistics: Num rows: 462000 Data size: 663560457 Basic stats: COMPLETE Column stats: NONE
@@ -227,7 +249,7 @@ STAGE PLANS:
                         Statistics: Num rows: 462000 Data size: 663560457 Basic stats: COMPLETE Column stats: NONE
                         value expressions: _col1 (type: decimal(7,2)), _col2 (type: string), _col3 (type: string), _col4 (type: string), _col5 (type: int)
             Execution mode: vectorized
-        Map 22 
+        Map 23 
             Map Operator Tree:
                 TableScan
                   alias: store_returns
@@ -246,109 +268,92 @@ STAGE PLANS:
                         Map-reduce partition columns: _col0 (type: int), _col1 (type: int)
                         Statistics: Num rows: 57591150 Data size: 4462194832 Basic stats: COMPLETE Column stats: NONE
             Execution mode: vectorized
-        Map 23 
-            Map Operator Tree:
-                TableScan
-                  alias: customer_address
-                  filterExpr: (upper(ca_country) is not null and ca_zip is not null) (type: boolean)
-                  Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                  Filter Operator
-                    predicate: (ca_zip is not null and upper(ca_country) is not null) (type: boolean)
-                    Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                    Select Operator
-                      expressions: ca_state (type: string), ca_zip (type: string), ca_country (type: string)
-                      outputColumnNames: _col0, _col1, _col2
-                      Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                      Reduce Output Operator
-                        key expressions: _col1 (type: string), upper(_col2) (type: string)
-                        sort order: ++
-                        Map-reduce partition columns: _col1 (type: string), upper(_col2) (type: string)
-                        Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col0 (type: string)
-            Execution mode: vectorized
         Reducer 13 
             Reduce Operator Tree:
               Join Operator
                 condition map:
                      Inner Join 0 to 1
                 keys:
-                  0 _col1 (type: int)
-                  1 _col0 (type: int)
-                outputColumnNames: _col0, _col3, _col4, _col6, _col8, _col9, _col11, _col12, _col13
-                Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: int)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: int)
-                  Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col3 (type: int), _col4 (type: decimal(7,2)), _col6 (type: string), _col8 (type: string), _col9 (type: string), _col11 (type: string), _col12 (type: string), _col13 (type: string)
+                  0 _col0 (type: int)
+                  1 _col1 (type: int)
+                outputColumnNames: _col1, _col3, _col4, _col5, _col7, _col9, _col11, _col12, _col13
+                Statistics: Num rows: 88000001 Data size: 75681779077 Basic stats: COMPLETE Column stats: NONE
+                Filter Operator
+                  predicate: (_col13 <> upper(_col3)) (type: boolean)
+                  Statistics: Num rows: 88000001 Data size: 75681779077 Basic stats: COMPLETE Column stats: NONE
+                  Reduce Output Operator
+                    key expressions: _col9 (type: int), _col4 (type: int)
+                    sort order: ++
+                    Map-reduce partition columns: _col9 (type: int), _col4 (type: int)
+                    Statistics: Num rows: 88000001 Data size: 75681779077 Basic stats: COMPLETE Column stats: NONE
+                    value expressions: _col1 (type: string), _col5 (type: string), _col7 (type: string), _col11 (type: string), _col12 (type: string)
         Reducer 14 
             Reduce Operator Tree:
               Join Operator
                 condition map:
                      Inner Join 0 to 1
                 keys:
-                  0 _col0 (type: int)
-                  1 _col0 (type: int)
-                outputColumnNames: _col0, _col3, _col4, _col6, _col8, _col9, _col11, _col12, _col13, _col15, _col16, _col17, _col18, _col19
-                Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
+                  0 _col9 (type: int), _col4 (type: int)
+                  1 _col1 (type: int), _col2 (type: int)
+                outputColumnNames: _col1, _col5, _col7, _col11, _col12, _col14, _col17, _col18
+                Statistics: Num rows: 633595212 Data size: 55895953508 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
-                  key expressions: _col0 (type: int), _col3 (type: int)
-                  sort order: ++
-                  Map-reduce partition columns: _col0 (type: int), _col3 (type: int)
-                  Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col4 (type: decimal(7,2)), _col6 (type: string), _col8 (type: string), _col9 (type: string), _col11 (type: string), _col12 (type: string), _col13 (type: string), _col15 (type: decimal(7,2)), _col16 (type: string), _col17 (type: string), _col18 (type: string), _col19 (type: int)
+                  key expressions: _col14 (type: int)
+                  sort order: +
+                  Map-reduce partition columns: _col14 (type: int)
+                  Statistics: Num rows: 633595212 Data size: 55895953508 Basic stats: COMPLETE Column stats: NONE
+                  value expressions: _col1 (type: string), _col5 (type: string), _col7 (type: string), _col11 (type: string), _col12 (type: string), _col17 (type: int), _col18 (type: decimal(7,2))
         Reducer 15 
             Reduce Operator Tree:
               Join Operator
                 condition map:
                      Inner Join 0 to 1
                 keys:
-                  0 _col0 (type: int), _col3 (type: int)
-                  1 _col0 (type: int), _col1 (type: int)
-                outputColumnNames: _col4, _col6, _col8, _col9, _col11, _col12, _col13, _col15, _col16, _col17, _col18, _col19
-                Statistics: Num rows: 843315281 Data size: 74397518956 Basic stats: COMPLETE Column stats: NONE
+                  0 _col14 (type: int)
+                  1 _col0 (type: int)
+                outputColumnNames: _col1, _col5, _col7, _col11, _col12, _col14, _col17, _col18, _col20, _col21, _col22, _col23, _col24
+                Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
-                  key expressions: _col9 (type: string), _col13 (type: string)
+                  key expressions: _col14 (type: int), _col17 (type: int)
                   sort order: ++
-                  Map-reduce partition columns: _col9 (type: string), _col13 (type: string)
-                  Statistics: Num rows: 843315281 Data size: 74397518956 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col4 (type: decimal(7,2)), _col6 (type: string), _col8 (type: string), _col11 (type: string), _col12 (type: string), _col15 (type: decimal(7,2)), _col16 (type: string), _col17 (type: string), _col18 (type: string), _col19 (type: int)
+                  Map-reduce partition columns: _col14 (type: int), _col17 (type: int)
+                  Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
+                  value expressions: _col1 (type: string), _col5 (type: string), _col7 (type: string), _col11 (type: string), _col12 (type: string), _col18 (type: decimal(7,2)), _col20 (type: decimal(7,2)), _col21 (type: string), _col22 (type: string), _col23 (type: string), _col24 (type: int)
         Reducer 16 
             Reduce Operator Tree:
               Join Operator
                 condition map:
                      Inner Join 0 to 1
                 keys:
-                  0 _col9 (type: string), _col13 (type: string)
-                  1 _col1 (type: string), upper(_col2) (type: string)
-                outputColumnNames: _col4, _col6, _col8, _col11, _col12, _col15, _col16, _col17, _col18, _col19, _col22
-                Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
+                  0 _col14 (type: int), _col17 (type: int)
+                  1 _col0 (type: int), _col1 (type: int)
+                outputColumnNames: _col1, _col5, _col7, _col11, _col12, _col18, _col20, _col21, _col22, _col23, _col24
+                Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
                 Group By Operator
-                  aggregations: sum(_col4)
-                  keys: _col11 (type: string), _col12 (type: string), _col6 (type: string), _col8 (type: string), _col15 (type: decimal(7,2)), _col16 (type: string), _col17 (type: string), _col18 (type: string), _col19 (type: int), _col22 (type: string)
+                  aggregations: sum(_col18)
+                  keys: _col11 (type: string), _col12 (type: string), _col1 (type: string), _col5 (type: string), _col7 (type: string), _col20 (type: decimal(7,2)), _col21 (type: string), _col22 (type: string), _col23 (type: string), _col24 (type: int)
                   mode: hash
                   outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10
-                  Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
+                  Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
                   Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: decimal(7,2)), _col5 (type: string), _col6 (type: string), _col7 (type: string), _col8 (type: int), _col9 (type: string)
+                    key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: string), _col5 (type: decimal(7,2)), _col6 (type: string), _col7 (type: string), _col8 (type: string), _col9 (type: int)
                     sort order: ++++++++++
-                    Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: decimal(7,2)), _col5 (type: string), _col6 (type: string), _col7 (type: string), _col8 (type: int), _col9 (type: string)
-                    Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
+                    Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: string), _col5 (type: decimal(7,2)), _col6 (type: string), _col7 (type: string), _col8 (type: string), _col9 (type: int)
+                    Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
                     value expressions: _col10 (type: decimal(17,2))
         Reducer 17 
             Execution mode: vectorized
             Reduce Operator Tree:
               Group By Operator
                 aggregations: sum(VALUE._col0)
-                keys: KEY._col0 (type: string), KEY._col1 (type: string), KEY._col2 (type: string), KEY._col3 (type: string), KEY._col4 (type: decimal(7,2)), KEY._col5 (type: string), KEY._col6 (type: string), KEY._col7 (type: string), KEY._col8 (type: int), KEY._col9 (type: string)
+                keys: KEY._col0 (type: string), KEY._col1 (type: string), KEY._col2 (type: string), KEY._col3 (type: string), KEY._col4 (type: string), KEY._col5 (type: decimal(7,2)), KEY._col6 (type: string), KEY._col7 (type: string), KEY._col8 (type: string), KEY._col9 (type: int)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9, _col10
-                Statistics: Num rows: 463823414 Data size: 40918636268 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 383325119 Data size: 33817053293 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
                   expressions: _col10 (type: decimal(17,2))
                   outputColumnNames: _col10
-                  Statistics: Num rows: 463823414 Data size: 40918636268 Basic stats: COMPLETE Column stats: NONE
+                  Statistics: Num rows: 383325119 Data size: 33817053293 Basic stats: COMPLETE Column stats: NONE
                   Group By Operator
                     aggregations: sum(_col10), count(_col10)
                     mode: hash
@@ -381,7 +386,7 @@ STAGE PLANS:
     Spark
 #### A masked pattern was here ####
       Vertices:
-        Map 8 
+        Map 9 
             Map Operator Tree:
                 TableScan
                   alias: store
@@ -396,8 +401,8 @@ STAGE PLANS:
                       Statistics: Num rows: 852 Data size: 1628138 Basic stats: COMPLETE Column stats: NONE
                       Spark HashTable Sink Operator
                         keys:
-                          0 _col2 (type: int)
-                          1 _col0 (type: int)
+                          0 _col2 (type: string)
+                          1 _col4 (type: string)
             Execution mode: vectorized
             Local Work:
               Map Reduce Local Work
@@ -405,11 +410,11 @@ STAGE PLANS:
   Stage: Stage-1
     Spark
       Edges:
-        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 400), Map 7 (PARTITION-LEVEL SORT, 400)
-        Reducer 3 <- Map 9 (PARTITION-LEVEL SORT, 1009), Reducer 2 (PARTITION-LEVEL SORT, 1009)
-        Reducer 4 <- Map 10 (PARTITION-LEVEL SORT, 564), Reducer 3 (PARTITION-LEVEL SORT, 564)
-        Reducer 5 <- Map 11 (PARTITION-LEVEL SORT, 899), Reducer 4 (PARTITION-LEVEL SORT, 899)
-        Reducer 6 <- Reducer 5 (GROUP PARTITION-LEVEL SORT, 640)
+        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 400), Map 6 (PARTITION-LEVEL SORT, 400)
+        Reducer 3 <- Reducer 2 (PARTITION-LEVEL SORT, 1009), Reducer 8 (PARTITION-LEVEL SORT, 1009)
+        Reducer 4 <- Map 11 (PARTITION-LEVEL SORT, 516), Reducer 3 (PARTITION-LEVEL SORT, 516)
+        Reducer 5 <- Reducer 4 (GROUP PARTITION-LEVEL SORT, 529)
+        Reducer 8 <- Map 10 (PARTITION-LEVEL SORT, 887), Map 7 (PARTITION-LEVEL SORT, 887)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -435,6 +440,26 @@ STAGE PLANS:
         Map 10 
             Map Operator Tree:
                 TableScan
+                  alias: customer
+                  filterExpr: (c_customer_sk is not null and c_current_addr_sk is not null) (type: boolean)
+                  Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
+                  Filter Operator
+                    predicate: (c_current_addr_sk is not null and c_customer_sk is not null) (type: boolean)
+                    Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
+                    Select Operator
+                      expressions: c_customer_sk (type: int), c_current_addr_sk (type: int), c_first_name (type: string), c_last_name (type: string), c_birth_country (type: string)
+                      outputColumnNames: _col0, _col1, _col2, _col3, _col4
+                      Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
+                      Reduce Output Operator
+                        key expressions: _col1 (type: int)
+                        sort order: +
+                        Map-reduce partition columns: _col1 (type: int)
+                        Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
+                        value expressions: _col0 (type: int), _col2 (type: string), _col3 (type: string), _col4 (type: string)
+            Execution mode: vectorized
+        Map 11 
+            Map Operator Tree:
+                TableScan
                   alias: store_returns
                   filterExpr: (sr_ticket_number is not null and sr_item_sk is not null) (type: boolean)
                   Statistics: Num rows: 57591150 Data size: 4462194832 Basic stats: COMPLETE Column stats: NONE
@@ -451,27 +476,7 @@ STAGE PLANS:
                         Map-reduce partition columns: _col0 (type: int), _col1 (type: int)
                         Statistics: Num rows: 57591150 Data size: 4462194832 Basic stats: COMPLETE Column stats: NONE
             Execution mode: vectorized
-        Map 11 
-            Map Operator Tree:
-                TableScan
-                  alias: customer_address
-                  filterExpr: (upper(ca_country) is not null and ca_zip is not null) (type: boolean)
-                  Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                  Filter Operator
-                    predicate: (ca_zip is not null and upper(ca_country) is not null) (type: boolean)
-                    Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                    Select Operator
-                      expressions: ca_state (type: string), ca_zip (type: string), ca_country (type: string)
-                      outputColumnNames: _col0, _col1, _col2
-                      Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                      Reduce Output Operator
-                        key expressions: _col1 (type: string), upper(_col2) (type: string)
-                        sort order: ++
-                        Map-reduce partition columns: _col1 (type: string), upper(_col2) (type: string)
-                        Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col0 (type: string)
-            Execution mode: vectorized
-        Map 7 
+        Map 6 
             Map Operator Tree:
                 TableScan
                   alias: item
@@ -491,29 +496,39 @@ STAGE PLANS:
                         Statistics: Num rows: 231000 Data size: 331780228 Basic stats: COMPLETE Column stats: NONE
                         value expressions: _col1 (type: decimal(7,2)), _col2 (type: string), _col4 (type: string), _col5 (type: int)
             Execution mode: vectorized
-        Map 9 
+        Map 7 
             Map Operator Tree:
                 TableScan
-                  alias: customer
-                  filterExpr: (c_customer_sk is not null and c_birth_country is not null) (type: boolean)
-                  Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
+                  alias: customer_address
+                  filterExpr: (ca_address_sk is not null and ca_zip is not null) (type: boolean)
+                  Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
                   Filter Operator
-                    predicate: (c_birth_country is not null and c_customer_sk is not null) (type: boolean)
-                    Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
+                    predicate: (ca_address_sk is not null and ca_zip is not null) (type: boolean)
+                    Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
-                      expressions: c_customer_sk (type: int), c_first_name (type: string), c_last_name (type: string), c_birth_country (type: string)
+                      expressions: ca_address_sk (type: int), ca_state (type: string), ca_zip (type: string), ca_country (type: string)
                       outputColumnNames: _col0, _col1, _col2, _col3
-                      Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
-                      Reduce Output Operator
-                        key expressions: _col0 (type: int)
-                        sort order: +
-                        Map-reduce partition columns: _col0 (type: int)
-                        Statistics: Num rows: 80000000 Data size: 68801615852 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: string), _col2 (type: string), _col3 (type: string)
+                      Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE Column stats: NONE
+                      Map Join Operator
+                        condition map:
+                             Inner Join 0 to 1
+                        keys:
+                          0 _col2 (type: string)
+                          1 _col4 (type: string)
+                        outputColumnNames: _col0, _col1, _col3, _col4, _col5, _col7
+                        input vertices:
+                          1 Map 9
+                        Statistics: Num rows: 44000000 Data size: 44654715780 Basic stats: COMPLETE Column stats: NONE
+                        Reduce Output Operator
+                          key expressions: _col0 (type: int)
+                          sort order: +
+                          Map-reduce partition columns: _col0 (type: int)
+                          Statistics: Num rows: 44000000 Data size: 44654715780 Basic stats: COMPLETE Column stats: NONE
+                          value expressions: _col1 (type: string), _col3 (type: string), _col4 (type: int), _col5 (type: string), _col7 (type: string)
             Execution mode: vectorized
-        Reducer 2 
             Local Work:
               Map Reduce Local Work
+        Reducer 2 
             Reduce Operator Tree:
               Join Operator
                 condition map:
@@ -523,38 +538,28 @@ STAGE PLANS:
                   1 _col0 (type: int)
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col6, _col7, _col9, _col10
                 Statistics: Num rows: 633595212 Data size: 55895953508 Basic stats: COMPLETE Column stats: NONE
-                Map Join Operator
-                  condition map:
-                       Inner Join 0 to 1
-                  keys:
-                    0 _col2 (type: int)
-                    1 _col0 (type: int)
-                  outputColumnNames: _col0, _col1, _col3, _col4, _col6, _col7, _col9, _col10, _col12, _col14, _col15
-                  input vertices:
-                    1 Map 8
-                  Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col1 (type: int)
-                    sort order: +
-                    Map-reduce partition columns: _col1 (type: int)
-                    Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
-                    value expressions: _col0 (type: int), _col3 (type: int), _col4 (type: decimal(7,2)), _col6 (type: decimal(7,2)), _col7 (type: string), _col9 (type: string), _col10 (type: int), _col12 (type: string), _col14 (type: string), _col15 (type: string)
+                Reduce Output Operator
+                  key expressions: _col1 (type: int), _col2 (type: int)
+                  sort order: ++
+                  Map-reduce partition columns: _col1 (type: int), _col2 (type: int)
+                  Statistics: Num rows: 633595212 Data size: 55895953508 Basic stats: COMPLETE Column stats: NONE
+                  value expressions: _col0 (type: int), _col3 (type: int), _col4 (type: decimal(7,2)), _col6 (type: decimal(7,2)), _col7 (type: string), _col9 (type: string), _col10 (type: int)
         Reducer 3 
             Reduce Operator Tree:
               Join Operator
                 condition map:
                      Inner Join 0 to 1
                 keys:
-                  0 _col1 (type: int)
-                  1 _col0 (type: int)
-                outputColumnNames: _col0, _col3, _col4, _col6, _col7, _col9, _col10, _col12, _col14, _col15, _col17, _col18, _col19
-                Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
+                  0 _col1 (type: int), _col2 (type: int)
+                  1 _col0 (type: int), _col9 (type: int)
+                outputColumnNames: _col0, _col3, _col4, _col6, _col7, _col9, _col10, _col13, _col14, _col17, _col21, _col23
+                Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
                 Reduce Output Operator
                   key expressions: _col0 (type: int), _col3 (type: int)
                   sort order: ++
                   Map-reduce partition columns: _col0 (type: int), _col3 (type: int)
-                  Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col4 (type: decimal(7,2)), _col6 (type: decimal(7,2)), _col7 (type: string), _col9 (type: string), _col10 (type: int), _col12 (type: string), _col14 (type: string), _col15 (type: string), _col17 (type: string), _col18 (type: string), _col19 (type: string)
+                  Statistics: Num rows: 696954748 Data size: 61485550191 Basic stats: COMPLETE Column stats: NONE
+                  value expressions: _col4 (type: decimal(7,2)), _col6 (type: decimal(7,2)), _col7 (type: string), _col9 (type: string), _col10 (type: int), _col13 (type: string), _col14 (type: string), _col17 (type: string), _col21 (type: string), _col23 (type: string)
         Reducer 4 
             Reduce Operator Tree:
               Join Operator
@@ -563,61 +568,45 @@ STAGE PLANS:
                 keys:
                   0 _col0 (type: int), _col3 (type: int)
                   1 _col0 (type: int), _col1 (type: int)
-                outputColumnNames: _col4, _col6, _col7, _col9, _col10, _col12, _col14, _col15, _col17, _col18, _col19
-                Statistics: Num rows: 843315281 Data size: 74397518956 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col15 (type: string), _col19 (type: string)
-                  sort order: ++
-                  Map-reduce partition columns: _col15 (type: string), _col19 (type: string)
-                  Statistics: Num rows: 843315281 Data size: 74397518956 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col4 (type: decimal(7,2)), _col6 (type: decimal(7,2)), _col7 (type: string), _col9 (type: string), _col10 (type: int), _col12 (type: string), _col14 (type: string), _col17 (type: string), _col18 (type: string)
-        Reducer 5 
-            Reduce Operator Tree:
-              Join Operator
-                condition map:
-                     Inner Join 0 to 1
-                keys:
-                  0 _col15 (type: string), _col19 (type: string)
-                  1 _col1 (type: string), upper(_col2) (type: string)
-                outputColumnNames: _col4, _col6, _col7, _col9, _col10, _col12, _col14, _col17, _col18, _col22
-                Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
+                outputColumnNames: _col4, _col6, _col7, _col9, _col10, _col13, _col14, _col17, _col21, _col23
+                Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
                 Group By Operator
                   aggregations: sum(_col4)
-                  keys: _col17 (type: string), _col18 (type: string), _col12 (type: string), _col22 (type: string), _col6 (type: decimal(7,2)), _col7 (type: string), _col9 (type: string), _col10 (type: int), _col14 (type: string)
+                  keys: _col13 (type: string), _col14 (type: string), _col21 (type: string), _col6 (type: decimal(7,2)), _col7 (type: string), _col9 (type: string), _col10 (type: int), _col17 (type: string), _col23 (type: string)
                   mode: hash
                   outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9
-                  Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
+                  Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
                   Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string), _col4 (type: decimal(7,2)), _col5 (type: string), _col6 (type: string), _col7 (type: int), _col8 (type: string)
+                    key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: decimal(7,2)), _col4 (type: string), _col5 (type: string), _col6 (type: int), _col7 (type: string), _col8 (type: string)
                     sort order: +++++++++
                     Map-reduce partition columns: _col0 (type: string), _col1 (type: string), _col2 (type: string)
-                    Statistics: Num rows: 927646829 Data size: 81837272625 Basic stats: COMPLETE Column stats: NONE
+                    Statistics: Num rows: 766650239 Data size: 67634106676 Basic stats: COMPLETE Column stats: NONE
                     value expressions: _col9 (type: decimal(17,2))
-        Reducer 6 
+        Reducer 5 
             Execution mode: vectorized
             Local Work:
               Map Reduce Local Work
             Reduce Operator Tree:
               Group By Operator
                 aggregations: sum(VALUE._col0)
-                keys: KEY._col0 (type: string), KEY._col1 (type: string), KEY._col2 (type: string), KEY._col3 (type: string), KEY._col4 (type: decimal(7,2)), KEY._col5 (type: string), KEY._col6 (type: string), KEY._col7 (type: int), KEY._col8 (type: string)
+                keys: KEY._col0 (type: string), KEY._col1 (type: string), KEY._col2 (type: string), KEY._col3 (type: decimal(7,2)), KEY._col4 (type: string), KEY._col5 (type: string), KEY._col6 (type: int), KEY._col7 (type: string), KEY._col8 (type: string)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9
-                Statistics: Num rows: 463823414 Data size: 40918636268 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 383325119 Data size: 33817053293 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
                   expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col9 (type: decimal(17,2))
-                  outputColumnNames: _col1, _col2, _col7, _col9
-                  Statistics: Num rows: 463823414 Data size: 40918636268 Basic stats: COMPLETE Column stats: NONE
+                  outputColumnNames: _col4, _col5, _col7, _col9
+                  Statistics: Num rows: 383325119 Data size: 33817053293 Basic stats: COMPLETE Column stats: NONE
                   Group By Operator
                     aggregations: sum(_col9)
-                    keys: _col1 (type: string), _col2 (type: string), _col7 (type: string)
+                    keys: _col4 (type: string), _col5 (type: string), _col7 (type: string)
                     mode: complete
                     outputColumnNames: _col0, _col1, _col2, _col3
-                    Statistics: Num rows: 231911707 Data size: 20459318134 Basic stats: COMPLETE Column stats: NONE
+                    Statistics: Num rows: 191662559 Data size: 16908526602 Basic stats: COMPLETE Column stats: NONE
                     Select Operator
                       expressions: _col1 (type: string), _col0 (type: string), _col2 (type: string), _col3 (type: decimal(27,2))
                       outputColumnNames: _col0, _col1, _col2, _col3
-                      Statistics: Num rows: 231911707 Data size: 20459318134 Basic stats: COMPLETE Column stats: NONE
+                      Statistics: Num rows: 191662559 Data size: 16908526602 Basic stats: COMPLETE Column stats: NONE
                       Map Join Operator
                         condition map:
                              Inner Join 0 to 1
@@ -627,21 +616,44 @@ STAGE PLANS:
                         outputColumnNames: _col0, _col1, _col2, _col3, _col4
                         input vertices:
                           1 Reducer 18
-                        Statistics: Num rows: 231911707 Data size: 74494745865 Basic stats: COMPLETE Column stats: NONE
+                        Statistics: Num rows: 191662559 Data size: 61565902849 Basic stats: COMPLETE Column stats: NONE
                         Filter Operator
                           predicate: (_col3 > _col4) (type: boolean)
-                          Statistics: Num rows: 77303902 Data size: 24831581847 Basic stats: COMPLETE Column stats: NONE
+                          Statistics: Num rows: 63887519 Data size: 20521967402 Basic stats: COMPLETE Column stats: NONE
                           Select Operator
                             expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: decimal(27,2))
                             outputColumnNames: _col0, _col1, _col2, _col3
-                            Statistics: Num rows: 77303902 Data size: 24831581847 Basic stats: COMPLETE Column stats: NONE
+                            Statistics: Num rows: 63887519 Data size: 20521967402 Basic stats: COMPLETE Column stats: NONE
                             File Output Operator
                               compressed: false
-                              Statistics: Num rows: 77303902 Data size: 24831581847 Basic stats: COMPLETE Column stats: NONE
+                              Statistics: Num rows: 63887519 Data size: 20521967402 Basic stats: COMPLETE Column stats: NONE
                               table:
                                   input format: org.apache.hadoop.mapred.SequenceFileInputFormat
                                   output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                                   serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Reducer 8 
+            Reduce Operator Tree:
+              Join Operator
+                condition map:
+                     Inner Join 0 to 1
+                keys:
+                  0 _col0 (type: int)
+                  1 _col1 (type: int)
+                outputColumnNames: _col1, _col3, _col4, _col5, _col7, _col9, _col11, _col12, _col13
+                Statistics: Num rows: 88000001 Data size: 75681779077 Basic stats: COMPLETE Column stats: NONE
+                Filter Operator
+                  predicate: (_col13 <> upper(_col3)) (type: boolean)
+                  Statistics: Num rows: 88000001 Data size: 75681779077 Basic stats: COMPLETE Column stats: NONE
+                  Select Operator
+                    expressions: _col9 (type: int), _col11 (type: string), _col12 (type: string), _col1 (type: string), _col4 (type: int), _col5 (type: string), _col7 (type: string)
+                    outputColumnNames: _col0, _col2, _col3, _col6, _col9, _col10, _col12
+                    Statistics: Num rows: 88000001 Data size: 75681779077 Basic stats: COMPLETE Column stats: NONE
+                    Reduce Output Operator
+                      key expressions: _col0 (type: int), _col9 (type: int)
+                      sort order: ++
+                      Map-reduce partition columns: _col0 (type: int), _col9 (type: int)
+                      Statistics: Num rows: 88000001 Data size: 75681779077 Basic stats: COMPLETE Column stats: NONE
+                      value expressions: _col2 (type: string), _col3 (type: string), _col6 (type: string), _col10 (type: string), _col12 (type: string)
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out
index baf790e..ace7cf5 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query23.q.out
@@ -1,7 +1,7 @@
-Warning: Shuffle Join MERGEJOIN[589][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 29' is a cross product
-Warning: Shuffle Join MERGEJOIN[590][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 30' is a cross product
-Warning: Shuffle Join MERGEJOIN[592][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 33' is a cross product
-Warning: Shuffle Join MERGEJOIN[593][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 34' is a cross product
+Warning: Shuffle Join MERGEJOIN[593][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 29' is a cross product
+Warning: Shuffle Join MERGEJOIN[594][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 30' is a cross product
+Warning: Shuffle Join MERGEJOIN[596][tables = [$hdt$_1, $hdt$_2]] in Stage 'Reducer 33' is a cross product
+Warning: Shuffle Join MERGEJOIN[597][tables = [$hdt$_1, $hdt$_2, $hdt$_0]] in Stage 'Reducer 34' is a cross product
 PREHOOK: query: explain cbo
 with frequent_ss_items as 
  (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
index 53220d2..1d005b8 100644
--- a/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query24.q.out
@@ -1,4 +1,4 @@
-Warning: Shuffle Join MERGEJOIN[290][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[301][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
 PREHOOK: query: explain cbo
 with ssales as
 (select c_last_name
@@ -23,7 +23,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -79,7 +80,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -115,57 +117,58 @@ CBO PLAN:
 HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
   HiveJoin(condition=[>($3, $4)], joinType=[inner], algorithm=[none], cost=[not available])
     HiveProject(c_last_name=[$1], c_first_name=[$0], s_store_name=[$2], $f3=[$3])
-      HiveAggregate(group=[{1, 2, 7}], agg#0=[sum($9)])
-        HiveProject(ca_state=[$0], c_first_name=[$1], c_last_name=[$2], i_current_price=[$3], i_size=[$4], i_units=[$5], i_manager_id=[$6], s_store_name=[$7], s_state=[$8], $f9=[$9])
-          HiveAggregate(group=[{0, 6, 7, 15, 16, 18, 19, 21, 23}], agg#0=[sum($13)])
-            HiveJoin(condition=[AND(=($8, UPPER($2)), =($24, $1))], joinType=[inner], algorithm=[none], cost=[not available])
-              HiveProject(ca_state=[$8], ca_zip=[$9], ca_country=[$10])
-                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
-                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
-              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
-                  HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2))])
-                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
-                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
-                  HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
-                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($14))])
-                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
-                  HiveJoin(condition=[=($2, $11)], joinType=[inner], algorithm=[none], cost=[not available])
-                    HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
-                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
-                        HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($7), IS NOT NULL($3))])
-                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
-                      HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[CAST(_UTF-16LE'orchid'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_units=[$18], i_manager_id=[$20])
-                        HiveFilter(condition=[AND(=($17, _UTF-16LE'orchid'), IS NOT NULL($0))])
-                          HiveTableScan(table=[[default, item]], table:alias=[item])
-                    HiveProject(s_store_sk=[$0], s_store_name=[$5], s_market_id=[CAST(7):INTEGER], s_state=[$24], s_zip=[$25])
-                      HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($0), IS NOT NULL($25))])
-                        HiveTableScan(table=[[default, store]], table:alias=[store])
+      HiveAggregate(group=[{4, 5, 7}], agg#0=[sum($9)])
+        HiveProject(i_current_price=[$0], i_size=[$1], i_units=[$2], i_manager_id=[$3], c_first_name=[$4], c_last_name=[$5], ca_state=[$6], s_store_name=[$7], s_state=[$8], $f9=[$9])
+          HiveAggregate(group=[{8, 9, 11, 12, 15, 16, 19, 23, 25}], agg#0=[sum($6)])
+            HiveJoin(condition=[AND(=($5, $1), =($2, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2))])
+                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+              HiveJoin(condition=[AND(=($1, $11), =($2, $20))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($7), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[CAST(_UTF-16LE'orchid'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], i_units=[$18], i_manager_id=[$20])
+                    HiveFilter(condition=[AND(=($17, _UTF-16LE'orchid'), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$1], c_first_name=[$2], c_last_name=[$3], c_birth_country=[$4], ca_address_sk=[$5], ca_state=[$6], ca_zip=[$7], ca_country=[$8], s_store_sk=[$9], s_store_name=[$10], s_market_id=[$11], s_state=[$12], s_zip=[$13])
+                  HiveJoin(condition=[AND(=($1, $5), <>($4, UPPER($8)))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+                        HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                    HiveJoin(condition=[=($8, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_zip=[$9], ca_country=[$10])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($9))])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                      HiveProject(s_store_sk=[$0], s_store_name=[$5], s_market_id=[CAST(7):INTEGER], s_state=[$24], s_zip=[$25])
+                        HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($0), IS NOT NULL($25))])
+                          HiveTableScan(table=[[default, store]], table:alias=[store])
     HiveProject(_o__c0=[*(0.05, /($0, $1))])
       HiveAggregate(group=[{}], agg#0=[sum($10)], agg#1=[count($10)])
-        HiveProject(c_first_name=[$0], c_last_name=[$1], s_store_name=[$2], s_state=[$3], i_current_price=[$4], i_size=[$5], i_color=[$6], i_units=[$7], i_manager_id=[$8], ca_state=[$9], $f10=[$10])
-          HiveAggregate(group=[{3, 4, 12, 14, 17, 18, 19, 20, 21, 22}], agg#0=[sum($10)])
-            HiveJoin(condition=[AND(=($5, UPPER($24)), =($15, $23))], joinType=[inner], algorithm=[none], cost=[not available])
-              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
-                  HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2))])
-                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
-                HiveJoin(condition=[=($4, $14)], joinType=[inner], algorithm=[none], cost=[not available])
-                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
-                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
-                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($14))])
+        HiveProject(c_first_name=[$0], c_last_name=[$1], ca_state=[$2], s_store_name=[$3], s_state=[$4], i_current_price=[$5], i_size=[$6], i_color=[$7], i_units=[$8], i_manager_id=[$9], $f10=[$10])
+          HiveAggregate(group=[{7, 8, 11, 15, 17, 20, 21, 22, 23, 24}], agg#0=[sum($4)])
+            HiveJoin(condition=[AND(=($3, $26), =($0, $25))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($0, $19)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[AND(=($1, $5), =($2, $14))], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($7), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveJoin(condition=[AND(=($1, $5), <>($4, UPPER($8)))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
                         HiveTableScan(table=[[default, customer]], table:alias=[customer])
-                    HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
-                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
-                        HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2), IS NOT NULL($7), IS NOT NULL($3))])
-                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveJoin(condition=[=($8, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_zip=[$9], ca_country=[$10])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($9))])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
                       HiveProject(s_store_sk=[$0], s_store_name=[$5], s_market_id=[CAST(7):INTEGER], s_state=[$24], s_zip=[$25])
                         HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($0), IS NOT NULL($25))])
                           HiveTableScan(table=[[default, store]], table:alias=[store])
-                  HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[$17], i_units=[$18], i_manager_id=[$20])
-                    HiveFilter(condition=[IS NOT NULL($0)])
-                      HiveTableScan(table=[[default, item]], table:alias=[item])
-              HiveProject(ca_state=[$8], ca_zip=[$9], ca_country=[$10])
-                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
-                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[$17], i_units=[$18], i_manager_id=[$20])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                HiveFilter(condition=[AND(IS NOT NULL($9), IS NOT NULL($2))])
+                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out
index 34cc51b..0801f34 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query24.q.out
@@ -1,4 +1,4 @@
-Warning: Shuffle Join MERGEJOIN[287][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 8' is a cross product
+Warning: Shuffle Join MERGEJOIN[298][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 6' is a cross product
 PREHOOK: query: explain cbo
 with ssales as
 (select c_last_name
@@ -23,7 +23,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -79,7 +80,8 @@ where ss_ticket_number = sr_ticket_number
   and ss_customer_sk = c_customer_sk
   and ss_item_sk = i_item_sk
   and ss_store_sk = s_store_sk
-  and c_birth_country = upper(ca_country)
+  and c_current_addr_sk = ca_address_sk
+  and c_birth_country <> upper(ca_country)
   and s_zip = ca_zip
 and s_market_id=7
 group by c_last_name
@@ -115,54 +117,55 @@ CBO PLAN:
 HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
   HiveJoin(condition=[>($3, $4)], joinType=[inner], algorithm=[none], cost=[not available])
     HiveProject(c_last_name=[$1], c_first_name=[$0], s_store_name=[$2], $f3=[$3])
-      HiveAggregate(group=[{1, 2, 7}], agg#0=[sum($9)])
-        HiveProject(ca_state=[$0], c_first_name=[$1], c_last_name=[$2], i_current_price=[$3], i_size=[$4], i_units=[$5], i_manager_id=[$6], s_store_name=[$7], s_state=[$8], $f9=[$9])
-          HiveAggregate(group=[{0, 6, 7, 15, 16, 17, 18, 20, 21}], agg#0=[sum($13)])
-            HiveJoin(condition=[AND(=($8, $2), =($22, $1))], joinType=[inner], algorithm=[none], cost=[not available])
-              HiveProject(ca_state=[$8], ca_zip=[$9], UPPER=[UPPER($10)])
-                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
-                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
-              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
-                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
-                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
-                  HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
-                    HiveFilter(condition=[IS NOT NULL($14)])
-                      HiveTableScan(table=[[default, customer]], table:alias=[customer])
-                  HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
-                    HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
-                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
-                        HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($3))])
-                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
-                      HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_units=[$18], i_manager_id=[$20])
-                        HiveFilter(condition=[=($17, _UTF-16LE'orchid')])
-                          HiveTableScan(table=[[default, item]], table:alias=[item])
-                    HiveProject(s_store_sk=[$0], s_store_name=[$5], s_state=[$24], s_zip=[$25])
-                      HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($25))])
-                        HiveTableScan(table=[[default, store]], table:alias=[store])
-    HiveProject(_o__c0=[*(0.05, /($0, $1))])
-      HiveAggregate(group=[{}], agg#0=[sum($10)], agg#1=[count($10)])
-        HiveProject(c_first_name=[$0], c_last_name=[$1], s_store_name=[$2], s_state=[$3], i_current_price=[$4], i_size=[$5], i_color=[$6], i_units=[$7], i_manager_id=[$8], ca_state=[$9], $f10=[$10])
-          HiveAggregate(group=[{3, 4, 12, 13, 16, 17, 18, 19, 20, 21}], agg#0=[sum($10)])
-            HiveJoin(condition=[AND(=($5, $23), =($14, $22))], joinType=[inner], algorithm=[none], cost=[not available])
-              HiveJoin(condition=[AND(=($9, $1), =($6, $0))], joinType=[inner], algorithm=[none], cost=[not available])
-                HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
-                  HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
-                HiveJoin(condition=[=($4, $13)], joinType=[inner], algorithm=[none], cost=[not available])
-                  HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
-                    HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
-                      HiveFilter(condition=[IS NOT NULL($14)])
+      HiveAggregate(group=[{4, 5, 7}], agg#0=[sum($9)])
+        HiveProject(i_current_price=[$0], i_size=[$1], i_units=[$2], i_manager_id=[$3], c_first_name=[$4], c_last_name=[$5], ca_state=[$6], s_store_name=[$7], s_state=[$8], $f9=[$9])
+          HiveAggregate(group=[{8, 9, 10, 11, 14, 15, 18, 22, 23}], agg#0=[sum($6)])
+            HiveJoin(condition=[AND(=($5, $1), =($2, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+              HiveJoin(condition=[AND(=($1, $10), =($2, $19))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_units=[$18], i_manager_id=[$20])
+                    HiveFilter(condition=[=($17, _UTF-16LE'orchid')])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$1], c_first_name=[$2], c_last_name=[$3], c_birth_country=[$4], ca_address_sk=[$5], ca_state=[$6], ca_zip=[$7], UPPER=[$8], s_store_sk=[$9], s_store_name=[$10], s_state=[$11], s_zip=[$12])
+                  HiveJoin(condition=[AND(=($1, $5), <>($4, $8))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                      HiveFilter(condition=[IS NOT NULL($4)])
                         HiveTableScan(table=[[default, customer]], table:alias=[customer])
-                    HiveJoin(condition=[=($2, $5)], joinType=[inner], algorithm=[none], cost=[not available])
-                      HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
-                        HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($3))])
-                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveJoin(condition=[=($7, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_zip=[$9], UPPER=[UPPER($10)])
+                        HiveFilter(condition=[IS NOT NULL($9)])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
                       HiveProject(s_store_sk=[$0], s_store_name=[$5], s_state=[$24], s_zip=[$25])
                         HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($25))])
                           HiveTableScan(table=[[default, store]], table:alias=[store])
-                  HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[$17], i_units=[$18], i_manager_id=[$20])
-                    HiveTableScan(table=[[default, item]], table:alias=[item])
-              HiveProject(ca_state=[$8], ca_zip=[$9], UPPER=[UPPER($10)])
-                HiveFilter(condition=[AND(IS NOT NULL(UPPER($10)), IS NOT NULL($9))])
-                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+    HiveProject(_o__c0=[*(0.05, /($0, $1))])
+      HiveAggregate(group=[{}], agg#0=[sum($10)], agg#1=[count($10)])
+        HiveProject(c_first_name=[$0], c_last_name=[$1], ca_state=[$2], s_store_name=[$3], s_state=[$4], i_current_price=[$5], i_size=[$6], i_color=[$7], i_units=[$8], i_manager_id=[$9], $f10=[$10])
+          HiveAggregate(group=[{9, 10, 13, 17, 18, 21, 22, 23, 24, 25}], agg#0=[sum($6)])
+            HiveJoin(condition=[AND(=($5, $1), =($2, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+              HiveJoin(condition=[=($0, $18)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[AND(=($17, $12), =($2, $14))], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($1, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($3))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveJoin(condition=[AND(=($1, $5), <>($4, $8))], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9], c_birth_country=[$14])
+                        HiveFilter(condition=[IS NOT NULL($4)])
+                          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8], ca_zip=[$9], UPPER=[UPPER($10)])
+                        HiveFilter(condition=[IS NOT NULL($9)])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                  HiveProject(s_store_sk=[$0], s_store_name=[$5], s_state=[$24], s_zip=[$25])
+                    HiveFilter(condition=[AND(=($10, 7), IS NOT NULL($25))])
+                      HiveTableScan(table=[[default, store]], table:alias=[store])
+                HiveProject(i_item_sk=[$0], i_current_price=[$5], i_size=[$15], i_color=[$17], i_units=[$18], i_manager_id=[$20])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
 

http://git-wip-us.apache.org/repos/asf/hive/blob/3cbc13e9/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out
index ef53060..cbf372a 100644
--- a/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query6.q.out
@@ -1,4 +1,4 @@
-Warning: Map Join MAPJOIN[172][bigTable=?] in task 'Reducer 15' is a cross product
+Warning: Map Join MAPJOIN[170][bigTable=?] in task 'Reducer 15' is a cross product
 PREHOOK: query: explain cbo
 select  a.ca_state state, count(*) cnt
  from customer_address a


[04/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query81.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query81.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query81.q.out
new file mode 100644
index 0000000..bcfe19e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query81.q.out
@@ -0,0 +1,220 @@
+PREHOOK: query: explain
+with customer_total_return as
+ (select cr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(cr_return_amt_inc_tax) as ctr_total_return
+ from catalog_returns
+     ,date_dim
+     ,customer_address
+ where cr_returned_date_sk = d_date_sk 
+   and d_year =1998
+   and cr_returning_addr_sk = ca_address_sk 
+ group by cr_returning_customer_sk
+         ,ca_state )
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with customer_total_return as
+ (select cr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(cr_return_amt_inc_tax) as ctr_total_return
+ from catalog_returns
+     ,date_dim
+     ,customer_address
+ where cr_returned_date_sk = d_date_sk 
+   and d_year =1998
+   and cr_returning_addr_sk = ca_address_sk 
+ group by cr_returning_customer_sk
+         ,ca_state )
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 13 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 14 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 12 <- Map 15 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 5 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 7 <- Map 14 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 8 <- Map 15 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 4 vectorized
+      File Output Operator [FS_210]
+        Select Operator [SEL_209] (rows=100 width=1506)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"]
+          Limit [LIM_208] (rows=100 width=1420)
+            Number of rows:100
+            Select Operator [SEL_207] (rows=1577696 width=1418)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+            <-Reducer 3 [SIMPLE_EDGE]
+              SHUFFLE [RS_63]
+                Select Operator [SEL_62] (rows=1577696 width=1418)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+                  Merge Join Operator [MERGEJOIN_178] (rows=1577696 width=1418)
+                    Conds:RS_59._col0=RS_60._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16","_col19"]
+                  <-Reducer 10 [SIMPLE_EDGE]
+                    SHUFFLE [RS_60]
+                      PartitionCols:_col0
+                      Select Operator [SEL_55] (rows=1609248 width=227)
+                        Output:["_col0","_col2"]
+                        Filter Operator [FIL_54] (rows=1609248 width=227)
+                          predicate:(_col2 > _col3)
+                          Merge Join Operator [MERGEJOIN_177] (rows=4827746 width=227)
+                            Conds:RS_201._col1=RS_206._col1(Inner),Output:["_col0","_col2","_col3"]
+                          <-Reducer 13 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_206]
+                              PartitionCols:_col1
+                              Select Operator [SEL_205] (rows=12 width=198)
+                                Output:["_col0","_col1"]
+                                Group By Operator [GBY_204] (rows=12 width=206)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(_col2)","count(_col2)"],keys:_col0
+                                  Select Operator [SEL_203] (rows=5266632 width=201)
+                                    Output:["_col0","_col2"]
+                                    Group By Operator [GBY_202] (rows=5266632 width=201)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                    <-Reducer 12 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_43]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_42] (rows=8749496 width=201)
+                                          Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col6, _col1
+                                          Merge Join Operator [MERGEJOIN_176] (rows=8749496 width=194)
+                                            Conds:RS_38._col2=RS_198._col0(Inner),Output:["_col1","_col3","_col6"]
+                                          <-Map 15 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_198]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_196] (rows=40000000 width=90)
+                                                Output:["_col0","_col1"]
+                                                Filter Operator [FIL_195] (rows=40000000 width=90)
+                                                  predicate:ca_state is not null
+                                                  TableScan [TS_12] (rows=40000000 width=90)
+                                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
+                                          <-Reducer 11 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_38]
+                                              PartitionCols:_col2
+                                              Merge Join Operator [MERGEJOIN_175] (rows=8749496 width=112)
+                                                Conds:RS_190._col0=RS_194._col0(Inner),Output:["_col1","_col2","_col3"]
+                                              <-Map 14 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_194]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_192] (rows=652 width=4)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_191] (rows=652 width=8)
+                                                      predicate:(d_year = 1998)
+                                                      TableScan [TS_9] (rows=73049 width=8)
+                                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                              <-Map 6 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_190]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_188] (rows=28221532 width=121)
+                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                    Filter Operator [FIL_186] (rows=28221532 width=121)
+                                                      predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null)
+                                                      TableScan [TS_6] (rows=28798881 width=121)
+                                                        default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_returned_date_sk","cr_returning_customer_sk","cr_returning_addr_sk","cr_return_amt_inc_tax"]
+                          <-Reducer 9 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_201]
+                              PartitionCols:_col1
+                              Select Operator [SEL_200] (rows=4827746 width=201)
+                                Output:["_col0","_col1","_col2"]
+                                Group By Operator [GBY_199] (rows=4827746 width=201)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                <-Reducer 8 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_23]
+                                    PartitionCols:_col0, _col1
+                                    Group By Operator [GBY_22] (rows=8574602 width=201)
+                                      Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col6, _col1
+                                      Merge Join Operator [MERGEJOIN_174] (rows=8574602 width=194)
+                                        Conds:RS_18._col2=RS_197._col0(Inner),Output:["_col1","_col3","_col6"]
+                                      <-Map 15 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_197]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_196]
+                                      <-Reducer 7 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_18]
+                                          PartitionCols:_col2
+                                          Merge Join Operator [MERGEJOIN_173] (rows=8574602 width=112)
+                                            Conds:RS_189._col0=RS_193._col0(Inner),Output:["_col1","_col2","_col3"]
+                                          <-Map 14 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_193]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_192]
+                                          <-Map 6 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_189]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_187] (rows=27657410 width=121)
+                                                Output:["_col0","_col1","_col2","_col3"]
+                                                Filter Operator [FIL_185] (rows=27657410 width=121)
+                                                  predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null and cr_returning_customer_sk is not null)
+                                                   Please refer to the previous TableScan [TS_6]
+                  <-Reducer 2 [SIMPLE_EDGE]
+                    SHUFFLE [RS_59]
+                      PartitionCols:_col0
+                      Merge Join Operator [MERGEJOIN_172] (rows=1568628 width=1310)
+                        Conds:RS_181._col2=RS_184._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16"]
+                      <-Map 1 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_181]
+                          PartitionCols:_col2
+                          Select Operator [SEL_180] (rows=80000000 width=375)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                            Filter Operator [FIL_179] (rows=80000000 width=375)
+                              predicate:c_current_addr_sk is not null
+                              TableScan [TS_0] (rows=80000000 width=375)
+                                default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_customer_id","c_current_addr_sk","c_salutation","c_first_name","c_last_name"]
+                      <-Map 5 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_184]
+                          PartitionCols:_col0
+                          Select Operator [SEL_183] (rows=784314 width=941)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+                            Filter Operator [FIL_182] (rows=784314 width=1027)
+                              predicate:(ca_state = 'IL')
+                              TableScan [TS_3] (rows=40000000 width=1027)
+                                default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_street_number","ca_street_name","ca_street_type","ca_suite_number","ca_city","ca_county","ca_state","ca_zip","ca_country","ca_gmt_offset","ca_location_type"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query82.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query82.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query82.q.out
new file mode 100644
index 0000000..1344b94
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query82.q.out
@@ -0,0 +1,146 @@
+PREHOOK: query: explain
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, store_sales
+ where i_current_price between 30 and 30+30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
+ and i_manufact_id in (437,129,727,663)
+ and inv_quantity_on_hand between 100 and 500
+ and ss_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, store_sales
+ where i_current_price between 30 and 30+30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
+ and i_manufact_id in (437,129,727,663)
+ and inv_quantity_on_hand between 100 and 500
+ and ss_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (ONE_TO_ONE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 11 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_102]
+        Limit [LIM_101] (rows=1 width=396)
+          Number of rows:100
+          Select Operator [SEL_100] (rows=1 width=396)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_99]
+              Group By Operator [GBY_98] (rows=1 width=396)
+                Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_23]
+                  PartitionCols:_col0, _col1, _col2
+                  Group By Operator [GBY_22] (rows=2 width=396)
+                    Output:["_col0","_col1","_col2"],keys:_col2, _col3, _col4
+                    Top N Key Operator [TNK_42] (rows=2871 width=396)
+                      keys:_col2, _col3, _col4,sort order:+++,top n:100
+                      Merge Join Operator [MERGEJOIN_78] (rows=2871 width=396)
+                        Conds:RS_18._col1=RS_19._col1(Inner),Output:["_col2","_col3","_col4"]
+                      <-Reducer 9 [SIMPLE_EDGE]
+                        SHUFFLE [RS_19]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_77] (rows=463969 width=4)
+                            Conds:RS_89._col0=RS_92._col0(Inner),Output:["_col1"]
+                          <-Map 11 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_92]
+                              PartitionCols:_col0
+                              Select Operator [SEL_91] (rows=8116 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_90] (rows=8116 width=98)
+                                  predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'2002-05-30 00:00:00' AND TIMESTAMP'2002-07-29 00:00:00'
+                                  TableScan [TS_8] (rows=73049 width=98)
+                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                          <-Map 8 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_89]
+                              PartitionCols:_col0
+                              Select Operator [SEL_88] (rows=4176000 width=8)
+                                Output:["_col0","_col1"]
+                                Filter Operator [FIL_87] (rows=4176000 width=11)
+                                  predicate:inv_quantity_on_hand BETWEEN 100 AND 500
+                                  TableScan [TS_5] (rows=37584000 width=11)
+                                    default@inventory,inventory,Tbl:COMPLETE,Col:COMPLETE,Output:["inv_date_sk","inv_item_sk","inv_quantity_on_hand"]
+                      <-Reducer 2 [ONE_TO_ONE_EDGE]
+                        FORWARD [RS_18]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_76] (rows=3564040 width=400)
+                            Conds:RS_97._col0=RS_81._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_81]
+                              PartitionCols:_col0
+                              Select Operator [SEL_80] (rows=297 width=400)
+                                Output:["_col0","_col1","_col2","_col3"]
+                                Filter Operator [FIL_79] (rows=297 width=404)
+                                  predicate:((i_manufact_id) IN (437, 129, 727, 663) and i_current_price BETWEEN 30 AND 60)
+                                  TableScan [TS_2] (rows=462000 width=403)
+                                    default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_item_desc","i_current_price","i_manufact_id"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_97]
+                              PartitionCols:_col0
+                              Select Operator [SEL_96] (rows=575995635 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_95] (rows=575995635 width=4)
+                                  predicate:((ss_item_sk BETWEEN DynamicValue(RS_16_item_i_item_sk_min) AND DynamicValue(RS_16_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_16_item_i_item_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_19_inventory_inv_item_sk_min) AND DynamicValue(RS_19_inventory_inv_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_19_inventory_inv_item_sk_bloom_filter))))
+                                  TableScan [TS_0] (rows=575995635 width=4)
+                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_item_sk"]
+                                  <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_94]
+                                      Group By Operator [GBY_93] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Reducer 9 [CUSTOM_SIMPLE_EDGE]
+                                        SHUFFLE [RS_50]
+                                          Group By Operator [GBY_49] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_48] (rows=463969 width=8)
+                                              Output:["_col0"]
+                                               Please refer to the previous Merge Join Operator [MERGEJOIN_77]
+                                  <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_86]
+                                      Group By Operator [GBY_85] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_84]
+                                          Group By Operator [GBY_83] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_82] (rows=297 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_80]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query83.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query83.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query83.q.out
new file mode 100644
index 0000000..4c9fc68
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query83.q.out
@@ -0,0 +1,338 @@
+PREHOOK: query: explain
+with sr_items as
+ (select i_item_id item_id,
+        sum(sr_return_quantity) sr_item_qty
+ from store_returns,
+      item,
+      date_dim
+ where sr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   sr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+        sum(cr_return_quantity) cr_item_qty
+ from catalog_returns,
+      item,
+      date_dim
+ where cr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   cr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+        sum(wr_return_quantity) wr_item_qty
+ from web_returns,
+      item,
+      date_dim
+ where wr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+		where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   wr_returned_date_sk   = d_date_sk
+ group by i_item_id)
+  select  sr_items.item_id
+       ,sr_item_qty
+       ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev
+       ,cr_item_qty
+       ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev
+       ,wr_item_qty
+       ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev
+       ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average
+ from sr_items
+     ,cr_items
+     ,wr_items
+ where sr_items.item_id=cr_items.item_id
+   and sr_items.item_id=wr_items.item_id 
+ order by sr_items.item_id
+         ,sr_item_qty
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@web_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with sr_items as
+ (select i_item_id item_id,
+        sum(sr_return_quantity) sr_item_qty
+ from store_returns,
+      item,
+      date_dim
+ where sr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   sr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+        sum(cr_return_quantity) cr_item_qty
+ from catalog_returns,
+      item,
+      date_dim
+ where cr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   cr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+        sum(wr_return_quantity) wr_item_qty
+ from web_returns,
+      item,
+      date_dim
+ where wr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+		where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   wr_returned_date_sk   = d_date_sk
+ group by i_item_id)
+  select  sr_items.item_id
+       ,sr_item_qty
+       ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev
+       ,cr_item_qty
+       ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev
+       ,wr_item_qty
+       ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev
+       ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average
+ from sr_items
+     ,cr_items
+     ,wr_items
+ where sr_items.item_id=cr_items.item_id
+   and sr_items.item_id=wr_items.item_id 
+ order by sr_items.item_id
+         ,sr_item_qty
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 16 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Map 22 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE), Reducer 19 (ONE_TO_ONE_EDGE)
+Reducer 18 <- Map 17 (SIMPLE_EDGE), Map 20 (SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 16 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 11 (ONE_TO_ONE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 14 (ONE_TO_ONE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 21 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_397]
+        Limit [LIM_396] (rows=100 width=260)
+          Number of rows:100
+          Select Operator [SEL_395] (rows=130021 width=260)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_124]
+              Select Operator [SEL_123] (rows=130021 width=260)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                Merge Join Operator [MERGEJOIN_360] (rows=130021 width=148)
+                  Conds:RS_120._col0=RS_394._col0(Inner),Output:["_col0","_col1","_col2","_col4","_col5","_col7","_col8"]
+                <-Reducer 14 [ONE_TO_ONE_EDGE] vectorized
+                  FORWARD [RS_394]
+                    PartitionCols:_col0
+                    Select Operator [SEL_393] (rows=130021 width=116)
+                      Output:["_col0","_col1","_col2"]
+                      Group By Operator [GBY_392] (rows=130021 width=108)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 13 [SIMPLE_EDGE]
+                        SHUFFLE [RS_114]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_113] (rows=390063 width=108)
+                            Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col4
+                            Merge Join Operator [MERGEJOIN_358] (rows=5752600 width=103)
+                              Conds:RS_109._col0=RS_110._col0(Inner),Output:["_col2","_col4"]
+                            <-Reducer 16 [SIMPLE_EDGE]
+                              SHUFFLE [RS_110]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_349] (rows=5070 width=4)
+                                  Conds:RS_370._col1=RS_379._col0(Inner),Output:["_col0"]
+                                <-Map 15 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_370]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_369] (rows=73049 width=98)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_368] (rows=73049 width=98)
+                                        predicate:d_date is not null
+                                        TableScan [TS_5] (rows=73049 width=98)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                <-Reducer 19 [ONE_TO_ONE_EDGE] vectorized
+                                  FORWARD [RS_379]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_378] (rows=5070 width=94)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Reducer 18 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_21]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_20] (rows=5070 width=94)
+                                          Output:["_col0"],keys:_col0
+                                          Merge Join Operator [MERGEJOIN_348] (rows=10141 width=94)
+                                            Conds:RS_373._col1=RS_377._col0(Left Semi),Output:["_col0"]
+                                          <-Map 17 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_373]
+                                              PartitionCols:_col1
+                                              Select Operator [SEL_372] (rows=73049 width=98)
+                                                Output:["_col0","_col1"]
+                                                Filter Operator [FIL_371] (rows=73049 width=98)
+                                                  predicate:(d_date is not null and d_week_seq is not null)
+                                                  TableScan [TS_8] (rows=73049 width=98)
+                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date","d_week_seq"]
+                                          <-Map 20 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_377]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_376] (rows=1826 width=4)
+                                                Output:["_col0"],keys:_col0
+                                                Select Operator [SEL_375] (rows=3652 width=4)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_374] (rows=3652 width=98)
+                                                    predicate:((d_date) IN ('1998-01-02', '1998-10-15', '1998-11-10') and d_week_seq is not null)
+                                                    TableScan [TS_11] (rows=73049 width=98)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date","d_week_seq"]
+                            <-Reducer 12 [SIMPLE_EDGE]
+                              SHUFFLE [RS_109]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_353] (rows=13749816 width=107)
+                                  Conds:RS_391._col1=RS_367._col0(Inner),Output:["_col0","_col2","_col4"]
+                                <-Map 8 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_367]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_364] (rows=462000 width=104)
+                                      Output:["_col0","_col1"]
+                                      TableScan [TS_3] (rows=462000 width=104)
+                                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                                <-Map 22 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_391]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_390] (rows=13749816 width=11)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_389] (rows=13749816 width=11)
+                                        predicate:wr_returned_date_sk is not null
+                                        TableScan [TS_78] (rows=14398467 width=11)
+                                          default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_returned_date_sk","wr_item_sk","wr_return_quantity"]
+                <-Reducer 5 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_120]
+                    PartitionCols:_col0
+                    Merge Join Operator [MERGEJOIN_359] (rows=134905 width=132)
+                      Conds:RS_382._col0=RS_388._col0(Inner),Output:["_col0","_col1","_col2","_col4","_col5"]
+                    <-Reducer 11 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_388]
+                        PartitionCols:_col0
+                        Select Operator [SEL_387] (rows=141711 width=116)
+                          Output:["_col0","_col1","_col2"]
+                          Group By Operator [GBY_386] (rows=141711 width=108)
+                            Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                          <-Reducer 10 [SIMPLE_EDGE]
+                            SHUFFLE [RS_75]
+                              PartitionCols:_col0
+                              Group By Operator [GBY_74] (rows=462000 width=108)
+                                Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col4
+                                Merge Join Operator [MERGEJOIN_357] (rows=25343167 width=103)
+                                  Conds:RS_70._col0=RS_71._col0(Inner),Output:["_col2","_col4"]
+                                <-Reducer 16 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_71]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Merge Join Operator [MERGEJOIN_349]
+                                <-Reducer 9 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_70]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_350] (rows=55578005 width=107)
+                                      Conds:RS_385._col1=RS_366._col0(Inner),Output:["_col0","_col2","_col4"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_366]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_364]
+                                    <-Map 21 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_385]
+                                        PartitionCols:_col1
+                                        Select Operator [SEL_384] (rows=55578005 width=11)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_383] (rows=55578005 width=11)
+                                            predicate:sr_returned_date_sk is not null
+                                            TableScan [TS_39] (rows=57591150 width=11)
+                                              default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_returned_date_sk","sr_item_sk","sr_return_quantity"]
+                    <-Reducer 4 [ONE_TO_ONE_EDGE] vectorized
+                      FORWARD [RS_382]
+                        PartitionCols:_col0
+                        Select Operator [SEL_381] (rows=134905 width=116)
+                          Output:["_col0","_col1","_col2"]
+                          Group By Operator [GBY_380] (rows=134905 width=108)
+                            Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                          <-Reducer 3 [SIMPLE_EDGE]
+                            SHUFFLE [RS_36]
+                              PartitionCols:_col0
+                              Group By Operator [GBY_35] (rows=462000 width=108)
+                                Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col4
+                                Merge Join Operator [MERGEJOIN_356] (rows=12501392 width=103)
+                                  Conds:RS_31._col0=RS_32._col0(Inner),Output:["_col2","_col4"]
+                                <-Reducer 16 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_32]
+                                    PartitionCols:_col0
+                                     Please refer to the previous Merge Join Operator [MERGEJOIN_349]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_31]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_347] (rows=28798881 width=107)
+                                      Conds:RS_363._col1=RS_365._col0(Inner),Output:["_col0","_col2","_col4"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_365]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_364]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_363]
+                                        PartitionCols:_col1
+                                        Select Operator [SEL_362] (rows=28798881 width=11)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_361] (rows=28798881 width=11)
+                                            predicate:cr_returned_date_sk is not null
+                                            TableScan [TS_0] (rows=28798881 width=11)
+                                              default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_returned_date_sk","cr_item_sk","cr_return_quantity"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query84.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query84.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query84.q.out
new file mode 100644
index 0000000..8feac3e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query84.q.out
@@ -0,0 +1,153 @@
+PREHOOK: query: explain
+select  c_customer_id as customer_id
+       ,c_last_name || ', ' || c_first_name as customername
+ from customer
+     ,customer_address
+     ,customer_demographics
+     ,household_demographics
+     ,income_band
+     ,store_returns
+ where ca_city	        =  'Hopewell'
+   and c_current_addr_sk = ca_address_sk
+   and ib_lower_bound   >=  32287
+   and ib_upper_bound   <=  32287 + 50000
+   and ib_income_band_sk = hd_income_band_sk
+   and cd_demo_sk = c_current_cdemo_sk
+   and hd_demo_sk = c_current_hdemo_sk
+   and sr_cdemo_sk = cd_demo_sk
+ order by c_customer_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@income_band
+PREHOOK: Input: default@store_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  c_customer_id as customer_id
+       ,c_last_name || ', ' || c_first_name as customername
+ from customer
+     ,customer_address
+     ,customer_demographics
+     ,household_demographics
+     ,income_band
+     ,store_returns
+ where ca_city	        =  'Hopewell'
+   and c_current_addr_sk = ca_address_sk
+   and ib_lower_bound   >=  32287
+   and ib_upper_bound   <=  32287 + 50000
+   and ib_income_band_sk = hd_income_band_sk
+   and cd_demo_sk = c_current_cdemo_sk
+   and hd_demo_sk = c_current_hdemo_sk
+   and sr_cdemo_sk = cd_demo_sk
+ order by c_customer_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@income_band
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 11 <- Map 10 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 5 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (ONE_TO_ONE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 11 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 4 vectorized
+      File Output Operator [FS_139]
+        Limit [LIM_138] (rows=100 width=384)
+          Number of rows:100
+          Select Operator [SEL_137] (rows=255285 width=384)
+            Output:["_col0","_col1"]
+          <-Reducer 3 [SIMPLE_EDGE]
+            SHUFFLE [RS_35]
+              Select Operator [SEL_34] (rows=255285 width=384)
+                Output:["_col1","_col2"]
+                Merge Join Operator [MERGEJOIN_119] (rows=255285 width=284)
+                  Conds:RS_31._col1=RS_32._col1(Inner),Output:["_col2","_col6"]
+                <-Reducer 2 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_31]
+                    PartitionCols:_col1
+                    Merge Join Operator [MERGEJOIN_115] (rows=56363634 width=4)
+                      Conds:RS_122._col0=RS_124._col0(Inner),Output:["_col1"]
+                    <-Map 1 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_122]
+                        PartitionCols:_col0
+                        Select Operator [SEL_121] (rows=55577698 width=3)
+                          Output:["_col0"]
+                          Filter Operator [FIL_120] (rows=55577698 width=3)
+                            predicate:sr_cdemo_sk is not null
+                            TableScan [TS_0] (rows=57591150 width=3)
+                              default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_cdemo_sk"]
+                    <-Map 5 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_124]
+                        PartitionCols:_col0
+                        Select Operator [SEL_123] (rows=1861800 width=4)
+                          Output:["_col0"]
+                          TableScan [TS_3] (rows=1861800 width=4)
+                            default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk"]
+                <-Reducer 8 [SIMPLE_EDGE]
+                  SHUFFLE [RS_32]
+                    PartitionCols:_col1
+                    Merge Join Operator [MERGEJOIN_118] (rows=8315 width=284)
+                      Conds:RS_24._col2=RS_25._col0(Inner),Output:["_col0","_col1","_col4"]
+                    <-Reducer 11 [SIMPLE_EDGE]
+                      SHUFFLE [RS_25]
+                        PartitionCols:_col0
+                        Merge Join Operator [MERGEJOIN_117] (rows=721 width=4)
+                          Conds:RS_133._col1=RS_136._col0(Inner),Output:["_col0"]
+                        <-Map 10 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_133]
+                            PartitionCols:_col1
+                            Select Operator [SEL_132] (rows=7200 width=8)
+                              Output:["_col0","_col1"]
+                              Filter Operator [FIL_131] (rows=7200 width=8)
+                                predicate:hd_income_band_sk is not null
+                                TableScan [TS_11] (rows=7200 width=8)
+                                  default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_income_band_sk"]
+                        <-Map 12 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_136]
+                            PartitionCols:_col0
+                            Select Operator [SEL_135] (rows=2 width=4)
+                              Output:["_col0"]
+                              Filter Operator [FIL_134] (rows=2 width=12)
+                                predicate:((ib_lower_bound >= 32287) and (ib_upper_bound <= 82287))
+                                TableScan [TS_14] (rows=20 width=12)
+                                  default@income_band,income_band,Tbl:COMPLETE,Col:COMPLETE,Output:["ib_income_band_sk","ib_lower_bound","ib_upper_bound"]
+                    <-Reducer 7 [SIMPLE_EDGE]
+                      SHUFFLE [RS_24]
+                        PartitionCols:_col2
+                        Merge Join Operator [MERGEJOIN_116] (rows=83148 width=284)
+                          Conds:RS_127._col3=RS_130._col0(Inner),Output:["_col0","_col1","_col2","_col4"]
+                        <-Map 6 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_127]
+                            PartitionCols:_col3
+                            Select Operator [SEL_126] (rows=74500295 width=295)
+                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                              Filter Operator [FIL_125] (rows=74500295 width=291)
+                                predicate:(c_current_addr_sk is not null and c_current_cdemo_sk is not null and c_current_hdemo_sk is not null)
+                                TableScan [TS_5] (rows=80000000 width=291)
+                                  default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_id","c_current_cdemo_sk","c_current_hdemo_sk","c_current_addr_sk","c_first_name","c_last_name"]
+                        <-Map 9 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_130]
+                            PartitionCols:_col0
+                            Select Operator [SEL_129] (rows=44643 width=4)
+                              Output:["_col0"]
+                              Filter Operator [FIL_128] (rows=44643 width=97)
+                                predicate:(ca_city = 'Hopewell')
+                                TableScan [TS_8] (rows=40000000 width=97)
+                                  default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_city"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query85.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query85.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query85.q.out
new file mode 100644
index 0000000..ec5e4cf
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query85.q.out
@@ -0,0 +1,320 @@
+PREHOOK: query: explain
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
+ from web_sales, web_returns, web_page, customer_demographics cd1,
+      customer_demographics cd2, customer_address, date_dim, reason 
+ where ws_web_page_sk = wp_web_page_sk
+   and ws_item_sk = wr_item_sk
+   and ws_order_number = wr_order_number
+   and ws_sold_date_sk = d_date_sk and d_year = 1998
+   and cd1.cd_demo_sk = wr_refunded_cdemo_sk 
+   and cd2.cd_demo_sk = wr_returning_cdemo_sk
+   and ca_address_sk = wr_refunded_addr_sk
+   and r_reason_sk = wr_reason_sk
+   and
+   (
+    (
+     cd1.cd_marital_status = 'M'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = '4 yr Degree'
+     and 
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 100.00 and 150.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'D'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Primary' 
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 50.00 and 100.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'U'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Advanced Degree'
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 150.00 and 200.00
+    )
+   )
+   and
+   (
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('KY', 'GA', 'NM')
+     and ws_net_profit between 100 and 200  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('MT', 'OR', 'IN')
+     and ws_net_profit between 150 and 300  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('WI', 'MO', 'WV')
+     and ws_net_profit between 50 and 250  
+    )
+   )
+group by r_reason_desc
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@reason
+PREHOOK: Input: default@web_page
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
+ from web_sales, web_returns, web_page, customer_demographics cd1,
+      customer_demographics cd2, customer_address, date_dim, reason 
+ where ws_web_page_sk = wp_web_page_sk
+   and ws_item_sk = wr_item_sk
+   and ws_order_number = wr_order_number
+   and ws_sold_date_sk = d_date_sk and d_year = 1998
+   and cd1.cd_demo_sk = wr_refunded_cdemo_sk 
+   and cd2.cd_demo_sk = wr_returning_cdemo_sk
+   and ca_address_sk = wr_refunded_addr_sk
+   and r_reason_sk = wr_reason_sk
+   and
+   (
+    (
+     cd1.cd_marital_status = 'M'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = '4 yr Degree'
+     and 
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 100.00 and 150.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'D'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Primary' 
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 50.00 and 100.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'U'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Advanced Degree'
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 150.00 and 200.00
+    )
+   )
+   and
+   (
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('KY', 'GA', 'NM')
+     and ws_net_profit between 100 and 200  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('MT', 'OR', 'IN')
+     and ws_net_profit between 150 and 300  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('WI', 'MO', 'WV')
+     and ws_net_profit between 50 and 250  
+    )
+   )
+group by r_reason_desc
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@reason
+POSTHOOK: Input: default@web_page
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 10 <- Reducer 12 (BROADCAST_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 3 <- Map 15 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 11 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 13 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Map 14 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 15 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 9 vectorized
+      File Output Operator [FS_209]
+        Limit [LIM_208] (rows=7 width=832)
+          Number of rows:100
+          Select Operator [SEL_207] (rows=7 width=832)
+            Output:["_col0","_col1","_col2","_col3"]
+          <-Reducer 8 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_206]
+              Select Operator [SEL_205] (rows=7 width=832)
+                Output:["_col4","_col5","_col6","_col7"]
+                Group By Operator [GBY_204] (rows=7 width=353)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)"],keys:KEY._col0
+                <-Reducer 7 [SIMPLE_EDGE]
+                  SHUFFLE [RS_42]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_41] (rows=7 width=353)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"],aggregations:["sum(_col11)","count(_col11)","sum(_col7)","count(_col7)","sum(_col6)","count(_col6)"],keys:_col23
+                      Select Operator [SEL_40] (rows=16740 width=136)
+                        Output:["_col6","_col7","_col11","_col23"]
+                        Filter Operator [FIL_39] (rows=16740 width=136)
+                          predicate:((_col31 and _col32 and _col15) or (_col33 and _col34 and _col16) or (_col35 and _col36 and _col17))
+                          Merge Join Operator [MERGEJOIN_179] (rows=44640 width=136)
+                            Conds:RS_36._col1, _col19, _col20=RS_197._col0, _col1, _col2(Inner),Output:["_col6","_col7","_col11","_col15","_col16","_col17","_col23","_col31","_col32","_col33","_col34","_col35","_col36"]
+                          <-Map 15 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_197]
+                              PartitionCols:_col0, _col1, _col2
+                              Select Operator [SEL_195] (rows=265971 width=207)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                Filter Operator [FIL_194] (rows=265971 width=183)
+                                  predicate:((cd_education_status) IN ('4 yr Degree', 'Primary', 'Advanced Degree') and (cd_marital_status) IN ('M', 'D', 'U'))
+                                  TableScan [TS_17] (rows=1861800 width=183)
+                                    default@customer_demographics,cd1,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_marital_status","cd_education_status"]
+                          <-Reducer 6 [SIMPLE_EDGE]
+                            SHUFFLE [RS_36]
+                              PartitionCols:_col1, _col19, _col20
+                              Filter Operator [FIL_35] (rows=44640 width=315)
+                                predicate:((_col25 and _col12) or (_col26 and _col13) or (_col27 and _col14))
+                                Merge Join Operator [MERGEJOIN_178] (rows=59520 width=315)
+                                  Conds:RS_32._col2=RS_203._col0(Inner),Output:["_col1","_col6","_col7","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col19","_col20","_col23","_col25","_col26","_col27"]
+                                <-Map 14 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_203]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_202] (rows=3529412 width=16)
+                                      Output:["_col0","_col1","_col2","_col3"]
+                                      Filter Operator [FIL_201] (rows=3529412 width=187)
+                                        predicate:((ca_country = 'United States') and (ca_state) IN ('KY', 'GA', 'NM', 'MT', 'OR', 'IN', 'WI', 'MO', 'WV'))
+                                        TableScan [TS_14] (rows=40000000 width=187)
+                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state","ca_country"]
+                                <-Reducer 5 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_32]
+                                    PartitionCols:_col2
+                                    Merge Join Operator [MERGEJOIN_177] (rows=674551 width=350)
+                                      Conds:RS_29._col4=RS_200._col0(Inner),Output:["_col1","_col2","_col6","_col7","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col19","_col20","_col23"]
+                                    <-Map 13 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_200]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_199] (rows=72 width=101)
+                                          Output:["_col0","_col1"]
+                                          TableScan [TS_12] (rows=72 width=101)
+                                            default@reason,reason,Tbl:COMPLETE,Col:COMPLETE,Output:["r_reason_sk","r_reason_desc"]
+                                    <-Reducer 4 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_29]
+                                        PartitionCols:_col4
+                                        Merge Join Operator [MERGEJOIN_176] (rows=674551 width=254)
+                                          Conds:RS_26._col8=RS_185._col0(Inner),Output:["_col1","_col2","_col4","_col6","_col7","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col19","_col20"]
+                                        <-Map 11 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_185]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_184] (rows=652 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_183] (rows=652 width=8)
+                                                predicate:(d_year = 1998)
+                                                TableScan [TS_9] (rows=73049 width=8)
+                                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                        <-Reducer 3 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_26]
+                                            PartitionCols:_col8
+                                            Merge Join Operator [MERGEJOIN_175] (rows=1889180 width=379)
+                                              Conds:RS_23._col3=RS_198._col0(Inner),Output:["_col1","_col2","_col4","_col6","_col7","_col8","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col19","_col20"]
+                                            <-Map 15 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_198]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_196] (rows=265971 width=183)
+                                                  Output:["_col0","_col1","_col2"]
+                                                   Please refer to the previous Filter Operator [FIL_194]
+                                            <-Reducer 2 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_23]
+                                                PartitionCols:_col3
+                                                Merge Join Operator [MERGEJOIN_174] (rows=13039884 width=262)
+                                                  Conds:RS_182._col0, _col5=RS_193._col1, _col2(Inner),Output:["_col1","_col2","_col3","_col4","_col6","_col7","_col8","_col11","_col12","_col13","_col14","_col15","_col16","_col17"]
+                                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_182]
+                                                    PartitionCols:_col0, _col5
+                                                    Select Operator [SEL_181] (rows=11975292 width=237)
+                                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                                      Filter Operator [FIL_180] (rows=11975292 width=237)
+                                                        predicate:(wr_reason_sk is not null and wr_refunded_addr_sk is not null and wr_refunded_cdemo_sk is not null and wr_returning_cdemo_sk is not null)
+                                                        TableScan [TS_0] (rows=14398467 width=237)
+                                                          default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_item_sk","wr_refunded_cdemo_sk","wr_refunded_addr_sk","wr_returning_cdemo_sk","wr_reason_sk","wr_order_number","wr_fee","wr_refunded_cash"]
+                                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_193]
+                                                    PartitionCols:_col1, _col2
+                                                    Select Operator [SEL_192] (rows=15992347 width=39)
+                                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+                                                      Filter Operator [FIL_191] (rows=15992347 width=243)
+                                                        predicate:((ws_net_profit BETWEEN 100 AND 200 or ws_net_profit BETWEEN 150 AND 300 or ws_net_profit BETWEEN 50 AND 250) and (ws_sales_price BETWEEN 100 AND 150 or ws_sales_price BETWEEN 50 AND 100 or ws_sales_price BETWEEN 150 AND 200) and (ws_sold_date_sk BETWEEN DynamicValue(RS_27_date_dim_d_date_sk_min) AND DynamicValue(RS_27_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_27_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null and ws_web_page_sk is not null)
+                                                        TableScan [TS_3] (rows=144002668 width=243)
+                                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_web_page_sk","ws_order_number","ws_quantity","ws_sales_price","ws_net_profit"]
+                                                        <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_190]
+                                                            Group By Operator [GBY_189] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_188]
+                                                                Group By Operator [GBY_187] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_186] (rows=652 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_184]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query86.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query86.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query86.q.out
new file mode 100644
index 0000000..638cce1
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query86.q.out
@@ -0,0 +1,145 @@
+PREHOOK: query: explain
+select   
+    sum(ws_net_paid) as total_sum
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ws_net_paid) desc) as rank_within_parent
+ from
+    web_sales
+   ,date_dim       d1
+   ,item
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ws_sold_date_sk
+ and i_item_sk  = ws_item_sk
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc,
+   case when lochierarchy = 0 then i_category end,
+   rank_within_parent
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select   
+    sum(ws_net_paid) as total_sum
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ws_net_paid) desc) as rank_within_parent
+ from
+    web_sales
+   ,date_dim       d1
+   ,item
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ws_sold_date_sk
+ and i_item_sk  = ws_item_sk
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc,
+   case when lochierarchy = 0 then i_category end,
+   rank_within_parent
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 8 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 3 <- Map 9 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 8 <- Map 7 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_82]
+        Limit [LIM_81] (rows=100 width=490)
+          Number of rows:100
+          Select Operator [SEL_80] (rows=3060 width=490)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_79]
+              Select Operator [SEL_78] (rows=3060 width=490)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                PTF Operator [PTF_77] (rows=3060 width=302)
+                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col2 DESC NULLS LAST","partition by:":"(grouping(_col3, 1) + grouping(_col3, 0)), CASE WHEN ((grouping(_col3, 0) = 0)) THEN (_col0) ELSE (CAST( null AS STRING)) END"}]
+                  Select Operator [SEL_76] (rows=3060 width=302)
+                    Output:["_col0","_col1","_col2","_col3"]
+                  <-Reducer 4 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_75]
+                      PartitionCols:(grouping(_col3, 1) + grouping(_col3, 0)), CASE WHEN ((grouping(_col3, 0) = 0)) THEN (_col0) ELSE (CAST( null AS STRING)) END
+                      Select Operator [SEL_74] (rows=3060 width=302)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Group By Operator [GBY_73] (rows=3060 width=302)
+                          Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                        <-Reducer 3 [SIMPLE_EDGE]
+                          SHUFFLE [RS_17]
+                            PartitionCols:_col0, _col1, _col2
+                            Group By Operator [GBY_16] (rows=88740 width=302)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)"],keys:_col0, _col1, 0L
+                              Select Operator [SEL_14] (rows=24992810 width=293)
+                                Output:["_col0","_col1","_col2"]
+                                Merge Join Operator [MERGEJOIN_59] (rows=24992810 width=293)
+                                  Conds:RS_11._col1=RS_72._col0(Inner),Output:["_col2","_col5","_col6"]
+                                <-Map 9 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_72]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_71] (rows=462000 width=186)
+                                      Output:["_col0","_col1","_col2"]
+                                      TableScan [TS_6] (rows=462000 width=186)
+                                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_class","i_category"]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_11]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_58] (rows=24992810 width=115)
+                                      Conds:RS_70._col0=RS_62._col0(Inner),Output:["_col1","_col2"]
+                                    <-Map 7 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_62]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_61] (rows=317 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_60] (rows=317 width=8)
+                                            predicate:d_month_seq BETWEEN 1212 AND 1223
+                                            TableScan [TS_3] (rows=73049 width=8)
+                                              default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_70]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_69] (rows=143966864 width=119)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_68] (rows=143966864 width=119)
+                                            predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_9_d1_d_date_sk_min) AND DynamicValue(RS_9_d1_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_9_d1_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                            TableScan [TS_0] (rows=144002668 width=119)
+                                              default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_net_paid"]
+                                            <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_67]
+                                                Group By Operator [GBY_66] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_65]
+                                                    Group By Operator [GBY_64] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_63] (rows=317 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_61]
+


[71/75] [abbrv] hive git commit: HIVE-20806: Add ASF license for files added in HIVE-20679 (Anishek Agarwal, reviewed by Sankar Hariappan)

Posted by se...@apache.org.
HIVE-20806: Add ASF license for files added in HIVE-20679 (Anishek Agarwal, reviewed by Sankar Hariappan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/50a96d77
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/50a96d77
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/50a96d77

Branch: refs/heads/master-tez092
Commit: 50a96d77e369f82c67acdd018ff696b1b221f2b2
Parents: a26d9d1
Author: Anishek Agarwal <an...@gmail.com>
Authored: Fri Oct 26 10:27:02 2018 +0530
Committer: Anishek Agarwal <an...@gmail.com>
Committed: Fri Oct 26 10:27:02 2018 +0530

----------------------------------------------------------------------
 .../messaging/json/gzip/DeSerializer.java         | 18 ++++++++++++++++++
 .../metastore/messaging/json/gzip/Serializer.java | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/50a96d77/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java
index 9c64e33..49596b5 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.hadoop.hive.metastore.messaging.json.gzip;
 
 import org.apache.commons.io.FileUtils;

http://git-wip-us.apache.org/repos/asf/hive/blob/50a96d77/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java
index c40600d..7786d96 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.hadoop.hive.metastore.messaging.json.gzip;
 
 import org.apache.hadoop.hive.metastore.messaging.EventMessage;


[45/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query26.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query26.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query26.q.out
new file mode 100644
index 0000000..8b36aed
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query26.q.out
@@ -0,0 +1,76 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[/(CAST($1):DOUBLE, $2)], $f2=[/($3, $4)], $f3=[/($5, $6)], $f4=[/($7, $8)])
+    HiveAggregate(group=[{1}], agg#0=[sum($6)], agg#1=[count($6)], agg#2=[sum($7)], agg#3=[count($7)], agg#4=[sum($9)], agg#5=[count($9)], agg#6=[sum($8)], agg#7=[count($8)])
+      HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_item_id=[$1])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveJoin(condition=[=($3, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($1, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cs_sold_date_sk=[$0], cs_bill_cdemo_sk=[$4], cs_item_sk=[$15], cs_promo_sk=[$16], cs_quantity=[$18], cs_list_price=[$20], cs_sales_price=[$21], cs_coupon_amt=[$27])
+                HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($15), IS NOT NULL($16))])
+                  HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+              HiveProject(cd_demo_sk=[$0], cd_gender=[CAST(_UTF-16LE'F'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_marital_status=[CAST(_UTF-16LE'W'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_education_status=[CAST(_UTF-16LE'Primary'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                HiveFilter(condition=[AND(=($1, _UTF-16LE'F'), =($2, _UTF-16LE'W'), =($3, _UTF-16LE'Primary'), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+            HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER])
+              HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(p_promo_sk=[$0], p_channel_email=[$9], p_channel_event=[$14])
+            HiveFilter(condition=[AND(OR(=($9, _UTF-16LE'N'), =($14, _UTF-16LE'N')), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out
new file mode 100644
index 0000000..9a6718a
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query27.q.out
@@ -0,0 +1,81 @@
+PREHOOK: query: explain cbo
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id,
+        s_state, grouping(s_state) g_state,
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4
+ from store_sales, customer_demographics, date_dim, store, item
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_store_sk = s_store_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       cd_gender = 'M' and
+       cd_marital_status = 'U' and
+       cd_education_status = '2 yr Degree' and
+       d_year = 2001 and
+       s_state in ('SD','FL', 'MI', 'LA', 'MO', 'SC')
+ group by rollup (i_item_id, s_state)
+ order by i_item_id
+         ,s_state
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], s_state=[$1], g_state=[grouping($10, 0)], agg1=[/(CAST($2):DOUBLE, $3)], agg2=[/($4, $5)], agg3=[/($6, $7)], agg4=[/($8, $9)])
+    HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[count($2)], agg#2=[sum($3)], agg#3=[count($3)], agg#4=[sum($4)], agg#5=[count($4)], agg#6=[sum($5)], agg#7=[count($5)], GROUPING__ID=[GROUPING__ID()])
+      HiveProject($f0=[$1], $f1=[$17], $f2=[$6], $f3=[$7], $f4=[$9], $f5=[$8])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1])
+            HiveFilter(condition=[IS NOT NULL($0)])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+          HiveJoin(condition=[=($3, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_cdemo_sk=[$4], ss_store_sk=[$7], ss_quantity=[$10], ss_list_price=[$12], ss_sales_price=[$13], ss_coupon_amt=[$19])
+                  HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($2))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(cd_demo_sk=[$0], cd_gender=[CAST(_UTF-16LE'M'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_marital_status=[CAST(_UTF-16LE'U'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_education_status=[CAST(_UTF-16LE'2 yr Degree'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                  HiveFilter(condition=[AND(=($1, _UTF-16LE'M'), =($2, _UTF-16LE'U'), =($3, _UTF-16LE'2 yr Degree'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+              HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(s_store_sk=[$0], s_state=[$24])
+              HiveFilter(condition=[AND(IN($24, _UTF-16LE'SD', _UTF-16LE'FL', _UTF-16LE'MI', _UTF-16LE'LA', _UTF-16LE'MO', _UTF-16LE'SC'), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query28.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query28.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query28.q.out
new file mode 100644
index 0000000..643e5b6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query28.q.out
@@ -0,0 +1,146 @@
+Warning: Shuffle Join MERGEJOIN[102][tables = [$hdt$_0, $hdt$_1]] in Stage 'Reducer 4' is a cross product
+Warning: Shuffle Join MERGEJOIN[103][tables = [$hdt$_0, $hdt$_1, $hdt$_2]] in Stage 'Reducer 5' is a cross product
+Warning: Shuffle Join MERGEJOIN[104][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3]] in Stage 'Reducer 6' is a cross product
+Warning: Shuffle Join MERGEJOIN[105][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4]] in Stage 'Reducer 7' is a cross product
+Warning: Shuffle Join MERGEJOIN[106][tables = [$hdt$_0, $hdt$_1, $hdt$_2, $hdt$_3, $hdt$_4, $hdt$_5]] in Stage 'Reducer 8' is a cross product
+PREHOOK: query: explain cbo
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from (select avg(ss_list_price) B1_LP
+            ,count(ss_list_price) B1_CNT
+            ,count(distinct ss_list_price) B1_CNTD
+      from store_sales
+      where ss_quantity between 0 and 5
+        and (ss_list_price between 11 and 11+10 
+             or ss_coupon_amt between 460 and 460+1000
+             or ss_wholesale_cost between 14 and 14+20)) B1,
+     (select avg(ss_list_price) B2_LP
+            ,count(ss_list_price) B2_CNT
+            ,count(distinct ss_list_price) B2_CNTD
+      from store_sales
+      where ss_quantity between 6 and 10
+        and (ss_list_price between 91 and 91+10
+          or ss_coupon_amt between 1430 and 1430+1000
+          or ss_wholesale_cost between 32 and 32+20)) B2,
+     (select avg(ss_list_price) B3_LP
+            ,count(ss_list_price) B3_CNT
+            ,count(distinct ss_list_price) B3_CNTD
+      from store_sales
+      where ss_quantity between 11 and 15
+        and (ss_list_price between 66 and 66+10
+          or ss_coupon_amt between 920 and 920+1000
+          or ss_wholesale_cost between 4 and 4+20)) B3,
+     (select avg(ss_list_price) B4_LP
+            ,count(ss_list_price) B4_CNT
+            ,count(distinct ss_list_price) B4_CNTD
+      from store_sales
+      where ss_quantity between 16 and 20
+        and (ss_list_price between 142 and 142+10
+          or ss_coupon_amt between 3054 and 3054+1000
+          or ss_wholesale_cost between 80 and 80+20)) B4,
+     (select avg(ss_list_price) B5_LP
+            ,count(ss_list_price) B5_CNT
+            ,count(distinct ss_list_price) B5_CNTD
+      from store_sales
+      where ss_quantity between 21 and 25
+        and (ss_list_price between 135 and 135+10
+          or ss_coupon_amt between 14180 and 14180+1000
+          or ss_wholesale_cost between 38 and 38+20)) B5,
+     (select avg(ss_list_price) B6_LP
+            ,count(ss_list_price) B6_CNT
+            ,count(distinct ss_list_price) B6_CNTD
+      from store_sales
+      where ss_quantity between 26 and 30
+        and (ss_list_price between 28 and 28+10
+          or ss_coupon_amt between 2513 and 2513+1000
+          or ss_wholesale_cost between 42 and 42+20)) B6
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f00=[$15], $f10=[$16], $f20=[$17], $f01=[$12], $f11=[$13], $f21=[$14], $f02=[$9], $f12=[$10], $f22=[$11], $f03=[$6], $f13=[$7], $f23=[$8], $f04=[$3], $f14=[$4], $f24=[$5])
+    HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[true], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+                  HiveFilter(condition=[AND(BETWEEN(false, $10, 0, 5), OR(BETWEEN(false, $12, 11, 21), BETWEEN(false, $19, 460, 1460), BETWEEN(false, $11, 14, 34)))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+                HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+                  HiveFilter(condition=[AND(BETWEEN(false, $10, 26, 30), OR(BETWEEN(false, $12, 28, 38), BETWEEN(false, $19, 2513, 3513), BETWEEN(false, $11, 42, 62)))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+            HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+              HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+                HiveFilter(condition=[AND(BETWEEN(false, $10, 21, 25), OR(BETWEEN(false, $12, 135, 145), BETWEEN(false, $19, 14180, 15180), BETWEEN(false, $11, 38, 58)))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+            HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+              HiveFilter(condition=[AND(BETWEEN(false, $10, 16, 20), OR(BETWEEN(false, $12, 142, 152), BETWEEN(false, $19, 3054, 4054), BETWEEN(false, $11, 80, 100)))])
+                HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+        HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+          HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+            HiveFilter(condition=[AND(BETWEEN(false, $10, 11, 15), OR(BETWEEN(false, $12, 66, 76), BETWEEN(false, $19, 920, 1920), BETWEEN(false, $11, 4, 24)))])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+      HiveProject($f0=[/($0, $1)], $f1=[$1], $f2=[$2])
+        HiveAggregate(group=[{}], agg#0=[sum($12)], agg#1=[count($12)], agg#2=[count(DISTINCT $12)])
+          HiveFilter(condition=[AND(BETWEEN(false, $10, 6, 10), OR(BETWEEN(false, $12, 91, 101), BETWEEN(false, $19, 1430, 2430), BETWEEN(false, $11, 32, 52)))])
+            HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query29.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query29.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query29.q.out
new file mode 100644
index 0000000..9f9ffe5
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query29.q.out
@@ -0,0 +1,144 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], s_store_id=[$2], s_store_name=[$3], $f4=[$4], $f5=[$5], $f6=[$6])
+    HiveAggregate(group=[{7, 8, 27, 28}], agg#0=[sum($14)], agg#1=[sum($22)], agg#2=[sum($3)])
+      HiveJoin(condition=[AND(=($20, $1), =($19, $2))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cs_sold_date_sk=[$0], cs_bill_customer_sk=[$3], cs_item_sk=[$15], cs_quantity=[$18])
+            HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($15), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+          HiveProject(d_date_sk=[$0], d_year=[$6])
+            HiveFilter(condition=[AND(IN($6, 1999, 2000, 2001), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+        HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$2], ss_sold_date_sk=[$3], ss_item_sk=[$4], ss_customer_sk=[$5], ss_store_sk=[$6], ss_ticket_number=[$7], ss_quantity=[$8], d_date_sk=[$9], d_year=[$10], d_moy=[$11], sr_returned_date_sk=[$12], sr_item_sk=[$13], sr_customer_sk=[$14], sr_ticket_number=[$15], sr_return_quantity=[$16], d_date_sk0=[$17], d_year0=[$18], d_moy0=[$19], s_store_sk=[$20], s_store_id=[$21], s_store_name=[$22])
+          HiveJoin(condition=[=($20, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+              HiveJoin(condition=[AND(AND(=($2, $11), =($1, $10)), =($4, $12))], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_store_sk=[$7], ss_ticket_number=[$9], ss_quantity=[$10])
+                    HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(4):INTEGER])
+                    HiveFilter(condition=[AND(=($8, 4), =($6, 1999), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$1], sr_customer_sk=[$2], sr_ticket_number=[$3], sr_return_quantity=[$4], d_date_sk=[$5], d_year=[$6], d_moy=[$7])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_returned_date_sk=[$0], sr_item_sk=[$2], sr_customer_sk=[$3], sr_ticket_number=[$9], sr_return_quantity=[$10])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[$8])
+                      HiveFilter(condition=[AND(BETWEEN(false, $8, 4, 7), =($6, 1999), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+            HiveProject(s_store_sk=[$0], s_store_id=[$1], s_store_name=[$5])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query3.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query3.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query3.q.out
new file mode 100644
index 0000000..09c9bb7
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query3.q.out
@@ -0,0 +1,64 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$3], sort2=[$1], dir0=[ASC], dir1=[DESC-nulls-last], dir2=[ASC], fetch=[100])
+  HiveProject(d_year=[$2], i_brand_id=[$0], i_brand=[$1], $f3=[$3])
+    HiveAggregate(group=[{4, 5, 8}], agg#0=[sum($2)])
+      HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($1, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_ext_sales_price=[$15])
+            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2))])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+          HiveProject(i_item_sk=[$0], i_brand_id=[$7], i_brand=[$8], i_manufact_id=[CAST(436):INTEGER])
+            HiveFilter(condition=[AND(=($13, 436), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(d_date_sk=[$0], d_year=[$6], d_moy=[CAST(12):INTEGER])
+          HiveFilter(condition=[AND(=($8, 12), IS NOT NULL($0))])
+            HiveTableScan(table=[[default, date_dim]], table:alias=[dt])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query30.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query30.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query30.q.out
new file mode 100644
index 0000000..067b2bc
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query30.q.out
@@ -0,0 +1,112 @@
+PREHOOK: query: explain cbo
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@web_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], sort10=[$10], sort11=[$11], sort12=[$12], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], dir10=[ASC], dir11=[ASC], dir12=[ASC], fetch=[100])
+  HiveProject(c_customer_id=[$1], c_salutation=[$3], c_first_name=[$4], c_last_name=[$5], c_preferred_cust_flag=[$6], c_birth_day=[$7], c_birth_month=[$8], c_birth_year=[$9], c_birth_country=[$10], c_login=[$11], c_email_address=[$12], c_last_review_date=[$13], ctr_total_return=[$18])
+    HiveJoin(condition=[=($16, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($14, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_current_addr_sk=[$4], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_day=[$11], c_birth_month=[$12], c_birth_year=[$13], c_birth_country=[$14], c_login=[$15], c_email_address=[$16], c_last_review_date=[$17])
+          HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ca_address_sk=[$0], ca_state=[CAST(_UTF-16LE'IL'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+          HiveFilter(condition=[AND(=($8, _UTF-16LE'IL'), IS NOT NULL($0))])
+            HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+      HiveProject(wr_returning_customer_sk=[$0], ca_state=[$1], $f2=[$2], _o__c0=[$3], ctr_state=[$4])
+        HiveJoin(condition=[AND(=($1, $4), >($2, $3))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(wr_returning_customer_sk=[$1], ca_state=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+              HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($8))])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(wr_returned_date_sk=[$0], wr_returning_customer_sk=[$7], wr_returning_addr_sk=[$10], wr_return_amt=[$15])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(_o__c0=[*(/($1, $2), 1.2)], ctr_state=[$0])
+            HiveAggregate(group=[{0}], agg#0=[sum($2)], agg#1=[count($2)])
+              HiveProject(ca_state=[$0], wr_returning_customer_sk=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 3}], agg#0=[sum($5)])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($8))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(wr_returned_date_sk=[$0], wr_returning_customer_sk=[$7], wr_returning_addr_sk=[$10], wr_return_amt=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($10))])
+                          HiveTableScan(table=[[default, web_returns]], table:alias=[web_returns])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out
new file mode 100644
index 0000000..5143053
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query31.q.out
@@ -0,0 +1,199 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(ca_county=[$0], d_year=[CAST(2000):INTEGER], web_q1_q2_increase=[/($9, $7)], store_q1_q2_increase=[/($1, $3)], web_q2_q3_increase=[/($11, $9)], store_q2_q3_increase=[/($5, $1)])
+  HiveJoin(condition=[AND(AND(=($0, $6), CASE(>($3, 0), CASE(>($7, 0), >(/($9, $7), /($1, $3)), >(null, /($1, $3))), CASE(>($7, 0), >(/($9, $7), null), null))), CASE(>($1, 0), CASE(>($9, 0), >(/($11, $9), /($5, $1)), >(null, /($5, $1))), CASE(>($9, 0), >(/($11, $9), null), null)))], joinType=[inner], algorithm=[none], cost=[not available])
+    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(ca_county=[$0], $f1=[$1])
+          HiveAggregate(group=[{1}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(2):INTEGER])
+                  HiveFilter(condition=[AND(=($10, 2), =($6, 2000), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(ca_county=[$0], $f1=[$1])
+          HiveAggregate(group=[{1}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(1):INTEGER])
+                  HiveFilter(condition=[AND(=($10, 1), =($6, 2000), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+      HiveProject(ca_county=[$0], $f1=[$1])
+        HiveAggregate(group=[{1}], agg#0=[sum($4)])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ca_address_sk=[$0], ca_county=[$7])
+              HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(3):INTEGER])
+                HiveFilter(condition=[AND(=($10, 3), =($6, 2000), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+    HiveProject(ca_county=[$0], $f1=[$1], ca_county0=[$2], $f10=[$3], ca_county1=[$4], $f11=[$5])
+      HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ca_county=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($4)])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(1):INTEGER])
+                    HiveFilter(condition=[AND(=($10, 1), =($6, 2000), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(ca_county=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($4)])
+              HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ws_sold_date_sk=[$0], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(2):INTEGER])
+                    HiveFilter(condition=[AND(=($10, 2), =($6, 2000), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(ca_county=[$0], $f1=[$1])
+          HiveAggregate(group=[{1}], agg#0=[sum($4)])
+            HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ca_address_sk=[$0], ca_county=[$7])
+                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                  HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+              HiveJoin(condition=[=($0, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ws_sold_date_sk=[$0], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER], d_qoy=[CAST(3):INTEGER])
+                  HiveFilter(condition=[AND(=($10, 3), =($6, 2000), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query32.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query32.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query32.q.out
new file mode 100644
index 0000000..981d478
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query32.q.out
@@ -0,0 +1,89 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(fetch=[100])
+  HiveProject($f0=[$0])
+    HiveAggregate(group=[{}], agg#0=[sum($2)])
+      HiveJoin(condition=[AND(>($2, CAST(*(1.3, $6)):DECIMAL(14, 7)), =($7, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_discount_amt=[$22])
+            HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+          HiveProject(d_date_sk=[$0], d_date=[$2])
+            HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(cs_item_sk=[$0], $f1=[$1], i_item_sk=[$2], i_manufact_id=[$3])
+          HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(cs_item_sk=[$0], $f1=[/($1, $2)])
+              HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+                HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_item_sk=[$15], cs_ext_discount_amt=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_date=[$2])
+                    HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 1998-03-18 00:00:00, 1998-06-16 00:00:00), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(i_item_sk=[$0], i_manufact_id=[CAST(269):INTEGER])
+              HiveFilter(condition=[AND(=($13, 269), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out
new file mode 100644
index 0000000..b5c7f11
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query33.q.out
@@ -0,0 +1,238 @@
+PREHOOK: query: explain cbo
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$1], dir0=[ASC], fetch=[100])
+  HiveProject(i_manufact_id=[$0], $f1=[$1])
+    HiveAggregate(group=[{0}], agg#0=[sum($1)])
+      HiveProject(i_manufact_id=[$0], $f1=[$1])
+        HiveUnion(all=[true])
+          HiveProject(i_manufact_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($13), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_manufact_id=[$0])
+                    HiveAggregate(group=[{13}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Books'), IS NOT NULL($13))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], ss_sold_date_sk=[$2], ss_item_sk=[$3], ss_addr_sk=[$4], ss_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-6):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_addr_sk=[$6], ss_ext_sales_price=[$15])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($2))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(3):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_manufact_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($7, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($13), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_manufact_id=[$0])
+                    HiveAggregate(group=[{13}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Books'), IS NOT NULL($13))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], cs_sold_date_sk=[$2], cs_bill_addr_sk=[$3], cs_item_sk=[$4], cs_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-6):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(cs_sold_date_sk=[$0], cs_bill_addr_sk=[$6], cs_item_sk=[$15], cs_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($15))])
+                          HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(3):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(i_manufact_id=[$0], $f1=[$1])
+            HiveAggregate(group=[{1}], agg#0=[sum($8)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(i_item_sk=[$0], i_manufact_id=[$13])
+                    HiveFilter(condition=[AND(IS NOT NULL($13), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, item]], table:alias=[item])
+                  HiveProject(i_manufact_id=[$0])
+                    HiveAggregate(group=[{13}])
+                      HiveFilter(condition=[AND(=($12, _UTF-16LE'Books'), IS NOT NULL($13))])
+                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveProject(ca_address_sk=[$0], ca_gmt_offset=[$1], ws_sold_date_sk=[$2], ws_item_sk=[$3], ws_bill_addr_sk=[$4], ws_ext_sales_price=[$5], d_date_sk=[$6], d_year=[$7], d_moy=[$8])
+                  HiveJoin(condition=[=($4, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ca_address_sk=[$0], ca_gmt_offset=[CAST(-6):DECIMAL(5, 2)])
+                      HiveFilter(condition=[AND(=($11, -6), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+                    HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_item_sk=[$3], ws_bill_addr_sk=[$7], ws_ext_sales_price=[$23])
+                        HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[CAST(3):INTEGER])
+                        HiveFilter(condition=[AND(=($6, 1999), =($8, 3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out
new file mode 100644
index 0000000..4e50a1c
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query34.q.out
@@ -0,0 +1,99 @@
+PREHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0 
+	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
+	else null 
+	end)  > 1.2
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County',
+                           'Fairfield County','Jackson County','Barrow County','Pennington County')
+    group by ss_ticket_number,ss_customer_sk) dn,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 15 and 20
+    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0 
+	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
+	else null 
+	end)  > 1.2
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County',
+                           'Fairfield County','Jackson County','Barrow County','Pennington County')
+    group by ss_ticket_number,ss_customer_sk) dn,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 15 and 20
+    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[DESC-nulls-last])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], c_salutation=[$1], c_preferred_cust_flag=[$4], ss_ticket_number=[$5], cnt=[$7])
+    HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(c_customer_sk=[$0], c_salutation=[$7], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10])
+        HiveFilter(condition=[IS NOT NULL($0)])
+          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+      HiveProject(ss_ticket_number=[$0], ss_customer_sk=[$1], $f2=[$2])
+        HiveFilter(condition=[BETWEEN(false, $2, 15, 20)])
+          HiveProject(ss_ticket_number=[$1], ss_customer_sk=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 4}], agg#0=[count()])
+              HiveJoin(condition=[=($3, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_store_sk=[$7], ss_ticket_number=[$9])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($3))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[$6], d_dom=[$9])
+                      HiveFilter(condition=[AND(IN($6, 2000, 2001, 2002), OR(BETWEEN(false, $9, 1, 3), BETWEEN(false, $9, 25, 28)), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(hd_demo_sk=[$0], hd_buy_potential=[$2], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                    HiveFilter(condition=[AND(IN($2, _UTF-16LE'>10000', _UTF-16LE'unknown'), >($4, 0), CASE(>($4, 0), >(/(CAST($3):DOUBLE, CAST($4):DOUBLE), 1.2), null), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+                HiveProject(s_store_sk=[$0], s_county=[$23])
+                  HiveFilter(condition=[AND(IN($23, _UTF-16LE'Mobile County', _UTF-16LE'Maverick County', _UTF-16LE'Huron County', _UTF-16LE'Kittitas County', _UTF-16LE'Fairfield County', _UTF-16LE'Jackson County', _UTF-16LE'Barrow County', _UTF-16LE'Pennington County'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query35.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query35.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query35.q.out
new file mode 100644
index 0000000..2b8a453
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query35.q.out
@@ -0,0 +1,175 @@
+PREHOOK: query: explain cbo
+select   
+  ca_state,
+  cd_gender,
+  cd_marital_status,
+  count(*) cnt1,
+  avg(cd_dep_count),
+  max(cd_dep_count),
+  sum(cd_dep_count),
+  cd_dep_employed_count,
+  count(*) cnt2,
+  avg(cd_dep_employed_count),
+  max(cd_dep_employed_count),
+  sum(cd_dep_employed_count),
+  cd_dep_college_count,
+  count(*) cnt3,
+  avg(cd_dep_college_count),
+  max(cd_dep_college_count),
+  sum(cd_dep_college_count)
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_qoy < 4) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4))
+ group by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select   
+  ca_state,
+  cd_gender,
+  cd_marital_status,
+  count(*) cnt1,
+  avg(cd_dep_count),
+  max(cd_dep_count),
+  sum(cd_dep_count),
+  cd_dep_employed_count,
+  count(*) cnt2,
+  avg(cd_dep_employed_count),
+  max(cd_dep_employed_count),
+  sum(cd_dep_employed_count),
+  cd_dep_college_count,
+  count(*) cnt3,
+  avg(cd_dep_college_count),
+  max(cd_dep_college_count),
+  sum(cd_dep_college_count)
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_qoy < 4) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4))
+ group by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(ca_state=[$0], cd_gender=[$1], cd_marital_status=[$2], cnt1=[$3], _o__c4=[$4], _o__c5=[$5], _o__c6=[$6], cd_dep_employed_count=[$7], cnt2=[$8], _o__c9=[$9], _o__c10=[$10], _o__c11=[$11], cd_dep_college_count=[$12], cnt3=[$13], _o__c14=[$14], _o__c15=[$15], _o__c16=[$16])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$17], sort4=[$7], sort5=[$12], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], fetch=[100])
+    HiveProject(ca_state=[$0], cd_gender=[$1], cd_marital_status=[$2], cnt1=[$6], _o__c4=[/(CAST($7):DOUBLE, $8)], _o__c5=[$9], _o__c6=[$7], cd_dep_employed_count=[$4], cnt2=[$6], _o__c9=[/(CAST($10):DOUBLE, $11)], _o__c10=[$12], _o__c11=[$10], cd_dep_college_count=[$5], cnt3=[$6], _o__c14=[/(CAST($13):DOUBLE, $14)], _o__c15=[$15], _o__c16=[$13], (tok_table_or_col cd_dep_count)=[$3])
+      HiveAggregate(group=[{4, 6, 7, 8, 9, 10}], agg#0=[count()], agg#1=[sum($8)], agg#2=[count($8)], agg#3=[max($8)], agg#4=[sum($9)], agg#5=[count($9)], agg#6=[max($9)], agg#7=[sum($10)], agg#8=[count($10)], agg#9=[max($10)])
+        HiveFilter(condition=[OR(IS NOT NULL($12), IS NOT NULL($14))])
+          HiveJoin(condition=[=($0, $13)], joinType=[left], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($0, $11)], joinType=[left], algorithm=[none], cost=[not available])
+              HiveSemiJoin(condition=[=($0, $11)], joinType=[inner])
+                HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, customer]], table:alias=[c])
+                    HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
+                  HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_dep_count=[$6], cd_dep_employed_count=[$7], cd_dep_college_count=[$8])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+                HiveProject(ss_customer_sk0=[$1])
+                  HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                      HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_qoy=[$10])
+                      HiveFilter(condition=[AND(=($6, 1999), <($10, 4), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+              HiveProject(ws_bill_customer_sk0=[$0], $f1=[true])
+                HiveAggregate(group=[{1}])
+                  HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                      HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                    HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_qoy=[$10])
+                      HiveFilter(condition=[AND(=($6, 1999), <($10, 4), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+            HiveProject(cs_ship_customer_sk0=[$0], $f1=[true])
+              HiveAggregate(group=[{1}])
+                HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(cs_sold_date_sk=[$0], cs_ship_customer_sk=[$7])
+                    HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_qoy=[$10])
+                    HiveFilter(condition=[AND(=($6, 1999), <($10, 4), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
new file mode 100644
index 0000000..b2a713f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query36.q.out
@@ -0,0 +1,91 @@
+PREHOOK: query: explain cbo
+select  
+    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,item
+   ,store
+ where
+    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 s_state in ('SD','FL','MI','LA',
+                 'MO','SC','AL','GA')
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then i_category end
+  ,rank_within_parent
+  limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,item
+   ,store
+ where
+    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 s_state in ('SD','FL','MI','LA',
+                 'MO','SC','AL','GA')
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then i_category end
+  ,rank_within_parent
+  limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(gross_margin=[$0], i_category=[$1], i_class=[$2], lochierarchy=[$3], rank_within_parent=[$4])
+  HiveSortLimit(sort0=[$3], sort1=[$5], sort2=[$4], dir0=[DESC-nulls-last], dir1=[ASC], dir2=[ASC], fetch=[100])
+    HiveProject(gross_margin=[/($2, $3)], i_category=[$0], i_class=[$1], lochierarchy=[+(grouping($4, 1), grouping($4, 0))], rank_within_parent=[rank() OVER (PARTITION BY +(grouping($4, 1), grouping($4, 0)), CASE(=(grouping($4, 0), 0), $0, null) ORDER BY /($2, $3) NULLS FIRST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)], (tok_function when (= (tok_table_or_col lochierarchy) 0) (tok_table_or_col i_category))=[CASE(=(+(grouping($4, 1), grouping($4, 0)), 0), $0, null)])
+      HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], GROUPING__ID=[$4])
+        HiveAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], agg#0=[sum($2)], agg#1=[sum($3)], GROUPING__ID=[GROUPING__ID()])
+          HiveProject($f0=[$11], $f1=[$10], $f2=[$4], $f3=[$3])
+            HiveJoin(condition=[=($9, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($7, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_ext_sales_price=[$15], ss_net_profit=[$22])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($2), IS NOT NULL($7))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER])
+                    HiveFilter(condition=[AND(=($6, 1999), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                HiveProject(s_store_sk=[$0], s_state=[$24])
+                  HiveFilter(condition=[AND(IN($24, _UTF-16LE'SD', _UTF-16LE'FL', _UTF-16LE'MI', _UTF-16LE'LA', _UTF-16LE'MO', _UTF-16LE'SC', _UTF-16LE'AL', _UTF-16LE'GA'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(i_item_sk=[$0], i_class=[$10], i_category=[$12])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, item]], table:alias=[item])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out
new file mode 100644
index 0000000..0edc78b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query37.q.out
@@ -0,0 +1,63 @@
+PREHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 22 and 22 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
+ and i_manufact_id in (678,964,918,849)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 22 and 22 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
+ and i_manufact_id in (678,964,918,849)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(i_item_id=[$0], i_item_desc=[$1], i_current_price=[$2])
+    HiveAggregate(group=[{2, 3, 4}])
+      HiveJoin(condition=[=($7, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[=($0, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(cs_item_sk=[$15])
+            HiveFilter(condition=[IS NOT NULL($15)])
+              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+          HiveProject(i_item_sk=[$0], i_item_id=[$1], i_item_desc=[$4], i_current_price=[$5], i_manufact_id=[$13])
+            HiveFilter(condition=[AND(IN($13, 678, 964, 918, 849), BETWEEN(false, $5, 22, 52), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_quantity_on_hand=[$2], d_date_sk=[$3], d_date=[$4])
+          HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(inv_date_sk=[$0], inv_item_sk=[$1], inv_quantity_on_hand=[$3])
+              HiveFilter(condition=[AND(BETWEEN(false, $3, 100, 500), IS NOT NULL($1), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, inventory]], table:alias=[inventory])
+            HiveProject(d_date_sk=[$0], d_date=[$2])
+              HiveFilter(condition=[AND(BETWEEN(false, CAST($2):TIMESTAMP(9), 2001-06-02 00:00:00, 2001-08-01 00:00:00), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[19/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query34.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query34.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query34.q.out
new file mode 100644
index 0000000..f4e6a73
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query34.q.out
@@ -0,0 +1,203 @@
+PREHOOK: query: explain
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0 
+	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
+	else null 
+	end)  > 1.2
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County',
+                           'Fairfield County','Jackson County','Barrow County','Pennington County')
+    group by ss_ticket_number,ss_customer_sk) dn,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 15 and 20
+    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0 
+	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
+	else null 
+	end)  > 1.2
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County',
+                           'Fairfield County','Jackson County','Barrow County','Pennington County')
+    group by ss_ticket_number,ss_customer_sk) dn,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 15 and 20
+    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 4 <- Reducer 10 (BROADCAST_EDGE), Reducer 12 (BROADCAST_EDGE), Reducer 14 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 5 <- Map 4 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 6 <- Map 11 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Map 13 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 3 vectorized
+      File Output Operator [FS_134]
+        Select Operator [SEL_133] (rows=276068 width=364)
+          Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+        <-Reducer 2 [SIMPLE_EDGE]
+          SHUFFLE [RS_34]
+            Select Operator [SEL_33] (rows=276068 width=364)
+              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+              Merge Join Operator [MERGEJOIN_99] (rows=276068 width=364)
+                Conds:RS_101._col0=RS_132._col1(Inner),Output:["_col1","_col2","_col3","_col4","_col5","_col7"]
+              <-Map 1 [SIMPLE_EDGE] vectorized
+                SHUFFLE [RS_101]
+                  PartitionCols:_col0
+                  Select Operator [SEL_100] (rows=80000000 width=356)
+                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                    TableScan [TS_0] (rows=80000000 width=356)
+                      default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_salutation","c_first_name","c_last_name","c_preferred_cust_flag"]
+              <-Reducer 8 [SIMPLE_EDGE] vectorized
+                SHUFFLE [RS_132]
+                  PartitionCols:_col1
+                  Filter Operator [FIL_131] (rows=276068 width=12)
+                    predicate:_col2 BETWEEN 15 AND 20
+                    Select Operator [SEL_130] (rows=5521356 width=12)
+                      Output:["_col0","_col1","_col2"]
+                      Group By Operator [GBY_129] (rows=5521356 width=12)
+                        Output:["_col0","_col1","_col2"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                      <-Reducer 7 [SIMPLE_EDGE]
+                        SHUFFLE [RS_25]
+                          PartitionCols:_col0, _col1
+                          Group By Operator [GBY_24] (rows=5521356 width=12)
+                            Output:["_col0","_col1","_col2"],aggregations:["count()"],keys:_col1, _col4
+                            Merge Join Operator [MERGEJOIN_98] (rows=5521356 width=4)
+                              Conds:RS_20._col3=RS_120._col0(Inner),Output:["_col1","_col4"]
+                            <-Map 13 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_120]
+                                PartitionCols:_col0
+                                Select Operator [SEL_119] (rows=112 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_118] (rows=112 width=102)
+                                    predicate:(s_county) IN ('Mobile County', 'Maverick County', 'Huron County', 'Kittitas County', 'Fairfield County', 'Jackson County', 'Barrow County', 'Pennington County')
+                                    TableScan [TS_11] (rows=1704 width=102)
+                                      default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_county"]
+                            <-Reducer 6 [SIMPLE_EDGE]
+                              SHUFFLE [RS_20]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_97] (rows=10407948 width=4)
+                                  Conds:RS_17._col2=RS_112._col0(Inner),Output:["_col1","_col3","_col4"]
+                                <-Map 11 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_112]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_111] (rows=480 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_110] (rows=480 width=104)
+                                        predicate:((hd_buy_potential) IN ('>10000', 'unknown') and (hd_vehicle_count > 0) and CASE WHEN ((hd_vehicle_count > 0)) THEN (((UDFToDouble(hd_dep_count) / UDFToDouble(hd_vehicle_count)) > 1.2D)) ELSE (null) END)
+                                        TableScan [TS_8] (rows=7200 width=104)
+                                          default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_buy_potential","hd_dep_count","hd_vehicle_count"]
+                                <-Reducer 5 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_17]
+                                    PartitionCols:_col2
+                                    Merge Join Operator [MERGEJOIN_96] (rows=156119211 width=14)
+                                      Conds:RS_128._col0=RS_104._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                    <-Map 9 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_104]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_103] (rows=595 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_102] (rows=595 width=12)
+                                            predicate:((d_dom BETWEEN 1 AND 3 or d_dom BETWEEN 25 AND 28) and (d_year) IN (2000, 2001, 2002))
+                                            TableScan [TS_5] (rows=73049 width=12)
+                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_dom"]
+                                    <-Map 4 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_128]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_127] (rows=479121995 width=19)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                          Filter Operator [FIL_126] (rows=479121995 width=19)
+                                            predicate:((ss_hdemo_sk BETWEEN DynamicValue(RS_18_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_18_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_18_household_demographics_hd_demo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_21_store_s_store_sk_min) AND DynamicValue(RS_21_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_21_store_s_store_sk_bloom_filter))) and ss_customer_sk is not null and ss_hdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                            TableScan [TS_2] (rows=575995635 width=19)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_hdemo_sk","ss_store_sk","ss_ticket_number"]
+                                            <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_109]
+                                                Group By Operator [GBY_108] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_107]
+                                                    Group By Operator [GBY_106] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_105] (rows=595 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_103]
+                                            <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_117]
+                                                Group By Operator [GBY_116] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_115]
+                                                    Group By Operator [GBY_114] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_113] (rows=480 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_111]
+                                            <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_125]
+                                                Group By Operator [GBY_124] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_123]
+                                                    Group By Operator [GBY_122] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_121] (rows=112 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_119]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query35.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query35.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query35.q.out
new file mode 100644
index 0000000..2501199
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query35.q.out
@@ -0,0 +1,361 @@
+PREHOOK: query: explain
+select   
+  ca_state,
+  cd_gender,
+  cd_marital_status,
+  count(*) cnt1,
+  avg(cd_dep_count),
+  max(cd_dep_count),
+  sum(cd_dep_count),
+  cd_dep_employed_count,
+  count(*) cnt2,
+  avg(cd_dep_employed_count),
+  max(cd_dep_employed_count),
+  sum(cd_dep_employed_count),
+  cd_dep_college_count,
+  count(*) cnt3,
+  avg(cd_dep_college_count),
+  max(cd_dep_college_count),
+  sum(cd_dep_college_count)
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_qoy < 4) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4))
+ group by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select   
+  ca_state,
+  cd_gender,
+  cd_marital_status,
+  count(*) cnt1,
+  avg(cd_dep_count),
+  max(cd_dep_count),
+  sum(cd_dep_count),
+  cd_dep_employed_count,
+  count(*) cnt2,
+  avg(cd_dep_employed_count),
+  max(cd_dep_employed_count),
+  sum(cd_dep_employed_count),
+  cd_dep_college_count,
+  count(*) cnt3,
+  avg(cd_dep_college_count),
+  max(cd_dep_college_count),
+  sum(cd_dep_college_count)
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_qoy < 4) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4))
+ group by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 13 <- Reducer 16 (BROADCAST_EDGE)
+Map 23 <- Reducer 10 (BROADCAST_EDGE), Reducer 19 (BROADCAST_EDGE)
+Map 24 <- Reducer 22 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (SIMPLE_EDGE), Map 15 (SIMPLE_EDGE)
+Reducer 16 <- Map 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 17 <- Map 15 (SIMPLE_EDGE), Map 23 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE)
+Reducer 19 <- Map 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 11 (SIMPLE_EDGE)
+Reducer 20 <- Map 15 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 21 <- Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Map 15 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 12 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 14 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 18 (ONE_TO_ONE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 21 (ONE_TO_ONE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 5 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_232]
+        Limit [LIM_231] (rows=1 width=352)
+          Number of rows:100
+          Select Operator [SEL_230] (rows=1 width=352)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15","_col16"]
+          <-Reducer 7 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_229]
+              Select Operator [SEL_228] (rows=1 width=352)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17"]
+                Group By Operator [GBY_227] (rows=1 width=336)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"],aggregations:["count(VALUE._col0)","sum(VALUE._col1)","count(VALUE._col2)","max(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","max(VALUE._col6)","sum(VALUE._col7)","count(VALUE._col8)","max(VALUE._col9)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5
+                <-Reducer 6 [SIMPLE_EDGE]
+                  SHUFFLE [RS_65]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5
+                    Group By Operator [GBY_64] (rows=1 width=336)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"],aggregations:["count()","sum(_col8)","count(_col8)","max(_col8)","sum(_col9)","count(_col9)","max(_col9)","sum(_col10)","count(_col10)","max(_col10)"],keys:_col4, _col6, _col7, _col8, _col9, _col10
+                      Top N Key Operator [TNK_102] (rows=67 width=276)
+                        keys:_col4, _col6, _col7, _col8, _col9, _col10,sort order:++++++,top n:100
+                        Select Operator [SEL_63] (rows=67 width=276)
+                          Output:["_col4","_col6","_col7","_col8","_col9","_col10"]
+                          Filter Operator [FIL_62] (rows=67 width=276)
+                            predicate:(_col12 is not null or _col14 is not null)
+                            Merge Join Operator [MERGEJOIN_180] (rows=67 width=276)
+                              Conds:RS_59._col0=RS_226._col0(Left Outer),Output:["_col4","_col6","_col7","_col8","_col9","_col10","_col12","_col14"]
+                            <-Reducer 5 [ONE_TO_ONE_EDGE]
+                              PARTITION_ONLY_SHUFFLE [RS_59]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_179] (rows=68 width=276)
+                                  Conds:RS_56._col0=RS_216._col0(Left Outer),Output:["_col0","_col4","_col6","_col7","_col8","_col9","_col10","_col12"]
+                                <-Reducer 4 [ONE_TO_ONE_EDGE]
+                                  FORWARD [RS_56]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_178] (rows=162346 width=272)
+                                      Conds:RS_53._col0=RS_54._col0(Left Semi),Output:["_col0","_col4","_col6","_col7","_col8","_col9","_col10"]
+                                    <-Reducer 14 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_54]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_52] (rows=168231 width=2)
+                                          Output:["_col0"],keys:_col0
+                                          Select Operator [SEL_16] (rows=62428523 width=2)
+                                            Output:["_col0"]
+                                            Merge Join Operator [MERGEJOIN_175] (rows=62428523 width=2)
+                                              Conds:RS_206._col0=RS_190._col0(Inner),Output:["_col1"]
+                                            <-Map 15 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_190]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_189] (rows=217 width=4)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_188] (rows=217 width=12)
+                                                    predicate:((d_qoy < 4) and (d_year = 1999))
+                                                    TableScan [TS_10] (rows=73049 width=12)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                                            <-Map 13 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_206]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_205] (rows=525327388 width=7)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_204] (rows=525327388 width=7)
+                                                    predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_14_date_dim_d_date_sk_min) AND DynamicValue(RS_14_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_14_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                    TableScan [TS_7] (rows=575995635 width=7)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk"]
+                                                    <-Reducer 16 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_203]
+                                                        Group By Operator [GBY_202] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_199]
+                                                            Group By Operator [GBY_196] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_191] (rows=217 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_189]
+                                    <-Reducer 3 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_53]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_174] (rows=78293105 width=272)
+                                          Conds:RS_48._col1=RS_187._col0(Inner),Output:["_col0","_col4","_col6","_col7","_col8","_col9","_col10"]
+                                        <-Map 12 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_187]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_186] (rows=1861800 width=186)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              TableScan [TS_5] (rows=1861800 width=186)
+                                                default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_dep_count","cd_dep_employed_count","cd_dep_college_count"]
+                                        <-Reducer 2 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_48]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_173] (rows=77201384 width=93)
+                                              Conds:RS_183._col2=RS_185._col0(Inner),Output:["_col0","_col1","_col4"]
+                                            <-Map 1 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_183]
+                                                PartitionCols:_col2
+                                                Select Operator [SEL_182] (rows=77201384 width=11)
+                                                  Output:["_col0","_col1","_col2"]
+                                                  Filter Operator [FIL_181] (rows=77201384 width=11)
+                                                    predicate:(c_current_addr_sk is not null and c_current_cdemo_sk is not null)
+                                                    TableScan [TS_0] (rows=80000000 width=11)
+                                                      default@customer,c,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk"]
+                                            <-Map 11 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_185]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_184] (rows=40000000 width=90)
+                                                  Output:["_col0","_col1"]
+                                                  TableScan [TS_3] (rows=40000000 width=90)
+                                                    default@customer_address,ca,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
+                                <-Reducer 18 [ONE_TO_ONE_EDGE] vectorized
+                                  FORWARD [RS_216]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_215] (rows=168231 width=7)
+                                      Output:["_col0","_col1"]
+                                      Group By Operator [GBY_214] (rows=168231 width=3)
+                                        Output:["_col0"],keys:KEY._col0
+                                      <-Reducer 17 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_28]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_27] (rows=168231 width=3)
+                                            Output:["_col0"],keys:_col1
+                                            Merge Join Operator [MERGEJOIN_176] (rows=17104380 width=3)
+                                              Conds:RS_213._col0=RS_192._col0(Inner),Output:["_col1"]
+                                            <-Map 15 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_192]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_189]
+                                            <-Map 23 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_213]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_212] (rows=143930993 width=7)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_211] (rows=143930993 width=7)
+                                                    predicate:((ws_bill_customer_sk BETWEEN DynamicValue(RS_56_c_c_customer_sk_min) AND DynamicValue(RS_56_c_c_customer_sk_max) and in_bloom_filter(ws_bill_customer_sk, DynamicValue(RS_56_c_c_customer_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_24_date_dim_d_date_sk_min) AND DynamicValue(RS_24_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_24_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                    TableScan [TS_17] (rows=144002668 width=7)
+                                                      default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk"]
+                                                    <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_210]
+                                                        Group By Operator [GBY_209] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                                          FORWARD [RS_150]
+                                                            Group By Operator [GBY_149] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_148] (rows=162346 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_178]
+                                                    <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_208]
+                                                        Group By Operator [GBY_207] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_200]
+                                                            Group By Operator [GBY_197] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_193] (rows=217 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_189]
+                            <-Reducer 21 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_226]
+                                PartitionCols:_col0
+                                Select Operator [SEL_225] (rows=167041 width=7)
+                                  Output:["_col0","_col1"]
+                                  Group By Operator [GBY_224] (rows=167041 width=3)
+                                    Output:["_col0"],keys:KEY._col0
+                                  <-Reducer 20 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_42]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_41] (rows=167041 width=3)
+                                        Output:["_col0"],keys:_col1
+                                        Merge Join Operator [MERGEJOIN_177] (rows=33642830 width=3)
+                                          Conds:RS_223._col0=RS_194._col0(Inner),Output:["_col1"]
+                                        <-Map 15 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_194]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_189]
+                                        <-Map 24 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_223]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_222] (rows=285115246 width=7)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_221] (rows=285115246 width=7)
+                                                predicate:((cs_ship_customer_sk BETWEEN DynamicValue(RS_59_c_c_customer_sk_min) AND DynamicValue(RS_59_c_c_customer_sk_max) and in_bloom_filter(cs_ship_customer_sk, DynamicValue(RS_59_c_c_customer_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_38_date_dim_d_date_sk_min) AND DynamicValue(RS_38_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_38_date_dim_d_date_sk_bloom_filter))) and cs_ship_customer_sk is not null and cs_sold_date_sk is not null)
+                                                TableScan [TS_31] (rows=287989836 width=7)
+                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_ship_customer_sk"]
+                                                <-Reducer 22 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_218]
+                                                    Group By Operator [GBY_217] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 15 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_201]
+                                                        Group By Operator [GBY_198] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_195] (rows=217 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_189]
+                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_220]
+                                                    Group By Operator [GBY_219] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_165]
+                                                        Group By Operator [GBY_164] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_163] (rows=68 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_179]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out
new file mode 100644
index 0000000..f2c0b4b
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query36.q.out
@@ -0,0 +1,182 @@
+PREHOOK: query: explain
+select  
+    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,item
+   ,store
+ where
+    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 s_state in ('SD','FL','MI','LA',
+                 'MO','SC','AL','GA')
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then i_category end
+  ,rank_within_parent
+  limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,item
+   ,store
+ where
+    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 s_state in ('SD','FL','MI','LA',
+                 'MO','SC','AL','GA')
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then i_category end
+  ,rank_within_parent
+  limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 12 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_112]
+        Limit [LIM_111] (rows=100 width=490)
+          Number of rows:100
+          Select Operator [SEL_110] (rows=3060 width=490)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_109]
+              Select Operator [SEL_108] (rows=3060 width=490)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                PTF Operator [PTF_107] (rows=3060 width=414)
+                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(_col2 / _col3) ASC NULLS FIRST","partition by:":"(grouping(_col4, 1) + grouping(_col4, 0)), CASE WHEN ((grouping(_col4, 0) = 0)) THEN (_col0) ELSE (CAST( null AS STRING)) END"}]
+                  Select Operator [SEL_106] (rows=3060 width=414)
+                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                  <-Reducer 5 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_105]
+                      PartitionCols:(grouping(_col4, 1) + grouping(_col4, 0)), CASE WHEN ((grouping(_col4, 0) = 0)) THEN (_col0) ELSE (CAST( null AS STRING)) END
+                      Select Operator [SEL_104] (rows=3060 width=414)
+                        Output:["_col0","_col1","_col2","_col3","_col4"]
+                        Group By Operator [GBY_103] (rows=3060 width=414)
+                          Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2
+                        <-Reducer 4 [SIMPLE_EDGE]
+                          SHUFFLE [RS_23]
+                            PartitionCols:_col0, _col1, _col2
+                            Group By Operator [GBY_22] (rows=85680 width=414)
+                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col2)","sum(_col3)"],keys:_col0, _col1, 0L
+                              Select Operator [SEL_20] (rows=30601888 width=232)
+                                Output:["_col0","_col1","_col2","_col3"]
+                                Merge Join Operator [MERGEJOIN_81] (rows=30601888 width=232)
+                                  Conds:RS_17._col1=RS_102._col0(Inner),Output:["_col3","_col4","_col8","_col9"]
+                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_102]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_101] (rows=462000 width=186)
+                                      Output:["_col0","_col1","_col2"]
+                                      TableScan [TS_9] (rows=462000 width=186)
+                                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_class","i_category"]
+                                <-Reducer 3 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_17]
+                                    PartitionCols:_col1
+                                    Merge Join Operator [MERGEJOIN_80] (rows=30601888 width=54)
+                                      Conds:RS_14._col2=RS_92._col0(Inner),Output:["_col1","_col3","_col4"]
+                                    <-Map 10 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_92]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_91] (rows=278 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_90] (rows=278 width=90)
+                                            predicate:(s_state) IN ('SD', 'FL', 'MI', 'LA', 'MO', 'SC', 'AL', 'GA')
+                                            TableScan [TS_6] (rows=1704 width=90)
+                                              default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
+                                    <-Reducer 2 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_14]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_79] (rows=187574154 width=203)
+                                          Conds:RS_100._col0=RS_84._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_84]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_83] (rows=652 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_82] (rows=652 width=8)
+                                                predicate:(d_year = 1999)
+                                                TableScan [TS_3] (rows=73049 width=8)
+                                                  default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_100]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_99] (rows=525329897 width=225)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                              Filter Operator [FIL_98] (rows=525329897 width=225)
+                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_12_d1_d_date_sk_min) AND DynamicValue(RS_12_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_12_d1_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_15_store_s_store_sk_min) AND DynamicValue(RS_15_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_15_store_s_store_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_0] (rows=575995635 width=225)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_ext_sales_price","ss_net_profit"]
+                                                <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_97]
+                                                    Group By Operator [GBY_96] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_95]
+                                                        Group By Operator [GBY_94] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_93] (rows=278 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_91]
+                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_89]
+                                                    Group By Operator [GBY_88] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_87]
+                                                        Group By Operator [GBY_86] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_85] (rows=652 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_83]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query37.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query37.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query37.q.out
new file mode 100644
index 0000000..fb4cbf4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query37.q.out
@@ -0,0 +1,146 @@
+PREHOOK: query: explain
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 22 and 22 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
+ and i_manufact_id in (678,964,918,849)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@inventory
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 22 and 22 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
+ and i_manufact_id in (678,964,918,849)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@inventory
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (ONE_TO_ONE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 11 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_102]
+        Limit [LIM_101] (rows=1 width=396)
+          Number of rows:100
+          Select Operator [SEL_100] (rows=1 width=396)
+            Output:["_col0","_col1","_col2"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_99]
+              Group By Operator [GBY_98] (rows=1 width=396)
+                Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_23]
+                  PartitionCols:_col0, _col1, _col2
+                  Group By Operator [GBY_22] (rows=2 width=396)
+                    Output:["_col0","_col1","_col2"],keys:_col2, _col3, _col4
+                    Top N Key Operator [TNK_42] (rows=2871 width=396)
+                      keys:_col2, _col3, _col4,sort order:+++,top n:100
+                      Merge Join Operator [MERGEJOIN_78] (rows=2871 width=396)
+                        Conds:RS_18._col1=RS_19._col1(Inner),Output:["_col2","_col3","_col4"]
+                      <-Reducer 9 [SIMPLE_EDGE]
+                        SHUFFLE [RS_19]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_77] (rows=463969 width=4)
+                            Conds:RS_89._col0=RS_92._col0(Inner),Output:["_col1"]
+                          <-Map 11 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_92]
+                              PartitionCols:_col0
+                              Select Operator [SEL_91] (rows=8116 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_90] (rows=8116 width=98)
+                                  predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'2001-06-02 00:00:00' AND TIMESTAMP'2001-08-01 00:00:00'
+                                  TableScan [TS_8] (rows=73049 width=98)
+                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                          <-Map 8 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_89]
+                              PartitionCols:_col0
+                              Select Operator [SEL_88] (rows=4176000 width=8)
+                                Output:["_col0","_col1"]
+                                Filter Operator [FIL_87] (rows=4176000 width=11)
+                                  predicate:inv_quantity_on_hand BETWEEN 100 AND 500
+                                  TableScan [TS_5] (rows=37584000 width=11)
+                                    default@inventory,inventory,Tbl:COMPLETE,Col:COMPLETE,Output:["inv_date_sk","inv_item_sk","inv_quantity_on_hand"]
+                      <-Reducer 2 [ONE_TO_ONE_EDGE]
+                        FORWARD [RS_18]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_76] (rows=1781971 width=400)
+                            Conds:RS_97._col0=RS_81._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_81]
+                              PartitionCols:_col0
+                              Select Operator [SEL_80] (rows=297 width=400)
+                                Output:["_col0","_col1","_col2","_col3"]
+                                Filter Operator [FIL_79] (rows=297 width=404)
+                                  predicate:((i_manufact_id) IN (678, 964, 918, 849) and i_current_price BETWEEN 22 AND 52)
+                                  TableScan [TS_2] (rows=462000 width=403)
+                                    default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_item_desc","i_current_price","i_manufact_id"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_97]
+                              PartitionCols:_col0
+                              Select Operator [SEL_96] (rows=287989836 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_95] (rows=287989836 width=4)
+                                  predicate:((cs_item_sk BETWEEN DynamicValue(RS_16_item_i_item_sk_min) AND DynamicValue(RS_16_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_16_item_i_item_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_19_inventory_inv_item_sk_min) AND DynamicValue(RS_19_inventory_inv_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_19_inventory_inv_item_sk_bloom_filter))))
+                                  TableScan [TS_0] (rows=287989836 width=4)
+                                    default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_item_sk"]
+                                  <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_94]
+                                      Group By Operator [GBY_93] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Reducer 9 [CUSTOM_SIMPLE_EDGE]
+                                        SHUFFLE [RS_50]
+                                          Group By Operator [GBY_49] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_48] (rows=463969 width=8)
+                                              Output:["_col0"]
+                                               Please refer to the previous Merge Join Operator [MERGEJOIN_77]
+                                  <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_86]
+                                      Group By Operator [GBY_85] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_84]
+                                          Group By Operator [GBY_83] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_82] (rows=297 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_80]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query38.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query38.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query38.q.out
new file mode 100644
index 0000000..bc22cfb
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query38.q.out
@@ -0,0 +1,261 @@
+PREHOOK: query: explain
+select  count(*) from (
+    select distinct c_last_name, c_first_name, d_date
+    from store_sales, date_dim, customer
+          where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+      and store_sales.ss_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from catalog_sales, date_dim, customer
+          where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+      and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from web_sales, date_dim, customer
+          where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+      and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+) hot_cust
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  count(*) from (
+    select distinct c_last_name, c_first_name, d_date
+    from store_sales, date_dim, customer
+          where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+      and store_sales.ss_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from catalog_sales, date_dim, customer
+          where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+      and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from web_sales, date_dim, customer
+          where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+      and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+) hot_cust
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 9 (BROADCAST_EDGE)
+Map 19 <- Reducer 13 (BROADCAST_EDGE)
+Map 20 <- Reducer 17 (BROADCAST_EDGE)
+Reducer 10 <- Map 19 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 11 <- Map 18 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 13 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 20 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 15 <- Map 18 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 17 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 18 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_232]
+        Limit [LIM_231] (rows=1 width=8)
+          Number of rows:100
+          Group By Operator [GBY_230] (rows=1 width=8)
+            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+          <-Reducer 6 [CUSTOM_SIMPLE_EDGE] vectorized
+            PARTITION_ONLY_SHUFFLE [RS_229]
+              Group By Operator [GBY_228] (rows=1 width=8)
+                Output:["_col0"],aggregations:["count()"]
+                Select Operator [SEL_227] (rows=1 width=8)
+                  Filter Operator [FIL_226] (rows=1 width=8)
+                    predicate:(_col3 = 3L)
+                    Select Operator [SEL_225] (rows=165330890 width=8)
+                      Output:["_col3"]
+                      Group By Operator [GBY_224] (rows=165330890 width=282)
+                        Output:["_col0","_col1","_col2","_col3"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                      <-Union 5 [SIMPLE_EDGE]
+                        <-Reducer 12 [CONTAINS] vectorized
+                          Reduce Output Operator [RS_242]
+                            PartitionCols:_col0, _col1, _col2
+                            Group By Operator [GBY_241] (rows=165330890 width=282)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["count(_col3)"],keys:_col0, _col1, _col2
+                              Group By Operator [GBY_240] (rows=49146883 width=282)
+                                Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                Select Operator [SEL_239] (rows=49146883 width=274)
+                                  Output:["_col0","_col1","_col2"]
+                                  Group By Operator [GBY_238] (rows=49146883 width=274)
+                                    Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+                                  <-Reducer 11 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_40]
+                                      PartitionCols:_col0, _col1, _col2
+                                      Group By Operator [GBY_39] (rows=49146883 width=274)
+                                        Output:["_col0","_col1","_col2"],keys:_col6, _col5, _col3
+                                        Merge Join Operator [MERGEJOIN_175] (rows=49146883 width=274)
+                                          Conds:RS_35._col1=RS_217._col0(Inner),Output:["_col3","_col5","_col6"]
+                                        <-Map 18 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_217]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_215] (rows=80000000 width=184)
+                                              Output:["_col0","_col1","_col2"]
+                                              TableScan [TS_6] (rows=80000000 width=184)
+                                                default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_first_name","c_last_name"]
+                                        <-Reducer 10 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_35]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_174] (rows=49146883 width=97)
+                                              Conds:RS_237._col0=RS_200._col0(Inner),Output:["_col1","_col3"]
+                                            <-Map 8 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_200]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_197] (rows=317 width=98)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_196] (rows=317 width=102)
+                                                    predicate:d_month_seq BETWEEN 1212 AND 1223
+                                                    TableScan [TS_3] (rows=73049 width=102)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date","d_month_seq"]
+                                            <-Map 19 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_237]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_236] (rows=285117831 width=7)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_235] (rows=285117831 width=7)
+                                                    predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_33_date_dim_d_date_sk_min) AND DynamicValue(RS_33_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_33_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                                    TableScan [TS_24] (rows=287989836 width=7)
+                                                      default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk"]
+                                                    <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_234]
+                                                        Group By Operator [GBY_233] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_208]
+                                                            Group By Operator [GBY_205] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_201] (rows=317 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_197]
+                        <-Reducer 16 [CONTAINS] vectorized
+                          Reduce Output Operator [RS_252]
+                            PartitionCols:_col0, _col1, _col2
+                            Group By Operator [GBY_251] (rows=165330890 width=282)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["count(_col3)"],keys:_col0, _col1, _col2
+                              Group By Operator [GBY_250] (rows=24986582 width=282)
+                                Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                Select Operator [SEL_249] (rows=24986582 width=274)
+                                  Output:["_col0","_col1","_col2"]
+                                  Group By Operator [GBY_248] (rows=24986582 width=274)
+                                    Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+                                  <-Reducer 15 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_65]
+                                      PartitionCols:_col0, _col1, _col2
+                                      Group By Operator [GBY_64] (rows=24986582 width=274)
+                                        Output:["_col0","_col1","_col2"],keys:_col6, _col5, _col3
+                                        Merge Join Operator [MERGEJOIN_177] (rows=24986582 width=274)
+                                          Conds:RS_60._col1=RS_218._col0(Inner),Output:["_col3","_col5","_col6"]
+                                        <-Map 18 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_218]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_215]
+                                        <-Reducer 14 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_60]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_176] (rows=24986582 width=97)
+                                              Conds:RS_247._col0=RS_202._col0(Inner),Output:["_col1","_col3"]
+                                            <-Map 8 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_202]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_197]
+                                            <-Map 20 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_247]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_246] (rows=143930993 width=7)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_245] (rows=143930993 width=7)
+                                                    predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_58_date_dim_d_date_sk_min) AND DynamicValue(RS_58_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_58_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                    TableScan [TS_49] (rows=144002668 width=7)
+                                                      default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk"]
+                                                    <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_244]
+                                                        Group By Operator [GBY_243] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_209]
+                                                            Group By Operator [GBY_206] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_203] (rows=317 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_197]
+                        <-Reducer 4 [CONTAINS] vectorized
+                          Reduce Output Operator [RS_223]
+                            PartitionCols:_col0, _col1, _col2
+                            Group By Operator [GBY_222] (rows=165330890 width=282)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["count(_col3)"],keys:_col0, _col1, _col2
+                              Group By Operator [GBY_221] (rows=91197425 width=282)
+                                Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                Select Operator [SEL_220] (rows=91197425 width=274)
+                                  Output:["_col0","_col1","_col2"]
+                                  Group By Operator [GBY_219] (rows=91197425 width=274)
+                                    Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+                                  <-Reducer 3 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_16]
+                                      PartitionCols:_col0, _col1, _col2
+                                      Group By Operator [GBY_15] (rows=91197425 width=274)
+                                        Output:["_col0","_col1","_col2"],keys:_col6, _col5, _col3
+                                        Merge Join Operator [MERGEJOIN_173] (rows=91197425 width=274)
+                                          Conds:RS_11._col1=RS_216._col0(Inner),Output:["_col3","_col5","_col6"]
+                                        <-Map 18 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_216]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_215]
+                                        <-Reducer 2 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_11]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_172] (rows=91197425 width=96)
+                                              Conds:RS_214._col0=RS_198._col0(Inner),Output:["_col1","_col3"]
+                                            <-Map 8 [SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_198]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_197]
+                                            <-Map 1 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_214]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_213] (rows=525327388 width=7)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_212] (rows=525327388 width=7)
+                                                    predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_9_date_dim_d_date_sk_min) AND DynamicValue(RS_9_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_9_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                    TableScan [TS_0] (rows=575995635 width=7)
+                                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk"]
+                                                    <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_211]
+                                                        Group By Operator [GBY_210] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_207]
+                                                            Group By Operator [GBY_204] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_199] (rows=317 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_197]
+


[52/75] [abbrv] hive git commit: HIVE-20679: DDL operations on hive might create large messages for DBNotification (Anishek Agarwal, reviewed by Sankar Hariappan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java
deleted file mode 100644
index 6aa079d..0000000
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.hadoop.hive.metastore.messaging.json;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Predicate;
-import java.util.regex.PatternSyntaxException;
-
-import javax.annotation.Nullable;
-
-import org.apache.hadoop.hive.metastore.api.Catalog;
-import org.apache.hadoop.hive.metastore.api.Database;
-import org.apache.hadoop.hive.metastore.api.Function;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NotificationEvent;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
-import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
-import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
-import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.apache.hadoop.hive.metastore.api.TxnToWriteId;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
-import org.apache.hadoop.hive.metastore.events.AcidWriteEvent;
-import org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage;
-import org.apache.hadoop.hive.metastore.messaging.AddForeignKeyMessage;
-import org.apache.hadoop.hive.metastore.messaging.AddNotNullConstraintMessage;
-import org.apache.hadoop.hive.metastore.messaging.AddPartitionMessage;
-import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage;
-import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage;
-import org.apache.hadoop.hive.metastore.messaging.AllocWriteIdMessage;
-import org.apache.hadoop.hive.metastore.messaging.AlterCatalogMessage;
-import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage;
-import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage;
-import org.apache.hadoop.hive.metastore.messaging.AlterTableMessage;
-import org.apache.hadoop.hive.metastore.messaging.CommitTxnMessage;
-import org.apache.hadoop.hive.metastore.messaging.CreateCatalogMessage;
-import org.apache.hadoop.hive.metastore.messaging.CreateDatabaseMessage;
-import org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage;
-import org.apache.hadoop.hive.metastore.messaging.CreateTableMessage;
-import org.apache.hadoop.hive.metastore.messaging.DropCatalogMessage;
-import org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage;
-import org.apache.hadoop.hive.metastore.messaging.DropDatabaseMessage;
-import org.apache.hadoop.hive.metastore.messaging.DropFunctionMessage;
-import org.apache.hadoop.hive.metastore.messaging.DropPartitionMessage;
-import org.apache.hadoop.hive.metastore.messaging.DropTableMessage;
-import org.apache.hadoop.hive.metastore.messaging.InsertMessage;
-import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
-import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
-import org.apache.hadoop.hive.metastore.messaging.OpenTxnMessage;
-import org.apache.hadoop.hive.metastore.messaging.AcidWriteMessage;
-import org.apache.hadoop.hive.metastore.messaging.PartitionFiles;
-import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils;
-import org.apache.thrift.TBase;
-import org.apache.thrift.TDeserializer;
-import org.apache.thrift.TException;
-import org.apache.thrift.TSerializer;
-import org.apache.thrift.protocol.TJSONProtocol;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-
-import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.filterMapkeys;
-
-/**
- * The JSON implementation of the MessageFactory. Constructs JSON implementations of each
- * message-type.
- */
-public class JSONMessageFactory extends MessageFactory {
-
-  private static final Logger LOG = LoggerFactory.getLogger(JSONMessageFactory.class.getName());
-
-  private static JSONMessageDeserializer deserializer = new JSONMessageDeserializer();
-
-  private static List<Predicate<String>> paramsFilter;
-
-  @Override
-  public void init() throws MetaException {
-    super.init();
-
-    List<String> excludePatterns = Arrays.asList(MetastoreConf
-        .getTrimmedStringsVar(conf, MetastoreConf.ConfVars.EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS));
-    try {
-      paramsFilter = MetaStoreUtils.compilePatternsToPredicates(excludePatterns);
-    } catch (PatternSyntaxException e) {
-      LOG.error("Regex pattern compilation failed. Verify that "
-          + "metastore.notification.parameters.exclude.patterns has valid patterns.");
-      throw new MetaException("Regex pattern compilation failed. " + e.getMessage());
-    }
-  }
-
-  @Override
-  public MessageDeserializer getDeserializer() {
-    return deserializer;
-  }
-
-  @Override
-  public String getMessageFormat() {
-    return "json-0.2";
-  }
-
-  @Override
-  public CreateDatabaseMessage buildCreateDatabaseMessage(Database db) {
-    return new JSONCreateDatabaseMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, db, now());
-  }
-
-  @Override
-  public AlterDatabaseMessage buildAlterDatabaseMessage(Database beforeDb, Database afterDb) {
-    return new JSONAlterDatabaseMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
-                                        beforeDb, afterDb, now());
-  }
-
-  @Override
-  public DropDatabaseMessage buildDropDatabaseMessage(Database db) {
-    return new JSONDropDatabaseMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, db.getName(), now());
-  }
-
-  @Override
-  public CreateTableMessage buildCreateTableMessage(Table table, Iterator<String> fileIter) {
-    return new JSONCreateTableMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table, fileIter, now());
-  }
-
-  @Override
-  public AlterTableMessage buildAlterTableMessage(Table before, Table after, boolean isTruncateOp, Long writeId) {
-    return new JSONAlterTableMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, before, after, isTruncateOp, writeId, now());
-  }
-
-  @Override
-  public DropTableMessage buildDropTableMessage(Table table) {
-    return new JSONDropTableMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table, now());
-  }
-
-  @Override
-  public AddPartitionMessage buildAddPartitionMessage(Table table,
-      Iterator<Partition> partitionsIterator, Iterator<PartitionFiles> partitionFileIter) {
-    return new JSONAddPartitionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table,
-        partitionsIterator, partitionFileIter, now());
-  }
-
-  @Override
-  public AlterPartitionMessage buildAlterPartitionMessage(Table table, Partition before,
-      Partition after, boolean isTruncateOp, Long writeId) {
-    return new JSONAlterPartitionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
-                                        table, before, after, isTruncateOp, writeId, now());
-  }
-
-  @Override
-  public DropPartitionMessage buildDropPartitionMessage(Table table,
-      Iterator<Partition> partitionsIterator) {
-    return new JSONDropPartitionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table,
-        getPartitionKeyValues(table, partitionsIterator), now());
-  }
-
-  @Override
-  public CreateFunctionMessage buildCreateFunctionMessage(Function fn) {
-    return new JSONCreateFunctionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fn, now());
-  }
-
-  @Override
-  public DropFunctionMessage buildDropFunctionMessage(Function fn) {
-    return new JSONDropFunctionMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fn, now());
-  }
-
-  @Override
-  public InsertMessage buildInsertMessage(Table tableObj, Partition partObj,
-                                          boolean replace, Iterator<String> fileIter) {
-    return new JSONInsertMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
-                                tableObj, partObj, replace, fileIter, now());
-  }
-
-  @Override
-  public AddPrimaryKeyMessage buildAddPrimaryKeyMessage(List<SQLPrimaryKey> pks) {
-    return new JSONAddPrimaryKeyMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, pks, now());
-  }
-
-  @Override
-  public AddForeignKeyMessage buildAddForeignKeyMessage(List<SQLForeignKey> fks) {
-    return new JSONAddForeignKeyMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fks, now());
-  }
-
-  @Override
-  public AddUniqueConstraintMessage buildAddUniqueConstraintMessage(List<SQLUniqueConstraint> uks) {
-    return new JSONAddUniqueConstraintMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, uks, now());
-  }
-
-  @Override
-  public AddNotNullConstraintMessage buildAddNotNullConstraintMessage(List<SQLNotNullConstraint> nns) {
-    return new JSONAddNotNullConstraintMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, nns, now());
-  }
-
-  @Override
-  public DropConstraintMessage buildDropConstraintMessage(String dbName, String tableName,
-      String constraintName) {
-    return new JSONDropConstraintMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, dbName, tableName,
-        constraintName, now());
-  }
-
-  @Override
-  public CreateCatalogMessage buildCreateCatalogMessage(Catalog catalog) {
-    return new JSONCreateCatalogMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, catalog.getName(), now());
-  }
-
-  @Override
-  public AlterCatalogMessage buildAlterCatalogMessage(Catalog beforeCat, Catalog afterCat) {
-    return new JSONAlterCatalogMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
-        beforeCat, afterCat, now());
-  }
-
-  @Override
-  public DropCatalogMessage buildDropCatalogMessage(Catalog catalog) {
-    return new JSONDropCatalogMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, catalog.getName(), now());
-  }
-
-  @Override
-  public OpenTxnMessage buildOpenTxnMessage(Long fromTxnId, Long toTxnId) {
-    return new JSONOpenTxnMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, fromTxnId, toTxnId, now());
-  }
-
-  @Override
-  public CommitTxnMessage buildCommitTxnMessage(Long txnId) {
-    return new JSONCommitTxnMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, txnId, now());
-  }
-
-  @Override
-  public AbortTxnMessage buildAbortTxnMessage(Long txnId) {
-    return new JSONAbortTxnMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, txnId, now());
-  }
-
-  @Override
-  public AllocWriteIdMessage buildAllocWriteIdMessage(List<TxnToWriteId> txnToWriteIdList,
-                                                      String dbName, String tableName) {
-    return new JSONAllocWriteIdMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, txnToWriteIdList, dbName, tableName, now());
-  }
-
-  @Override
-  public AcidWriteMessage buildAcidWriteMessage(AcidWriteEvent acidWriteEvent, Iterator<String> files) {
-    return new JSONAcidWriteMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, now(), acidWriteEvent, files);
-  }
-
-  private long now() {
-    return System.currentTimeMillis() / 1000;
-  }
-
-  static Map<String, String> getPartitionKeyValues(Table table, Partition partition) {
-    Map<String, String> partitionKeys = new LinkedHashMap<>();
-    for (int i = 0; i < table.getPartitionKeysSize(); ++i) {
-      partitionKeys.put(table.getPartitionKeys().get(i).getName(), partition.getValues().get(i));
-    }
-    return partitionKeys;
-  }
-
-  static List<Map<String, String>> getPartitionKeyValues(final Table table,
-      Iterator<Partition> iterator) {
-    return Lists.newArrayList(Iterators.transform(iterator,
-        new com.google.common.base.Function<Partition, Map<String, String>>() {
-          @Override
-          public Map<String, String> apply(@Nullable Partition partition) {
-            return getPartitionKeyValues(table, partition);
-          }
-        }));
-  }
-
-  static String createPrimaryKeyObjJson(SQLPrimaryKey primaryKeyObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(primaryKeyObj, "UTF-8");
-  }
-
-  static String createForeignKeyObjJson(SQLForeignKey foreignKeyObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(foreignKeyObj, "UTF-8");
-  }
-
-  static String createUniqueConstraintObjJson(SQLUniqueConstraint uniqueConstraintObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(uniqueConstraintObj, "UTF-8");
-  }
-
-  static String createNotNullConstraintObjJson(SQLNotNullConstraint notNullConstaintObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(notNullConstaintObj, "UTF-8");
-  }
-
-  static String createDatabaseObjJson(Database dbObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(dbObj, "UTF-8");
-  }
-
-  static String createCatalogObjJson(Catalog catObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(catObj, "UTF-8");
-  }
-
-  static String createTableObjJson(Table tableObj) throws TException {
-    //Note: The parameters of the Table object will be removed in the filter if it matches
-    // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS
-    filterMapkeys(tableObj.getParameters(), paramsFilter);
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(tableObj, "UTF-8");
-  }
-
-  static String createPartitionObjJson(Partition partitionObj) throws TException {
-    //Note: The parameters of the Partition object will be removed in the filter if it matches
-    // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS
-    filterMapkeys(partitionObj.getParameters(), paramsFilter);
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(partitionObj, "UTF-8");
-  }
-
-  static String createFunctionObjJson(Function functionObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(functionObj, "UTF-8");
-  }
-
-  public static ObjectNode getJsonTree(NotificationEvent event) throws Exception {
-    return getJsonTree(event.getMessage());
-  }
-
-  public static ObjectNode getJsonTree(String eventMessage) throws Exception {
-    JsonParser jsonParser = (new JsonFactory()).createJsonParser(eventMessage);
-    ObjectMapper mapper = new ObjectMapper();
-    return mapper.readValue(jsonParser, ObjectNode.class);
-  }
-
-  public static Table getTableObj(ObjectNode jsonTree) throws Exception {
-    TDeserializer deSerializer = new TDeserializer(new TJSONProtocol.Factory());
-    Table tableObj = new Table();
-    String tableJson = jsonTree.get("tableObjJson").asText();
-    deSerializer.deserialize(tableObj, tableJson, "UTF-8");
-    return tableObj;
-  }
-
-  /*
-   * TODO: Some thoughts here : We have a current todo to move some of these methods over to
-   * MessageFactory instead of being here, so we can override them, but before we move them over,
-   * we should keep the following in mind:
-   *
-   * a) We should return Iterables, not Lists. That makes sure that we can be memory-safe when
-   * implementing it rather than forcing ourselves down a path wherein returning List is part of
-   * our interface, and then people use .size() or somesuch which makes us need to materialize
-   * the entire list and not change. Also, returning Iterables allows us to do things like
-   * Iterables.transform for some of these.
-   * b) We should not have "magic" names like "tableObjJson", because that breaks expectation of a
-   * couple of things - firstly, that of serialization format, although that is fine for this
-   * JSONMessageFactory, and secondly, that makes us just have a number of mappings, one for each
-   * obj type, and sometimes, as the case is with alter, have multiples. Also, any event-specific
-   * item belongs in that event message / event itself, as opposed to in the factory. It's okay to
-   * have utility accessor methods here that are used by each of the messages to provide accessors.
-   * I'm adding a couple of those here.
-   *
-   */
-
-  public static TBase getTObj(String tSerialized, Class<? extends TBase> objClass) throws Exception{
-    TDeserializer thriftDeSerializer = new TDeserializer(new TJSONProtocol.Factory());
-    TBase obj = objClass.newInstance();
-    thriftDeSerializer.deserialize(obj, tSerialized, "UTF-8");
-    return obj;
-  }
-
-  public static Iterable<? extends TBase> getTObjs(
-      Iterable<String> objRefStrs, final Class<? extends TBase> objClass) throws Exception {
-
-    try {
-      return Iterables.transform(objRefStrs, new com.google.common.base.Function<String,TBase>(){
-        @Override
-        public TBase apply(@Nullable String objStr){
-          try {
-            return getTObj(objStr, objClass);
-          } catch (Exception e) {
-            throw new RuntimeException(e);
-          }
-        }
-      });
-    } catch (RuntimeException re){
-      // We have to add this bit of exception handling here, because Function.apply does not allow us to throw
-      // the actual exception that might be a checked exception, so we wind up needing to throw a RuntimeException
-      // with the previously thrown exception as its cause. However, since RuntimeException.getCause() returns
-      // a throwable instead of an Exception, we have to account for the possibility that the underlying code
-      // might have thrown a Throwable that we wrapped instead, in which case, continuing to throw the
-      // RuntimeException is the best thing we can do.
-      Throwable t = re.getCause();
-      if (t instanceof Exception){
-        throw (Exception) t;
-      } else {
-        throw re;
-      }
-    }
-  }
-
-  // If we do not need this format of accessor using ObjectNode, this is a candidate for removal as well
-  public static Iterable<? extends TBase> getTObjs(
-      ObjectNode jsonTree, String objRefListName, final Class<? extends TBase> objClass) throws Exception {
-    Iterable<JsonNode> jsonArrayIterator = jsonTree.get(objRefListName);
-    com.google.common.base.Function<JsonNode,String> textExtractor =
-        new com.google.common.base.Function<JsonNode, String>() {
-      @Nullable
-      @Override
-      public String apply(@Nullable JsonNode input) {
-        return input.asText();
-      }
-    };
-    return getTObjs(Iterables.transform(jsonArrayIterator, textExtractor), objClass);
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java
new file mode 100644
index 0000000..9c64e33
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/DeSerializer.java
@@ -0,0 +1,181 @@
+package org.apache.hadoop.hive.metastore.messaging.json.gzip;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage;
+import org.apache.hadoop.hive.metastore.messaging.AcidWriteMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddForeignKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddNotNullConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.AllocWriteIdMessage;
+import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.AlterTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.CommitTxnMessage;
+import org.apache.hadoop.hive.metastore.messaging.CreateDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage;
+import org.apache.hadoop.hive.metastore.messaging.CreateTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropFunctionMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.InsertMessage;
+import org.apache.hadoop.hive.metastore.messaging.OpenTxnMessage;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageDeserializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.zip.GZIPInputStream;
+
+
+public class DeSerializer extends JSONMessageDeserializer {
+  private static final Logger LOG = LoggerFactory.getLogger(Serializer.class.getName());
+
+  private static String deCompress(String messageBody) {
+    byte[] decodedBytes = Base64.getDecoder().decode(messageBody.getBytes(StandardCharsets.UTF_8));
+    try (
+        ByteArrayInputStream in = new ByteArrayInputStream(decodedBytes);
+        GZIPInputStream is = new GZIPInputStream(in)
+    ) {
+      byte[] bytes = IOUtils.toByteArray(is);
+      return new String(bytes, StandardCharsets.UTF_8);
+    } catch (IOException e) {
+      LOG.error("cannot decode the stream", e);
+      LOG.debug("base64 encoded String", messageBody);
+      throw new RuntimeException("cannot decode the stream ", e);
+    }
+  }
+
+  /**
+   * this is mainly as a utility to allow debugging of messages for developers by providing the
+   * message in a file and getting an actual message out.
+   * This class on a deployed hive instance will also be bundled in hive-exec jar.
+   *
+   */
+  public static void main(String[] args) throws IOException {
+    if(args.length != 1) {
+      System.out.println("Usage:");
+      System.out.println("java -cp [classpath] "+DeSerializer.class.getCanonicalName() +" [file_location]");
+    }
+    System.out.print(
+        deCompress(FileUtils.readFileToString(new File(args[0]), StandardCharsets.UTF_8)));
+  }
+
+  @Override
+  public CreateDatabaseMessage getCreateDatabaseMessage(String messageBody) {
+    return super.getCreateDatabaseMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AlterDatabaseMessage getAlterDatabaseMessage(String messageBody) {
+    return super.getAlterDatabaseMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public DropDatabaseMessage getDropDatabaseMessage(String messageBody) {
+    return super.getDropDatabaseMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public CreateTableMessage getCreateTableMessage(String messageBody) {
+    return super.getCreateTableMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AlterTableMessage getAlterTableMessage(String messageBody) {
+    return super.getAlterTableMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public DropTableMessage getDropTableMessage(String messageBody) {
+    return super.getDropTableMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AddPartitionMessage getAddPartitionMessage(String messageBody) {
+    return super.getAddPartitionMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AlterPartitionMessage getAlterPartitionMessage(String messageBody) {
+    return super.getAlterPartitionMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public DropPartitionMessage getDropPartitionMessage(String messageBody) {
+    return super.getDropPartitionMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public CreateFunctionMessage getCreateFunctionMessage(String messageBody) {
+    return super.getCreateFunctionMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public DropFunctionMessage getDropFunctionMessage(String messageBody) {
+    return super.getDropFunctionMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public InsertMessage getInsertMessage(String messageBody) {
+    return super.getInsertMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AddPrimaryKeyMessage getAddPrimaryKeyMessage(String messageBody) {
+    return super.getAddPrimaryKeyMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AddForeignKeyMessage getAddForeignKeyMessage(String messageBody) {
+    return super.getAddForeignKeyMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AddUniqueConstraintMessage getAddUniqueConstraintMessage(String messageBody) {
+    return super.getAddUniqueConstraintMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AddNotNullConstraintMessage getAddNotNullConstraintMessage(String messageBody) {
+    return super.getAddNotNullConstraintMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public DropConstraintMessage getDropConstraintMessage(String messageBody) {
+    return super.getDropConstraintMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public OpenTxnMessage getOpenTxnMessage(String messageBody) {
+    return super.getOpenTxnMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public CommitTxnMessage getCommitTxnMessage(String messageBody) {
+    return super.getCommitTxnMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AbortTxnMessage getAbortTxnMessage(String messageBody) {
+    return super.getAbortTxnMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AllocWriteIdMessage getAllocWriteIdMessage(String messageBody) {
+    return super.getAllocWriteIdMessage(deCompress(messageBody));
+  }
+
+  @Override
+  public AcidWriteMessage getAcidWriteMessage(String messageBody) {
+    return super.getAcidWriteMessage(deCompress(messageBody));
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/GzipJSONMessageEncoder.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/GzipJSONMessageEncoder.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/GzipJSONMessageEncoder.java
new file mode 100644
index 0000000..07b01a9
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/GzipJSONMessageEncoder.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.messaging.json.gzip;
+
+import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
+import org.apache.hadoop.hive.metastore.messaging.MessageEncoder;
+import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.MessageSerializer;
+
+/**
+ * This implementation gzips and then Base64 encodes the message before writing it out.
+ * This MessageEncoder will break the backward compatibility for hive replication v1 which uses webhcat endpoints.
+ */
+public class GzipJSONMessageEncoder implements MessageEncoder {
+  public static final String FORMAT = "gzip(json-2.0)";
+
+  static {
+    MessageFactory.register(FORMAT, GzipJSONMessageEncoder.class);
+  }
+
+  private static DeSerializer deSerializer = new DeSerializer();
+  private static Serializer serializer = new Serializer();
+
+  private static volatile MessageEncoder instance;
+
+  public static MessageEncoder getInstance() {
+    if (instance == null) {
+      synchronized (GzipJSONMessageEncoder.class) {
+        if (instance == null) {
+          instance = new GzipJSONMessageEncoder();
+        }
+      }
+    }
+    return instance;
+  }
+
+  @Override
+  public MessageDeserializer getDeserializer() {
+    return deSerializer;
+  }
+
+  @Override
+  public MessageSerializer getSerializer() {
+    return serializer;
+  }
+
+  @Override
+  public String getMessageFormat() {
+    return FORMAT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java
new file mode 100644
index 0000000..c40600d
--- /dev/null
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/gzip/Serializer.java
@@ -0,0 +1,32 @@
+package org.apache.hadoop.hive.metastore.messaging.json.gzip;
+
+import org.apache.hadoop.hive.metastore.messaging.EventMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.zip.GZIPOutputStream;
+
+class Serializer implements MessageSerializer {
+  private static final Logger LOG = LoggerFactory.getLogger(Serializer.class.getName());
+
+  @Override
+  public String serialize(EventMessage message) {
+    String messageAsString = MessageSerializer.super.serialize(message);
+    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+      GZIPOutputStream gout = new GZIPOutputStream(baos);
+      gout.write(messageAsString.getBytes(StandardCharsets.UTF_8));
+      gout.close();
+      byte[] compressed = baos.toByteArray();
+      return new String(Base64.getEncoder().encode(compressed), StandardCharsets.UTF_8);
+    } catch (IOException e) {
+      LOG.error("could not use gzip output stream", e);
+      LOG.debug("message " + messageAsString);
+      throw new RuntimeException("could not use the gzip output Stream", e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
index 3d36b60..b01a632 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
@@ -23,6 +23,7 @@ import java.net.ConnectException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -42,6 +43,8 @@ import org.slf4j.LoggerFactory;
 import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
 
 public class MetaStoreTestUtils {
+  private static Map<Integer, Thread> map = new HashMap<>();
+
   private static final Logger LOG = LoggerFactory.getLogger(MetaStoreTestUtils.class);
   private static final String TMP_DIR = System.getProperty("test.tmp.dir");
   public static final int RETRY_COUNT = 10;
@@ -75,9 +78,17 @@ public class MetaStoreTestUtils {
     }, "MetaStoreThread-" + port);
     thread.setDaemon(true);
     thread.start();
+    map.put(port,thread);
     MetaStoreTestUtils.loopUntilHMSReady(port);
   }
 
+  public static void close(final int port){
+    Thread thread = map.get(port);
+    if(thread != null){
+      thread.stop();
+    }
+  }
+
   public static int startMetaStoreWithRetry(final HadoopThriftAuthBridge bridge) throws Exception {
     return MetaStoreTestUtils.startMetaStoreWithRetry(bridge, MetastoreConf.newMetastoreConf());
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/testutils/ptest2/conf/deployed/master-mr2.properties
----------------------------------------------------------------------
diff --git a/testutils/ptest2/conf/deployed/master-mr2.properties b/testutils/ptest2/conf/deployed/master-mr2.properties
index 23ad0f6..ad5405f 100644
--- a/testutils/ptest2/conf/deployed/master-mr2.properties
+++ b/testutils/ptest2/conf/deployed/master-mr2.properties
@@ -68,7 +68,7 @@ ut.service.batchSize=8
 
 unitTests.module.itests.hive-unit=itests.hive-unit
 ut.itests.hive-unit.batchSize=9
-ut.itests.hive-unit.skipBatching=TestAcidOnTezWithSplitUpdate TestAcidOnTez TestMTQueries TestCompactor TestSchedulerQueue TestOperationLoggingAPIWithTez TestSSL TestJdbcDriver2 TestJdbcWithMiniHA TestJdbcWithMiniMr
+ut.itests.hive-unit.skipBatching=TestAcidOnTezWithSplitUpdate TestAcidOnTez TestMTQueries TestCompactor TestSchedulerQueue TestOperationLoggingAPIWithTez TestSSL TestJdbcDriver2 TestJdbcWithMiniHA TestJdbcWithMiniMr TestReplicationScenariosIncrementalLoadAcidTables TestReplIncrementalLoadAcidTablesWithJsonMessage TestReplicationScenarios TestReplWithJsonMessageFormat
 
 unitTests.module.itests.qtest=itests.qtest
 ut.itests.qtest.batchSize=9


[14/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out
new file mode 100644
index 0000000..b57ded3
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query56.q.out
@@ -0,0 +1,470 @@
+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
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 17 <- Reducer 21 (BROADCAST_EDGE), Reducer 29 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE)
+Map 32 <- Reducer 11 (BROADCAST_EDGE), Reducer 24 (BROADCAST_EDGE), Reducer 30 (BROADCAST_EDGE)
+Map 33 <- Reducer 14 (BROADCAST_EDGE), Reducer 27 (BROADCAST_EDGE), Reducer 31 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 11 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Reducer 2 (SIMPLE_EDGE), Reducer 26 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 14 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE)
+Reducer 18 <- Map 17 (SIMPLE_EDGE), Map 20 (SIMPLE_EDGE)
+Reducer 19 <- Map 28 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 16 (ONE_TO_ONE_EDGE)
+Reducer 21 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 22 <- Map 20 (SIMPLE_EDGE), Map 32 (SIMPLE_EDGE)
+Reducer 23 <- Map 28 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Map 20 (SIMPLE_EDGE), Map 33 (SIMPLE_EDGE)
+Reducer 26 <- Map 28 (SIMPLE_EDGE), Reducer 25 (SIMPLE_EDGE)
+Reducer 27 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 19 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 31 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Reducer 2 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_370]
+        Limit [LIM_369] (rows=100 width=212)
+          Number of rows:100
+          Select Operator [SEL_368] (rows=430 width=212)
+            Output:["_col0","_col1"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_367]
+              Group By Operator [GBY_366] (rows=430 width=212)
+                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Union 5 [SIMPLE_EDGE]
+                <-Reducer 10 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_382]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_381] (rows=430 width=212)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_380] (rows=430 width=212)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 9 [SIMPLE_EDGE]
+                        SHUFFLE [RS_69]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_68] (rows=430 width=212)
+                            Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_304] (rows=373066 width=100)
+                              Conds:RS_64._col0=RS_65._col3(Inner),Output:["_col1","_col7"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_64]
+                                PartitionCols:_col0
+                                Merge Join Operator [MERGEJOIN_294] (rows=17170 width=104)
+                                  Conds:RS_319._col1=RS_325._col0(Inner),Output:["_col0","_col1"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_319]
+                                    PartitionCols:_col1
+                                    Select Operator [SEL_318] (rows=462000 width=104)
+                                      Output:["_col0","_col1"]
+                                      TableScan [TS_0] (rows=462000 width=104)
+                                        default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                                <-Reducer 16 [ONE_TO_ONE_EDGE] vectorized
+                                  FORWARD [RS_325]
+                                    PartitionCols:_col0
+                                    Group By Operator [GBY_324] (rows=11550 width=100)
+                                      Output:["_col0"],keys:KEY._col0
+                                    <-Map 15 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_323]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_322] (rows=11550 width=100)
+                                          Output:["_col0"],keys:i_item_id
+                                          Select Operator [SEL_321] (rows=23100 width=189)
+                                            Output:["i_item_id"]
+                                            Filter Operator [FIL_320] (rows=23100 width=189)
+                                              predicate:(i_color) IN ('orchid', 'chiffon', 'lace')
+                                              TableScan [TS_2] (rows=462000 width=189)
+                                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_id","i_color"]
+                            <-Reducer 23 [SIMPLE_EDGE]
+                              SHUFFLE [RS_65]
+                                PartitionCols:_col3
+                                Select Operator [SEL_60] (rows=1550375 width=13)
+                                  Output:["_col3","_col4"]
+                                  Merge Join Operator [MERGEJOIN_299] (rows=1550375 width=13)
+                                    Conds:RS_57._col1=RS_346._col0(Inner),Output:["_col2","_col3"]
+                                  <-Map 28 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_346]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_343] (rows=8000000 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_342] (rows=8000000 width=112)
+                                          predicate:(ca_gmt_offset = -8)
+                                          TableScan [TS_15] (rows=40000000 width=112)
+                                            default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_gmt_offset"]
+                                  <-Reducer 22 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_57]
+                                      PartitionCols:_col1
+                                      Merge Join Operator [MERGEJOIN_298] (rows=7751872 width=98)
+                                        Conds:RS_379._col0=RS_330._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 20 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_330]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_327] (rows=50 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_326] (rows=50 width=12)
+                                              predicate:((d_moy = 1) and (d_year = 2000))
+                                              TableScan [TS_12] (rows=73049 width=12)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                      <-Map 32 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_379]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_378] (rows=285117733 width=123)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_377] (rows=285117733 width=123)
+                                              predicate:((cs_bill_addr_sk BETWEEN DynamicValue(RS_58_customer_address_ca_address_sk_min) AND DynamicValue(RS_58_customer_address_ca_address_sk_max) and in_bloom_filter(cs_bill_addr_sk, DynamicValue(RS_58_customer_address_ca_address_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_64_item_i_item_sk_min) AND DynamicValue(RS_64_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_64_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_55_date_dim_d_date_sk_min) AND DynamicValue(RS_55_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_55_date_dim_d_date_sk_bloom_filter))) and cs_bill_addr_sk is not null and cs_sold_date_sk is not null)
+                                              TableScan [TS_45] (rows=287989836 width=123)
+                                                default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_addr_sk","cs_item_sk","cs_ext_sales_price"]
+                                              <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_376]
+                                                  Group By Operator [GBY_375] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                    SHUFFLE [RS_239]
+                                                      Group By Operator [GBY_238] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_237] (rows=17170 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                                              <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_372]
+                                                  Group By Operator [GBY_371] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_338]
+                                                      Group By Operator [GBY_335] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_331] (rows=50 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_327]
+                                              <-Reducer 30 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_374]
+                                                  Group By Operator [GBY_373] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                  <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_354]
+                                                      Group By Operator [GBY_351] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                        Select Operator [SEL_347] (rows=8000000 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_343]
+                <-Reducer 13 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_394]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_393] (rows=430 width=212)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_392] (rows=430 width=212)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 12 [SIMPLE_EDGE]
+                        SHUFFLE [RS_106]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_105] (rows=430 width=212)
+                            Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_305] (rows=189670 width=190)
+                              Conds:RS_101._col0=RS_102._col2(Inner),Output:["_col1","_col7"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_101]
+                                PartitionCols:_col0
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                            <-Reducer 26 [SIMPLE_EDGE]
+                              SHUFFLE [RS_102]
+                                PartitionCols:_col2
+                                Select Operator [SEL_97] (rows=788222 width=110)
+                                  Output:["_col2","_col4"]
+                                  Merge Join Operator [MERGEJOIN_302] (rows=788222 width=110)
+                                    Conds:RS_94._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 28 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_348]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select Operator [SEL_343]
+                                  <-Reducer 25 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_94]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_301] (rows=3941109 width=118)
+                                        Conds:RS_391._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 20 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_332]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_327]
+                                      <-Map 33 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_391]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_390] (rows=143931246 width=123)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_389] (rows=143931246 width=123)
+                                              predicate:((ws_bill_addr_sk BETWEEN DynamicValue(RS_95_customer_address_ca_address_sk_min) AND DynamicValue(RS_95_customer_address_ca_address_sk_max) and in_bloom_filter(ws_bill_addr_sk, DynamicValue(RS_95_customer_address_ca_address_sk_bloom_filter))) and (ws_item_sk BETWEEN DynamicValue(RS_101_item_i_item_sk_min) AND DynamicValue(RS_101_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_101_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_92_date_dim_d_date_sk_min) AND DynamicValue(RS_92_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_92_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
+                                              TableScan [TS_82] (rows=144002668 width=123)
+                                                default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                                              <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_388]
+                                                  Group By Operator [GBY_387] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                    SHUFFLE [RS_285]
+                                                      Group By Operator [GBY_284] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_283] (rows=17170 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                                              <-Reducer 27 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_384]
+                                                  Group By Operator [GBY_383] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_339]
+                                                      Group By Operator [GBY_336] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_333] (rows=50 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_327]
+                                              <-Reducer 31 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_386]
+                                                  Group By Operator [GBY_385] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                  <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_355]
+                                                      Group By Operator [GBY_352] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                        Select Operator [SEL_349] (rows=8000000 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_343]
+                <-Reducer 4 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_365]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_364] (rows=430 width=212)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Group By Operator [GBY_363] (rows=430 width=212)
+                        Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                      <-Reducer 3 [SIMPLE_EDGE]
+                        SHUFFLE [RS_33]
+                          PartitionCols:_col0
+                          Group By Operator [GBY_32] (rows=430 width=212)
+                            Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                            Merge Join Operator [MERGEJOIN_303] (rows=692265 width=100)
+                              Conds:RS_28._col0=RS_29._col2(Inner),Output:["_col1","_col7"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_28]
+                                PartitionCols:_col0
+                                 Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+                            <-Reducer 19 [SIMPLE_EDGE]
+                              SHUFFLE [RS_29]
+                                PartitionCols:_col2
+                                Select Operator [SEL_24] (rows=2876890 width=4)
+                                  Output:["_col2","_col4"]
+                                  Merge Join Operator [MERGEJOIN_296] (rows=2876890 width=4)
+                                    Conds:RS_21._col2=RS_344._col0(Inner),Output:["_col1","_col3"]
+                                  <-Map 28 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_344]
+                                      PartitionCols:_col0
+                                       Please refer to the previous Select Operator [SEL_343]
+                                  <-Reducer 18 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_21]
+                                      PartitionCols:_col2
+                                      Merge Join Operator [MERGEJOIN_295] (rows=14384447 width=4)
+                                        Conds:RS_362._col0=RS_328._col0(Inner),Output:["_col1","_col2","_col3"]
+                                      <-Map 20 [SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_328]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_327]
+                                      <-Map 17 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_362]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_361] (rows=525327191 width=118)
+                                            Output:["_col0","_col1","_col2","_col3"]
+                                            Filter Operator [FIL_360] (rows=525327191 width=118)
+                                              predicate:((ss_addr_sk BETWEEN DynamicValue(RS_22_customer_address_ca_address_sk_min) AND DynamicValue(RS_22_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_22_customer_address_ca_address_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_28_item_i_item_sk_min) AND DynamicValue(RS_28_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_28_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_19_date_dim_d_date_sk_min) AND DynamicValue(RS_19_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_19_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
+                                              TableScan [TS_9] (rows=575995635 width=118)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
+                                              <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_341]
+                                                  Group By Operator [GBY_340] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_337]
+                                                      Group By Operator [GBY_334] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_329] (rows=50 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_327]
+                                              <-Reducer 29 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_357]
+                                                  Group By Operator [GBY_356] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                  <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                    PARTITION_ONLY_SHUFFLE [RS_353]
+                                                      Group By Operator [GBY_350] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                        Select Operator [SEL_345] (rows=8000000 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Select Operator [SEL_343]
+                                              <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                                BROADCAST [RS_359]
+                                                  Group By Operator [GBY_358] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                  <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                    SHUFFLE [RS_203]
+                                                      Group By Operator [GBY_202] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                        Select Operator [SEL_201] (rows=17170 width=4)
+                                                          Output:["_col0"]
+                                                           Please refer to the previous Merge Join Operator [MERGEJOIN_294]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query57.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query57.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query57.q.out
new file mode 100644
index 0000000..484a302
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query57.q.out
@@ -0,0 +1,260 @@
+PREHOOK: query: explain
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@call_center
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@call_center
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 13 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 3 <- Map 14 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 15 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE), Reducer 9 (ONE_TO_ONE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 11 (SIMPLE_EDGE), Reducer 6 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_321]
+        Limit [LIM_320] (rows=100 width=758)
+          Number of rows:100
+          Select Operator [SEL_319] (rows=130121 width=758)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 7 [SIMPLE_EDGE]
+            SHUFFLE [RS_110]
+              Select Operator [SEL_109] (rows=130121 width=758)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                Merge Join Operator [MERGEJOIN_278] (rows=130121 width=646)
+                  Conds:RS_106._col5, _col6, _col12, _col7=RS_306._col0, _col1, _col4, _col2(Inner),Output:["_col3","_col5","_col6","_col8","_col9","_col10","_col11","_col16"]
+                <-Reducer 6 [SIMPLE_EDGE] vectorized
+                  SHUFFLE [RS_306]
+                    PartitionCols:_col0, _col1, _col4, _col2
+                    Select Operator [SEL_304] (rows=87441185 width=404)
+                      Output:["_col0","_col1","_col2","_col3","_col4"]
+                      Filter Operator [FIL_302] (rows=87441185 width=408)
+                        predicate:rank_window_0 is not null
+                        PTF Operator [PTF_300] (rows=87441185 width=408)
+                          Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col2 ASC NULLS LAST, _col3 ASC NULLS LAST","partition by:":"_col1, _col0, _col4"}]
+                          Select Operator [SEL_299] (rows=87441185 width=408)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                          <-Reducer 5 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_297]
+                              PartitionCols:_col1, _col0, _col4
+                              Group By Operator [GBY_296] (rows=87441185 width=408)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                              <-Reducer 4 [SIMPLE_EDGE]
+                                SHUFFLE [RS_93]
+                                  PartitionCols:_col0, _col1, _col2, _col3, _col4
+                                  Group By Operator [GBY_92] (rows=87441185 width=408)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col3)"],keys:_col10, _col11, _col5, _col6, _col8
+                                    Merge Join Operator [MERGEJOIN_276] (rows=87441185 width=406)
+                                      Conds:RS_88._col2=RS_295._col0(Inner),Output:["_col3","_col5","_col6","_col8","_col10","_col11"]
+                                    <-Map 15 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_295]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_294] (rows=462000 width=194)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_293] (rows=462000 width=194)
+                                            predicate:(i_brand is not null and i_category is not null)
+                                            TableScan [TS_79] (rows=462000 width=194)
+                                              default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand","i_category"]
+                                    <-Reducer 3 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_88]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_275] (rows=87441185 width=220)
+                                          Conds:RS_85._col1=RS_292._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col8"]
+                                        <-Map 14 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_292]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_291] (rows=60 width=102)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_290] (rows=60 width=102)
+                                                predicate:cc_name is not null
+                                                TableScan [TS_76] (rows=60 width=102)
+                                                  default@call_center,call_center,Tbl:COMPLETE,Col:COMPLETE,Output:["cc_call_center_sk","cc_name"]
+                                        <-Reducer 2 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_85]
+                                            PartitionCols:_col1
+                                            Merge Join Operator [MERGEJOIN_274] (rows=87441185 width=126)
+                                              Conds:RS_289._col0=RS_281._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6"]
+                                            <-Map 12 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_281]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_280] (rows=564 width=12)
+                                                  Output:["_col0","_col1","_col2"]
+                                                  Filter Operator [FIL_279] (rows=564 width=12)
+                                                    predicate:(((d_year = 2000) or (struct(d_year,d_moy)) IN (const struct(1999,12), const struct(2001,1))) and (d_year) IN (2000, 1999, 2001))
+                                                    TableScan [TS_73] (rows=73049 width=12)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                            <-Map 1 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_289]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_288] (rows=285117980 width=123)
+                                                  Output:["_col0","_col1","_col2","_col3"]
+                                                  Filter Operator [FIL_287] (rows=285117980 width=123)
+                                                    predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_83_date_dim_d_date_sk_min) AND DynamicValue(RS_83_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_83_date_dim_d_date_sk_bloom_filter))) and cs_call_center_sk is not null and cs_sold_date_sk is not null)
+                                                    TableScan [TS_70] (rows=287989836 width=123)
+                                                      default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_call_center_sk","cs_item_sk","cs_sales_price"]
+                                                    <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                      BROADCAST [RS_286]
+                                                        Group By Operator [GBY_285] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                        <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_284]
+                                                            Group By Operator [GBY_283] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                              Select Operator [SEL_282] (rows=564 width=4)
+                                                                Output:["_col0"]
+                                                                 Please refer to the previous Select Operator [SEL_280]
+                <-Reducer 9 [ONE_TO_ONE_EDGE]
+                  FORWARD [RS_106]
+                    PartitionCols:_col5, _col6, _col12, _col7
+                    Merge Join Operator [MERGEJOIN_277] (rows=130121 width=636)
+                      Conds:RS_307._col0, _col1, _col4, _col2=RS_318._col0, _col1, _col7, _col2(Inner),Output:["_col3","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                    <-Reducer 6 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_307]
+                        PartitionCols:_col0, _col1, _col4, _col2
+                        Select Operator [SEL_305] (rows=87441185 width=404)
+                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                          Filter Operator [FIL_303] (rows=87441185 width=408)
+                            predicate:rank_window_0 is not null
+                            PTF Operator [PTF_301] (rows=87441185 width=408)
+                              Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col2 ASC NULLS LAST, _col3 ASC NULLS LAST","partition by:":"_col1, _col0, _col4"}]
+                               Please refer to the previous Select Operator [SEL_299]
+                    <-Reducer 11 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_318]
+                        PartitionCols:_col0, _col1, _col7, _col2
+                        Select Operator [SEL_317] (rows=130121 width=524)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                          Filter Operator [FIL_316] (rows=130121 width=524)
+                            predicate:CASE WHEN ((_col0 > 0)) THEN (((abs((_col6 - _col0)) / _col0) > 0.1)) ELSE (null) END
+                            Select Operator [SEL_315] (rows=260242 width=520)
+                              Output:["rank_window_1","_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                              Filter Operator [FIL_314] (rows=260242 width=520)
+                                predicate:((_col0 > 0) and (_col3 = 2000) and rank_window_1 is not null)
+                                PTF Operator [PTF_313] (rows=87441185 width=520)
+                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col3 ASC NULLS LAST, _col4 ASC NULLS LAST","partition by:":"_col2, _col1, _col5"}]
+                                  Select Operator [SEL_312] (rows=87441185 width=520)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                  <-Reducer 10 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_311]
+                                      PartitionCols:_col1, _col0, _col4
+                                      Select Operator [SEL_310] (rows=87441185 width=408)
+                                        Output:["avg_window_0","_col0","_col1","_col2","_col3","_col4","_col5"]
+                                        PTF Operator [PTF_309] (rows=87441185 width=408)
+                                          Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 ASC NULLS FIRST, _col0 ASC NULLS FIRST, _col4 ASC NULLS FIRST, _col2 ASC NULLS FIRST","partition by:":"_col1, _col0, _col4, _col2"}]
+                                          Select Operator [SEL_308] (rows=87441185 width=408)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                          <-Reducer 5 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_298]
+                                              PartitionCols:_col1, _col0, _col4, _col2
+                                               Please refer to the previous Group By Operator [GBY_296]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query58.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query58.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query58.q.out
new file mode 100644
index 0000000..ac9e412
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query58.q.out
@@ -0,0 +1,397 @@
+Warning: Shuffle Join MERGEJOIN[401][tables = [$hdt$_4, $hdt$_5]] in Stage 'Reducer 22' is a cross product
+PREHOOK: query: explain
+with ss_items as
+ (select i_item_id item_id
+        ,sum(ss_ext_sales_price) ss_item_rev 
+ from store_sales
+     ,item
+     ,date_dim
+ where ss_item_sk = i_item_sk
+   and d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+   and ss_sold_date_sk   = d_date_sk
+ group by i_item_id),
+ cs_items as
+ (select i_item_id item_id
+        ,sum(cs_ext_sales_price) cs_item_rev
+  from catalog_sales
+      ,item
+      ,date_dim
+ where cs_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+  and  cs_sold_date_sk = d_date_sk
+ group by i_item_id),
+ ws_items as
+ (select i_item_id item_id
+        ,sum(ws_ext_sales_price) ws_item_rev
+  from web_sales
+      ,item
+      ,date_dim
+ where ws_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq =(select d_week_seq 
+                                     from date_dim
+                                     where d_date = '1998-02-19'))
+  and ws_sold_date_sk   = d_date_sk
+ group by i_item_id)
+  select  ss_items.item_id
+       ,ss_item_rev
+       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
+       ,cs_item_rev
+       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
+       ,ws_item_rev
+       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
+       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
+ from ss_items,cs_items,ws_items
+ where ss_items.item_id=cs_items.item_id
+   and ss_items.item_id=ws_items.item_id 
+   and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+ order by item_id
+         ,ss_item_rev
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with ss_items as
+ (select i_item_id item_id
+        ,sum(ss_ext_sales_price) ss_item_rev 
+ from store_sales
+     ,item
+     ,date_dim
+ where ss_item_sk = i_item_sk
+   and d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+   and ss_sold_date_sk   = d_date_sk
+ group by i_item_id),
+ cs_items as
+ (select i_item_id item_id
+        ,sum(cs_ext_sales_price) cs_item_rev
+  from catalog_sales
+      ,item
+      ,date_dim
+ where cs_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+  and  cs_sold_date_sk = d_date_sk
+ group by i_item_id),
+ ws_items as
+ (select i_item_id item_id
+        ,sum(ws_ext_sales_price) ws_item_rev
+  from web_sales
+      ,item
+      ,date_dim
+ where ws_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq =(select d_week_seq 
+                                     from date_dim
+                                     where d_date = '1998-02-19'))
+  and ws_sold_date_sk   = d_date_sk
+ group by i_item_id)
+  select  ss_items.item_id
+       ,ss_item_rev
+       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
+       ,cs_item_rev
+       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
+       ,ws_item_rev
+       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
+       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
+ from ss_items,cs_items,ws_items
+ where ss_items.item_id=cs_items.item_id
+   and ss_items.item_id=ws_items.item_id 
+   and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+ order by item_id
+         ,ss_item_rev
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 17 (BROADCAST_EDGE)
+Map 26 <- Reducer 18 (BROADCAST_EDGE)
+Map 27 <- Reducer 19 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 16 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Map 27 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE), Reducer 24 (ONE_TO_ONE_EDGE)
+Reducer 17 <- Reducer 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Reducer 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Reducer 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 21 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 22 <- Map 25 (CUSTOM_SIMPLE_EDGE), Reducer 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 23 <- Map 25 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Reducer 23 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 16 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 11 (ONE_TO_ONE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 14 (ONE_TO_ONE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 26 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_466]
+        Limit [LIM_465] (rows=1 width=884)
+          Number of rows:100
+          Select Operator [SEL_464] (rows=1 width=884)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_160]
+              Select Operator [SEL_159] (rows=1 width=884)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                Filter Operator [FIL_155] (rows=1 width=1108)
+                  predicate:(_col1 BETWEEN _col10 AND _col11 and _col5 BETWEEN _col10 AND _col11 and _col9 BETWEEN _col2 AND _col3 and _col9 BETWEEN _col6 AND _col7)
+                  Merge Join Operator [MERGEJOIN_416] (rows=1 width=1108)
+                    Conds:RS_152._col0=RS_463._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7","_col9","_col10","_col11"]
+                  <-Reducer 14 [ONE_TO_ONE_EDGE] vectorized
+                    FORWARD [RS_463]
+                      PartitionCols:_col0
+                      Select Operator [SEL_462] (rows=69 width=436)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Group By Operator [GBY_461] (rows=69 width=212)
+                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                        <-Reducer 13 [SIMPLE_EDGE]
+                          SHUFFLE [RS_144]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_143] (rows=69 width=212)
+                              Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col4
+                              Merge Join Operator [MERGEJOIN_414] (rows=31537 width=100)
+                                Conds:RS_139._col0=RS_140._col0(Inner),Output:["_col2","_col4"]
+                              <-Reducer 16 [SIMPLE_EDGE]
+                                SHUFFLE [RS_140]
+                                  PartitionCols:_col0
+                                  Merge Join Operator [MERGEJOIN_403] (rows=2 width=4)
+                                    Conds:RS_419._col1=RS_435._col0(Inner),Output:["_col0"]
+                                  <-Map 15 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_419]
+                                      PartitionCols:_col1
+                                      Select Operator [SEL_418] (rows=73049 width=98)
+                                        Output:["_col0","_col1"]
+                                        Filter Operator [FIL_417] (rows=73049 width=98)
+                                          predicate:d_date is not null
+                                          TableScan [TS_5] (rows=73049 width=98)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                  <-Reducer 24 [ONE_TO_ONE_EDGE] vectorized
+                                    FORWARD [RS_435]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_434] (rows=2 width=94)
+                                        Output:["_col0"],keys:KEY._col0
+                                      <-Reducer 23 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_31]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_30] (rows=2 width=94)
+                                            Output:["_col0"],keys:_col2
+                                            Merge Join Operator [MERGEJOIN_402] (rows=5 width=94)
+                                              Conds:RS_26._col1=RS_432._col1(Inner),Output:["_col2"]
+                                            <-Map 25 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_432]
+                                                PartitionCols:_col1
+                                                Select Operator [SEL_430] (rows=73049 width=98)
+                                                  Output:["_col0","_col1"]
+                                                  Filter Operator [FIL_428] (rows=73049 width=98)
+                                                    predicate:(d_date is not null and d_week_seq is not null)
+                                                    TableScan [TS_20] (rows=73049 width=98)
+                                                      default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date","d_week_seq"]
+                                            <-Reducer 22 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_26]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_401] (rows=1 width=4)
+                                                  Conds:(Inner),Output:["_col1"]
+                                                <-Map 25 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_433]
+                                                    Select Operator [SEL_431] (rows=1 width=4)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_429] (rows=1 width=98)
+                                                        predicate:((d_date = '1998-02-19') and d_week_seq is not null)
+                                                         Please refer to the previous TableScan [TS_20]
+                                                <-Reducer 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_427]
+                                                    Select Operator [SEL_426] (rows=1 width=8)
+                                                      Filter Operator [FIL_425] (rows=1 width=8)
+                                                        predicate:(sq_count_check(_col0) <= 1)
+                                                        Group By Operator [GBY_424] (rows=1 width=8)
+                                                          Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                                        <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_423]
+                                                            Group By Operator [GBY_422] (rows=1 width=8)
+                                                              Output:["_col0"],aggregations:["count()"]
+                                                              Select Operator [SEL_421] (rows=1 width=94)
+                                                                Filter Operator [FIL_420] (rows=1 width=94)
+                                                                  predicate:(d_date = '1998-02-19')
+                                                                  TableScan [TS_8] (rows=73049 width=94)
+                                                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date"]
+                              <-Reducer 12 [SIMPLE_EDGE]
+                                SHUFFLE [RS_139]
+                                  PartitionCols:_col0
+                                  Merge Join Operator [MERGEJOIN_408] (rows=143966864 width=215)
+                                    Conds:RS_460._col1=RS_444._col0(Inner),Output:["_col0","_col2","_col4"]
+                                  <-Map 8 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_444]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_441] (rows=462000 width=104)
+                                        Output:["_col0","_col1"]
+                                        TableScan [TS_3] (rows=462000 width=104)
+                                          default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                                  <-Map 27 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_460]
+                                      PartitionCols:_col1
+                                      Select Operator [SEL_459] (rows=143966864 width=119)
+                                        Output:["_col0","_col1","_col2"]
+                                        Filter Operator [FIL_458] (rows=143966864 width=119)
+                                          predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_140_date_dim_d_date_sk_min) AND DynamicValue(RS_140_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_140_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                          TableScan [TS_98] (rows=144002668 width=119)
+                                            default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_ext_sales_price"]
+                                          <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_457]
+                                              Group By Operator [GBY_456] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Reducer 16 [CUSTOM_SIMPLE_EDGE]
+                                                SHUFFLE [RS_360]
+                                                  Group By Operator [GBY_359] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_358] (rows=2 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Merge Join Operator [MERGEJOIN_403]
+                  <-Reducer 5 [ONE_TO_ONE_EDGE]
+                    FORWARD [RS_152]
+                      PartitionCols:_col0
+                      Filter Operator [FIL_150] (rows=1 width=772)
+                        predicate:(_col1 BETWEEN _col6 AND _col7 and _col5 BETWEEN _col2 AND _col3)
+                        Merge Join Operator [MERGEJOIN_415] (rows=68 width=772)
+                          Conds:RS_447._col0=RS_455._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7"]
+                        <-Reducer 11 [ONE_TO_ONE_EDGE] vectorized
+                          FORWARD [RS_455]
+                            PartitionCols:_col0
+                            Select Operator [SEL_454] (rows=69 width=436)
+                              Output:["_col0","_col1","_col2","_col3"]
+                              Group By Operator [GBY_453] (rows=69 width=212)
+                                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                              <-Reducer 10 [SIMPLE_EDGE]
+                                SHUFFLE [RS_95]
+                                  PartitionCols:_col0
+                                  Group By Operator [GBY_94] (rows=69 width=212)
+                                    Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col4
+                                    Merge Join Operator [MERGEJOIN_413] (rows=120498 width=100)
+                                      Conds:RS_90._col0=RS_91._col0(Inner),Output:["_col2","_col4"]
+                                    <-Reducer 16 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_91]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Merge Join Operator [MERGEJOIN_403]
+                                    <-Reducer 9 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_90]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_404] (rows=550076554 width=210)
+                                          Conds:RS_452._col1=RS_443._col0(Inner),Output:["_col0","_col2","_col4"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_443]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_441]
+                                        <-Map 26 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_452]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_451] (rows=550076554 width=114)
+                                              Output:["_col0","_col1","_col2"]
+                                              Filter Operator [FIL_450] (rows=550076554 width=114)
+                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_91_date_dim_d_date_sk_min) AND DynamicValue(RS_91_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_91_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                TableScan [TS_49] (rows=575995635 width=114)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ext_sales_price"]
+                                                <-Reducer 18 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_449]
+                                                    Group By Operator [GBY_448] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 16 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_314]
+                                                        Group By Operator [GBY_313] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_312] (rows=2 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_403]
+                        <-Reducer 4 [ONE_TO_ONE_EDGE] vectorized
+                          FORWARD [RS_447]
+                            PartitionCols:_col0
+                            Select Operator [SEL_446] (rows=68 width=436)
+                              Output:["_col0","_col1","_col2","_col3"]
+                              Group By Operator [GBY_445] (rows=68 width=212)
+                                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                              <-Reducer 3 [SIMPLE_EDGE]
+                                SHUFFLE [RS_46]
+                                  PartitionCols:_col0
+                                  Group By Operator [GBY_45] (rows=68 width=212)
+                                    Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col4
+                                    Merge Join Operator [MERGEJOIN_412] (rows=62327 width=100)
+                                      Conds:RS_41._col0=RS_42._col0(Inner),Output:["_col2","_col4"]
+                                    <-Reducer 16 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_42]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Merge Join Operator [MERGEJOIN_403]
+                                    <-Reducer 2 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_41]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_400] (rows=286549727 width=215)
+                                          Conds:RS_440._col1=RS_442._col0(Inner),Output:["_col0","_col2","_col4"]
+                                        <-Map 8 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_442]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_441]
+                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_440]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_439] (rows=286549727 width=119)
+                                              Output:["_col0","_col1","_col2"]
+                                              Filter Operator [FIL_438] (rows=286549727 width=119)
+                                                predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_42_date_dim_d_date_sk_min) AND DynamicValue(RS_42_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_42_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                TableScan [TS_0] (rows=287989836 width=119)
+                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_ext_sales_price"]
+                                                <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_437]
+                                                    Group By Operator [GBY_436] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 16 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_264]
+                                                        Group By Operator [GBY_263] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_262] (rows=2 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_403]
+


[48/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query67.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query67.q b/ql/src/test/queries/clientpositive/perf/cbo_query67.q
new file mode 100644
index 0000000..5781aac
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query67.q
@@ -0,0 +1,46 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query67.tpl and seed 1819994127
+explain cbo
+select  *
+from (select i_category
+            ,i_class
+            ,i_brand
+            ,i_product_name
+            ,d_year
+            ,d_qoy
+            ,d_moy
+            ,s_store_id
+            ,sumsales
+            ,rank() over (partition by i_category order by sumsales desc) rk
+      from (select i_category
+                  ,i_class
+                  ,i_brand
+                  ,i_product_name
+                  ,d_year
+                  ,d_qoy
+                  ,d_moy
+                  ,s_store_id
+                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
+            from store_sales
+                ,date_dim
+                ,store
+                ,item
+       where  ss_sold_date_sk=d_date_sk
+          and ss_item_sk=i_item_sk
+          and ss_store_sk = s_store_sk
+          and d_month_seq between 1212 and 1212+11
+       group by  rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
+where rk <= 100
+order by i_category
+        ,i_class
+        ,i_brand
+        ,i_product_name
+        ,d_year
+        ,d_qoy
+        ,d_moy
+        ,s_store_id
+        ,sumsales
+        ,rk
+limit 100;
+
+-- end query 1 in stream 0 using template query67.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query68.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query68.q b/ql/src/test/queries/clientpositive/perf/cbo_query68.q
new file mode 100644
index 0000000..520b9d7
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query68.q
@@ -0,0 +1,44 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query68.tpl and seed 803547492
+explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,extended_price
+       ,extended_tax
+       ,list_price
+ from (select ss_ticket_number
+             ,ss_customer_sk
+             ,ca_city bought_city
+             ,sum(ss_ext_sales_price) extended_price 
+             ,sum(ss_ext_list_price) list_price
+             ,sum(ss_ext_tax) extended_tax 
+       from store_sales
+           ,date_dim
+           ,store
+           ,household_demographics
+           ,customer_address 
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_store_sk = store.s_store_sk  
+        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+        and store_sales.ss_addr_sk = customer_address.ca_address_sk
+        and date_dim.d_dom between 1 and 2 
+        and (household_demographics.hd_dep_count = 2 or
+             household_demographics.hd_vehicle_count= 1)
+        and date_dim.d_year in (1998,1998+1,1998+2)
+        and store.s_city in ('Cedar Grove','Wildwood')
+       group by ss_ticket_number
+               ,ss_customer_sk
+               ,ss_addr_sk,ca_city) dn
+      ,customer
+      ,customer_address current_addr
+ where ss_customer_sk = c_customer_sk
+   and customer.c_current_addr_sk = current_addr.ca_address_sk
+   and current_addr.ca_city <> bought_city
+ order by c_last_name
+         ,ss_ticket_number
+ limit 100;
+
+-- end query 1 in stream 0 using template query68.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query69.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query69.q b/ql/src/test/queries/clientpositive/perf/cbo_query69.q
new file mode 100644
index 0000000..01183fb
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query69.q
@@ -0,0 +1,49 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query69.tpl and seed 797269820
+explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_state in ('CO','IL','MN') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_moy between 1 and 1+2) and
+   (not exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2) and
+    not exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ limit 100;
+
+-- end query 1 in stream 0 using template query69.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query7.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query7.q b/ql/src/test/queries/clientpositive/perf/cbo_query7.q
new file mode 100644
index 0000000..3fb7130
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query7.q
@@ -0,0 +1,23 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query7.tpl and seed 1930872976
+explain cbo
+select  i_item_id, 
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4 
+ from store_sales, customer_demographics, date_dim, item, promotion
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       ss_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;
+
+-- end query 1 in stream 0 using template query7.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query70.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query70.q b/ql/src/test/queries/clientpositive/perf/cbo_query70.q
new file mode 100644
index 0000000..5b8b76e
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query70.q
@@ -0,0 +1,40 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query70.tpl and seed 1819994127
+explain cbo
+select  
+    sum(ss_net_profit) as total_sum
+   ,s_state
+   ,s_county
+   ,grouping(s_state)+grouping(s_county) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(s_state)+grouping(s_county),
+ 	case when grouping(s_county) = 0 then s_state end 
+ 	order by sum(ss_net_profit) desc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,store
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ss_sold_date_sk
+ and s_store_sk  = ss_store_sk
+ and s_state in
+             ( select s_state
+               from  (select s_state as s_state,
+ 			    rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
+                      from   store_sales, store, date_dim
+                      where  d_month_seq between 1212 and 1212+11
+ 			    and d_date_sk = ss_sold_date_sk
+ 			    and s_store_sk  = ss_store_sk
+                      group by s_state
+                     ) tmp1 
+               where ranking <= 5
+             )
+ group by rollup(s_state,s_county)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then s_state end
+  ,rank_within_parent
+ limit 100;
+
+-- end query 1 in stream 0 using template query70.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query71.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query71.q b/ql/src/test/queries/clientpositive/perf/cbo_query71.q
new file mode 100644
index 0000000..e4d4df5
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query71.q
@@ -0,0 +1,42 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query71.tpl and seed 2031708268
+explain cbo
+select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
+ 	sum(ext_price) ext_price
+ from item, (select ws_ext_sales_price as ext_price, 
+                        ws_sold_date_sk as sold_date_sk,
+                        ws_item_sk as sold_item_sk,
+                        ws_sold_time_sk as time_sk  
+                 from web_sales,date_dim
+                 where d_date_sk = ws_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select cs_ext_sales_price as ext_price,
+                        cs_sold_date_sk as sold_date_sk,
+                        cs_item_sk as sold_item_sk,
+                        cs_sold_time_sk as time_sk
+                 from catalog_sales,date_dim
+                 where d_date_sk = cs_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select ss_ext_sales_price as ext_price,
+                        ss_sold_date_sk as sold_date_sk,
+                        ss_item_sk as sold_item_sk,
+                        ss_sold_time_sk as time_sk
+                 from store_sales,date_dim
+                 where d_date_sk = ss_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 ) as tmp,time_dim
+ where
+   sold_item_sk = i_item_sk
+   and i_manager_id=1
+   and time_sk = t_time_sk
+   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
+ group by i_brand, i_brand_id,t_hour,t_minute
+ order by ext_price desc, i_brand_id
+ ;
+
+-- end query 1 in stream 0 using template query71.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query72.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query72.q b/ql/src/test/queries/clientpositive/perf/cbo_query72.q
new file mode 100644
index 0000000..941a643
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query72.q
@@ -0,0 +1,33 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query72.tpl and seed 2031708268
+explain cbo
+select  i_item_desc
+      ,w_warehouse_name
+      ,d1.d_week_seq
+      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
+      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
+      ,count(*) total_cnt
+from catalog_sales
+join inventory on (cs_item_sk = inv_item_sk)
+join warehouse on (w_warehouse_sk=inv_warehouse_sk)
+join item on (i_item_sk = cs_item_sk)
+join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk)
+join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk)
+join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk)
+join date_dim d2 on (inv_date_sk = d2.d_date_sk)
+join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk)
+left outer join promotion on (cs_promo_sk=p_promo_sk)
+left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number)
+where d1.d_week_seq = d2.d_week_seq
+  and inv_quantity_on_hand < cs_quantity 
+  and d3.d_date > d1.d_date + 5
+  and hd_buy_potential = '1001-5000'
+  and d1.d_year = 2001
+  and hd_buy_potential = '1001-5000'
+  and cd_marital_status = 'M'
+  and d1.d_year = 2001
+group by i_item_desc,w_warehouse_name,d1.d_week_seq
+order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
+limit 100;
+
+-- end query 1 in stream 0 using template query72.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query73.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query73.q b/ql/src/test/queries/clientpositive/perf/cbo_query73.q
new file mode 100644
index 0000000..c78225e
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query73.q
@@ -0,0 +1,30 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query73.tpl and seed 1971067816
+explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag 
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and date_dim.d_dom between 1 and 2 
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and case when household_demographics.hd_vehicle_count > 0 then 
+             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County')
+    group by ss_ticket_number,ss_customer_sk) dj,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 1 and 5
+    order by cnt desc;
+
+-- end query 1 in stream 0 using template query73.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query74.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query74.q b/ql/src/test/queries/clientpositive/perf/cbo_query74.q
new file mode 100644
index 0000000..71954c8
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query74.q
@@ -0,0 +1,63 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query74.tpl and seed 1556717815
+explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ss_net_paid) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,d_year as year
+       ,max(ws_net_paid) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+   and d_year in (2001,2001+1)
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         )
+  select 
+        t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.year = 2001
+         and t_s_secyear.year = 2001+1
+         and t_w_firstyear.year = 2001
+         and t_w_secyear.year = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by 2,1,3
+limit 100;
+
+-- end query 1 in stream 0 using template query74.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query75.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query75.q b/ql/src/test/queries/clientpositive/perf/cbo_query75.q
new file mode 100644
index 0000000..2d92853
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query75.q
@@ -0,0 +1,72 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query75.tpl and seed 1819994127
+explain cbo
+WITH all_sales AS (
+ SELECT d_year
+       ,i_brand_id
+       ,i_class_id
+       ,i_category_id
+       ,i_manufact_id
+       ,SUM(sales_cnt) AS sales_cnt
+       ,SUM(sales_amt) AS sales_amt
+ FROM (SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,cs_quantity - COALESCE(cr_return_quantity,0) AS sales_cnt
+             ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0) AS sales_amt
+       FROM catalog_sales JOIN item ON i_item_sk=cs_item_sk
+                          JOIN date_dim ON d_date_sk=cs_sold_date_sk
+                          LEFT JOIN catalog_returns ON (cs_order_number=cr_order_number 
+                                                    AND cs_item_sk=cr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ss_quantity - COALESCE(sr_return_quantity,0) AS sales_cnt
+             ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0) AS sales_amt
+       FROM store_sales JOIN item ON i_item_sk=ss_item_sk
+                        JOIN date_dim ON d_date_sk=ss_sold_date_sk
+                        LEFT JOIN store_returns ON (ss_ticket_number=sr_ticket_number 
+                                                AND ss_item_sk=sr_item_sk)
+       WHERE i_category='Sports'
+       UNION
+       SELECT d_year
+             ,i_brand_id
+             ,i_class_id
+             ,i_category_id
+             ,i_manufact_id
+             ,ws_quantity - COALESCE(wr_return_quantity,0) AS sales_cnt
+             ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0) AS sales_amt
+       FROM web_sales JOIN item ON i_item_sk=ws_item_sk
+                      JOIN date_dim ON d_date_sk=ws_sold_date_sk
+                      LEFT JOIN web_returns ON (ws_order_number=wr_order_number 
+                                            AND ws_item_sk=wr_item_sk)
+       WHERE i_category='Sports') sales_detail
+ GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+ SELECT  prev_yr.d_year AS prev_year
+                          ,curr_yr.d_year AS year
+                          ,curr_yr.i_brand_id
+                          ,curr_yr.i_class_id
+                          ,curr_yr.i_category_id
+                          ,curr_yr.i_manufact_id
+                          ,prev_yr.sales_cnt AS prev_yr_cnt
+                          ,curr_yr.sales_cnt AS curr_yr_cnt
+                          ,curr_yr.sales_cnt-prev_yr.sales_cnt AS sales_cnt_diff
+                          ,curr_yr.sales_amt-prev_yr.sales_amt AS sales_amt_diff
+ FROM all_sales curr_yr, all_sales prev_yr
+ WHERE curr_yr.i_brand_id=prev_yr.i_brand_id
+   AND curr_yr.i_class_id=prev_yr.i_class_id
+   AND curr_yr.i_category_id=prev_yr.i_category_id
+   AND curr_yr.i_manufact_id=prev_yr.i_manufact_id
+   AND curr_yr.d_year=2002
+   AND prev_yr.d_year=2002-1
+   AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9
+ ORDER BY sales_cnt_diff
+ limit 100;
+
+-- end query 1 in stream 0 using template query75.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query76.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query76.q b/ql/src/test/queries/clientpositive/perf/cbo_query76.q
new file mode 100644
index 0000000..9d2d89e
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query76.q
@@ -0,0 +1,26 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query76.tpl and seed 2031708268
+explain cbo
+select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
+        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
+         FROM store_sales, item, date_dim
+         WHERE ss_addr_sk IS NULL
+           AND ss_sold_date_sk=d_date_sk
+           AND ss_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
+         FROM web_sales, item, date_dim
+         WHERE ws_web_page_sk IS NULL
+           AND ws_sold_date_sk=d_date_sk
+           AND ws_item_sk=i_item_sk
+        UNION ALL
+        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
+         FROM catalog_sales, item, date_dim
+         WHERE cs_warehouse_sk IS NULL
+           AND cs_sold_date_sk=d_date_sk
+           AND cs_item_sk=i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+limit 100;
+
+-- end query 1 in stream 0 using template query76.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query77.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query77.q b/ql/src/test/queries/clientpositive/perf/cbo_query77.q
new file mode 100644
index 0000000..3d0f484
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query77.q
@@ -0,0 +1,109 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query77.tpl and seed 1819994127
+explain cbo
+with ss as
+ (select s_store_sk,
+         sum(ss_ext_sales_price) as sales,
+         sum(ss_net_profit) as profit
+ from store_sales,
+      date_dim,
+      store
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days) 
+       and ss_store_sk = s_store_sk
+ group by s_store_sk)
+ ,
+ sr as
+ (select s_store_sk,
+         sum(sr_return_amt) as returns,
+         sum(sr_net_loss) as profit_loss
+ from store_returns,
+      date_dim,
+      store
+ where sr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and sr_store_sk = s_store_sk
+ group by s_store_sk), 
+ cs as
+ (select cs_call_center_sk,
+        sum(cs_ext_sales_price) as sales,
+        sum(cs_net_profit) as profit
+ from catalog_sales,
+      date_dim
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ group by cs_call_center_sk 
+ ), 
+ cr as
+ (select
+        sum(cr_return_amount) as returns,
+        sum(cr_net_loss) as profit_loss
+ from catalog_returns,
+      date_dim
+ where cr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+ ), 
+ ws as
+ ( select wp_web_page_sk,
+        sum(ws_ext_sales_price) as sales,
+        sum(ws_net_profit) as profit
+ from web_sales,
+      date_dim,
+      web_page
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ws_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk), 
+ wr as
+ (select wp_web_page_sk,
+        sum(wr_return_amt) as returns,
+        sum(wr_net_loss) as profit_loss
+ from web_returns,
+      date_dim,
+      web_page
+ where wr_returned_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+       and wr_web_page_sk = wp_web_page_sk
+ group by wp_web_page_sk)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , ss.s_store_sk as id
+        , sales
+        , coalesce(returns, 0) as returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ss left join sr
+        on  ss.s_store_sk = sr.s_store_sk
+ union all
+ select 'catalog channel' as channel
+        , cs_call_center_sk as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  cs
+       , cr
+ union all
+ select 'web channel' as channel
+        , ws.wp_web_page_sk as id
+        , sales
+        , coalesce(returns, 0) returns
+        , (profit - coalesce(profit_loss,0)) as profit
+ from   ws left join wr
+        on  ws.wp_web_page_sk = wr.wp_web_page_sk
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100;
+
+-- end query 1 in stream 0 using template query77.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query78.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query78.q b/ql/src/test/queries/clientpositive/perf/cbo_query78.q
new file mode 100644
index 0000000..87f94dc
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query78.q
@@ -0,0 +1,60 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query78.tpl and seed 1819994127
+explain cbo
+with ws as
+  (select d_year AS ws_sold_year, ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+   from web_sales
+   left join web_returns on wr_order_number=ws_order_number and ws_item_sk=wr_item_sk
+   join date_dim on ws_sold_date_sk = d_date_sk
+   where wr_order_number is null
+   group by d_year, ws_item_sk, ws_bill_customer_sk
+   ),
+cs as
+  (select d_year AS cs_sold_year, cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+   from catalog_sales
+   left join catalog_returns on cr_order_number=cs_order_number and cs_item_sk=cr_item_sk
+   join date_dim on cs_sold_date_sk = d_date_sk
+   where cr_order_number is null
+   group by d_year, cs_item_sk, cs_bill_customer_sk
+   ),
+ss as
+  (select d_year AS ss_sold_year, ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+   from store_sales
+   left join store_returns on sr_ticket_number=ss_ticket_number and ss_item_sk=sr_item_sk
+   join date_dim on ss_sold_date_sk = d_date_sk
+   where sr_ticket_number is null
+   group by d_year, ss_item_sk, ss_customer_sk
+   )
+ select 
+ss_sold_year, ss_item_sk, ss_customer_sk,
+round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
+ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
+coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
+coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
+coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
+from ss
+left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
+order by 
+  ss_sold_year, ss_item_sk, ss_customer_sk,
+  ss_qty desc, ss_wc desc, ss_sp desc,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2)
+limit 100;
+
+-- end query 1 in stream 0 using template query78.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query79.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query79.q b/ql/src/test/queries/clientpositive/perf/cbo_query79.q
new file mode 100644
index 0000000..ce05a9a
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query79.q
@@ -0,0 +1,25 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query79.tpl and seed 2031708268
+explain cbo
+select 
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
+  from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,store.s_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
+    and date_dim.d_dow = 1
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_number_employees between 200 and 295
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
+    where ss_customer_sk = c_customer_sk
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
+limit 100;
+
+-- end query 1 in stream 0 using template query79.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query8.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query8.q b/ql/src/test/queries/clientpositive/perf/cbo_query8.q
new file mode 100644
index 0000000..71ab234
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query8.q
@@ -0,0 +1,110 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query8.tpl and seed 1766988859
+explain cbo
+select  s_store_name
+      ,sum(ss_net_profit)
+ from store_sales
+     ,date_dim
+     ,store,
+     (select ca_zip
+     from (
+     (SELECT substr(ca_zip,1,5) ca_zip
+      FROM customer_address
+      WHERE substr(ca_zip,1,5) IN (
+                          '89436','30868','65085','22977','83927','77557',
+                          '58429','40697','80614','10502','32779',
+                          '91137','61265','98294','17921','18427',
+                          '21203','59362','87291','84093','21505',
+                          '17184','10866','67898','25797','28055',
+                          '18377','80332','74535','21757','29742',
+                          '90885','29898','17819','40811','25990',
+                          '47513','89531','91068','10391','18846',
+                          '99223','82637','41368','83658','86199',
+                          '81625','26696','89338','88425','32200',
+                          '81427','19053','77471','36610','99823',
+                          '43276','41249','48584','83550','82276',
+                          '18842','78890','14090','38123','40936',
+                          '34425','19850','43286','80072','79188',
+                          '54191','11395','50497','84861','90733',
+                          '21068','57666','37119','25004','57835',
+                          '70067','62878','95806','19303','18840',
+                          '19124','29785','16737','16022','49613',
+                          '89977','68310','60069','98360','48649',
+                          '39050','41793','25002','27413','39736',
+                          '47208','16515','94808','57648','15009',
+                          '80015','42961','63982','21744','71853',
+                          '81087','67468','34175','64008','20261',
+                          '11201','51799','48043','45645','61163',
+                          '48375','36447','57042','21218','41100',
+                          '89951','22745','35851','83326','61125',
+                          '78298','80752','49858','52940','96976',
+                          '63792','11376','53582','18717','90226',
+                          '50530','94203','99447','27670','96577',
+                          '57856','56372','16165','23427','54561',
+                          '28806','44439','22926','30123','61451',
+                          '92397','56979','92309','70873','13355',
+                          '21801','46346','37562','56458','28286',
+                          '47306','99555','69399','26234','47546',
+                          '49661','88601','35943','39936','25632',
+                          '24611','44166','56648','30379','59785',
+                          '11110','14329','93815','52226','71381',
+                          '13842','25612','63294','14664','21077',
+                          '82626','18799','60915','81020','56447',
+                          '76619','11433','13414','42548','92713',
+                          '70467','30884','47484','16072','38936',
+                          '13036','88376','45539','35901','19506',
+                          '65690','73957','71850','49231','14276',
+                          '20005','18384','76615','11635','38177',
+                          '55607','41369','95447','58581','58149',
+                          '91946','33790','76232','75692','95464',
+                          '22246','51061','56692','53121','77209',
+                          '15482','10688','14868','45907','73520',
+                          '72666','25734','17959','24677','66446',
+                          '94627','53535','15560','41967','69297',
+                          '11929','59403','33283','52232','57350',
+                          '43933','40921','36635','10827','71286',
+                          '19736','80619','25251','95042','15526',
+                          '36496','55854','49124','81980','35375',
+                          '49157','63512','28944','14946','36503',
+                          '54010','18767','23969','43905','66979',
+                          '33113','21286','58471','59080','13395',
+                          '79144','70373','67031','38360','26705',
+                          '50906','52406','26066','73146','15884',
+                          '31897','30045','61068','45550','92454',
+                          '13376','14354','19770','22928','97790',
+                          '50723','46081','30202','14410','20223',
+                          '88500','67298','13261','14172','81410',
+                          '93578','83583','46047','94167','82564',
+                          '21156','15799','86709','37931','74703',
+                          '83103','23054','70470','72008','49247',
+                          '91911','69998','20961','70070','63197',
+                          '54853','88191','91830','49521','19454',
+                          '81450','89091','62378','25683','61869',
+                          '51744','36580','85778','36871','48121',
+                          '28810','83712','45486','67393','26935',
+                          '42393','20132','55349','86057','21309',
+                          '80218','10094','11357','48819','39734',
+                          '40758','30432','21204','29467','30214',
+                          '61024','55307','74621','11622','68908',
+                          '33032','52868','99194','99900','84936',
+                          '69036','99149','45013','32895','59004',
+                          '32322','14933','32936','33562','72550',
+                          '27385','58049','58200','16808','21360',
+                          '32961','18586','79307','15492'))
+     intersect
+     (select ca_zip
+      from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
+            FROM customer_address, customer
+            WHERE ca_address_sk = c_current_addr_sk and
+                  c_preferred_cust_flag='Y'
+            group by ca_zip
+            having count(*) > 10)A1))A2) V1
+ where ss_store_sk = s_store_sk
+  and ss_sold_date_sk = d_date_sk
+  and d_qoy = 1 and d_year = 2002
+  and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
+ group by s_store_name
+ order by s_store_name
+ limit 100;
+
+-- end query 1 in stream 0 using template query8.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query80.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query80.q b/ql/src/test/queries/clientpositive/perf/cbo_query80.q
new file mode 100644
index 0000000..16b1da2
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query80.q
@@ -0,0 +1,98 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query80.tpl and seed 1819994127
+explain cbo
+with ssr as
+ (select  s_store_id as store_id,
+          sum(ss_ext_sales_price) as sales,
+          sum(coalesce(sr_return_amt, 0)) as returns,
+          sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit
+  from store_sales left outer join store_returns on
+         (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number),
+     date_dim,
+     store,
+     item,
+     promotion
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ss_store_sk = s_store_sk
+       and ss_item_sk = i_item_sk
+       and i_current_price > 50
+       and ss_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+ group by s_store_id)
+ ,
+ csr as
+ (select  cp_catalog_page_id as catalog_page_id,
+          sum(cs_ext_sales_price) as sales,
+          sum(coalesce(cr_return_amount, 0)) as returns,
+          sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit
+  from catalog_sales left outer join catalog_returns on
+         (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number),
+     date_dim,
+     catalog_page,
+     item,
+     promotion
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and cs_catalog_page_sk = cp_catalog_page_sk
+       and cs_item_sk = i_item_sk
+       and i_current_price > 50
+       and cs_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select  web_site_id,
+          sum(ws_ext_sales_price) as sales,
+          sum(coalesce(wr_return_amt, 0)) as returns,
+          sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit
+  from web_sales left outer join web_returns on
+         (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number),
+     date_dim,
+     web_site,
+     item,
+     promotion
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and ws_web_site_sk = web_site_sk
+       and ws_item_sk = i_item_sk
+       and i_current_price > 50
+       and ws_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || store_id as id
+        , sales
+        , returns
+        , profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || catalog_page_id as id
+        , sales
+        , returns
+        , profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100;
+
+-- end query 1 in stream 0 using template query80.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query81.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query81.q b/ql/src/test/queries/clientpositive/perf/cbo_query81.q
new file mode 100644
index 0000000..722bc9e
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query81.q
@@ -0,0 +1,33 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query81.tpl and seed 1819994127
+explain cbo
+with customer_total_return as
+ (select cr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(cr_return_amt_inc_tax) as ctr_total_return
+ from catalog_returns
+     ,date_dim
+     ,customer_address
+ where cr_returned_date_sk = d_date_sk 
+   and d_year =1998
+   and cr_returning_addr_sk = ca_address_sk 
+ group by cr_returning_customer_sk
+         ,ca_state )
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
+                   ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
+                  ,ca_location_type,ctr_total_return
+ limit 100;
+
+-- end query 1 in stream 0 using template query81.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query82.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query82.q b/ql/src/test/queries/clientpositive/perf/cbo_query82.q
new file mode 100644
index 0000000..932a71b
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query82.q
@@ -0,0 +1,19 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query82.tpl and seed 55585014
+explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, store_sales
+ where i_current_price between 30 and 30+30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
+ and i_manufact_id in (437,129,727,663)
+ and inv_quantity_on_hand between 100 and 500
+ and ss_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100;
+
+-- end query 1 in stream 0 using template query82.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query83.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query83.q b/ql/src/test/queries/clientpositive/perf/cbo_query83.q
new file mode 100644
index 0000000..551ea0d
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query83.q
@@ -0,0 +1,69 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query83.tpl and seed 1930872976
+explain cbo
+with sr_items as
+ (select i_item_id item_id,
+        sum(sr_return_quantity) sr_item_qty
+ from store_returns,
+      item,
+      date_dim
+ where sr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   sr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+        sum(cr_return_quantity) cr_item_qty
+ from catalog_returns,
+      item,
+      date_dim
+ where cr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+	  where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   cr_returned_date_sk   = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+        sum(wr_return_quantity) wr_item_qty
+ from web_returns,
+      item,
+      date_dim
+ where wr_item_sk = i_item_sk
+ and   d_date    in 
+	(select d_date
+	from date_dim
+	where d_week_seq in 
+		(select d_week_seq
+		from date_dim
+		where d_date in ('1998-01-02','1998-10-15','1998-11-10')))
+ and   wr_returned_date_sk   = d_date_sk
+ group by i_item_id)
+  select  sr_items.item_id
+       ,sr_item_qty
+       ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev
+       ,cr_item_qty
+       ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev
+       ,wr_item_qty
+       ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev
+       ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average
+ from sr_items
+     ,cr_items
+     ,wr_items
+ where sr_items.item_id=cr_items.item_id
+   and sr_items.item_id=wr_items.item_id 
+ order by sr_items.item_id
+         ,sr_item_qty
+ limit 100;
+
+-- end query 1 in stream 0 using template query83.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query84.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query84.q b/ql/src/test/queries/clientpositive/perf/cbo_query84.q
new file mode 100644
index 0000000..d36df57
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query84.q
@@ -0,0 +1,23 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query84.tpl and seed 1819994127
+explain cbo
+select  c_customer_id as customer_id
+       ,c_last_name || ', ' || c_first_name as customername
+ from customer
+     ,customer_address
+     ,customer_demographics
+     ,household_demographics
+     ,income_band
+     ,store_returns
+ where ca_city	        =  'Hopewell'
+   and c_current_addr_sk = ca_address_sk
+   and ib_lower_bound   >=  32287
+   and ib_upper_bound   <=  32287 + 50000
+   and ib_income_band_sk = hd_income_band_sk
+   and cd_demo_sk = c_current_cdemo_sk
+   and hd_demo_sk = c_current_hdemo_sk
+   and sr_cdemo_sk = cd_demo_sk
+ order by c_customer_id
+ limit 100;
+
+-- end query 1 in stream 0 using template query84.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query85.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query85.q b/ql/src/test/queries/clientpositive/perf/cbo_query85.q
new file mode 100644
index 0000000..e09137b
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query85.q
@@ -0,0 +1,86 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query85.tpl and seed 622697896
+explain cbo
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
+ from web_sales, web_returns, web_page, customer_demographics cd1,
+      customer_demographics cd2, customer_address, date_dim, reason 
+ where ws_web_page_sk = wp_web_page_sk
+   and ws_item_sk = wr_item_sk
+   and ws_order_number = wr_order_number
+   and ws_sold_date_sk = d_date_sk and d_year = 1998
+   and cd1.cd_demo_sk = wr_refunded_cdemo_sk 
+   and cd2.cd_demo_sk = wr_returning_cdemo_sk
+   and ca_address_sk = wr_refunded_addr_sk
+   and r_reason_sk = wr_reason_sk
+   and
+   (
+    (
+     cd1.cd_marital_status = 'M'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = '4 yr Degree'
+     and 
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 100.00 and 150.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'D'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Primary' 
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 50.00 and 100.00
+    )
+   or
+    (
+     cd1.cd_marital_status = 'U'
+     and
+     cd1.cd_marital_status = cd2.cd_marital_status
+     and
+     cd1.cd_education_status = 'Advanced Degree'
+     and
+     cd1.cd_education_status = cd2.cd_education_status
+     and
+     ws_sales_price between 150.00 and 200.00
+    )
+   )
+   and
+   (
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('KY', 'GA', 'NM')
+     and ws_net_profit between 100 and 200  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('MT', 'OR', 'IN')
+     and ws_net_profit between 150 and 300  
+    )
+    or
+    (
+     ca_country = 'United States'
+     and
+     ca_state in ('WI', 'MO', 'WV')
+     and ws_net_profit between 50 and 250  
+    )
+   )
+group by r_reason_desc
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
+limit 100;
+
+-- end query 1 in stream 0 using template query85.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query86.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query86.q b/ql/src/test/queries/clientpositive/perf/cbo_query86.q
new file mode 100644
index 0000000..a8e9941
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query86.q
@@ -0,0 +1,28 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query86.tpl and seed 1819994127
+explain cbo
+select   
+    sum(ws_net_paid) as total_sum
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ws_net_paid) desc) as rank_within_parent
+ from
+    web_sales
+   ,date_dim       d1
+   ,item
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ws_sold_date_sk
+ and i_item_sk  = ws_item_sk
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc,
+   case when lochierarchy = 0 then i_category end,
+   rank_within_parent
+ limit 100;
+
+-- end query 1 in stream 0 using template query86.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query87.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query87.q b/ql/src/test/queries/clientpositive/perf/cbo_query87.q
new file mode 100644
index 0000000..79f8437
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query87.q
@@ -0,0 +1,25 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query87.tpl and seed 1819994127
+explain cbo
+select count(*) 
+from ((select distinct c_last_name, c_first_name, d_date
+       from store_sales, date_dim, customer
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from catalog_sales, date_dim, customer
+       where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+         and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from web_sales, date_dim, customer
+       where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+         and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+) cool_cust
+;
+
+-- end query 1 in stream 0 using template query87.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query88.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query88.q b/ql/src/test/queries/clientpositive/perf/cbo_query88.q
new file mode 100644
index 0000000..09f95b9
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query88.q
@@ -0,0 +1,96 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query88.tpl and seed 318176889
+explain cbo
+select  *
+from
+ (select count(*) h8_30_to_9
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk   
+     and ss_hdemo_sk = household_demographics.hd_demo_sk 
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 8
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
+     and store.s_store_name = 'ese') s1,
+ (select count(*) h9_to_9_30 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 9 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s2,
+ (select count(*) h9_30_to_10 
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 9
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s3,
+ (select count(*) h10_to_10_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s4,
+ (select count(*) h10_30_to_11
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 10 
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s5,
+ (select count(*) h11_to_11_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk 
+     and time_dim.t_hour = 11
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s6,
+ (select count(*) h11_30_to_12
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 11
+     and time_dim.t_minute >= 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s7,
+ (select count(*) h12_to_12_30
+ from store_sales, household_demographics , time_dim, store
+ where ss_sold_time_sk = time_dim.t_time_sk
+     and ss_hdemo_sk = household_demographics.hd_demo_sk
+     and ss_store_sk = s_store_sk
+     and time_dim.t_hour = 12
+     and time_dim.t_minute < 30
+     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
+          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
+          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
+     and store.s_store_name = 'ese') s8
+;
+
+-- end query 1 in stream 0 using template query88.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query89.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query89.q b/ql/src/test/queries/clientpositive/perf/cbo_query89.q
new file mode 100644
index 0000000..7682404
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query89.q
@@ -0,0 +1,30 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query89.tpl and seed 1719819282
+explain cbo
+select  *
+from(
+select i_category, i_class, i_brand,
+       s_store_name, s_company_name,
+       d_moy,
+       sum(ss_sales_price) sum_sales,
+       avg(sum(ss_sales_price)) over
+         (partition by i_category, i_brand, s_store_name, s_company_name)
+         avg_monthly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+      ss_sold_date_sk = d_date_sk and
+      ss_store_sk = s_store_sk and
+      d_year in (2000) and
+        ((i_category in ('Home','Books','Electronics') and
+          i_class in ('wallpaper','parenting','musical')
+         )
+      or (i_category in ('Shoes','Jewelry','Men') and
+          i_class in ('womens','birdal','pants') 
+        ))
+group by i_category, i_class, i_brand,
+         s_store_name, s_company_name, d_moy) tmp1
+where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
+order by sum_sales - avg_monthly_sales, s_store_name
+limit 100;
+
+-- end query 1 in stream 0 using template query89.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query9.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query9.q b/ql/src/test/queries/clientpositive/perf/cbo_query9.q
new file mode 100644
index 0000000..46d8868
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query9.q
@@ -0,0 +1,53 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query9.tpl and seed 1490436826
+explain cbo
+select case when (select count(*) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) > 409437
+            then (select avg(ss_ext_list_price) 
+                  from store_sales 
+                  where ss_quantity between 1 and 20) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 1 and 20) end bucket1 ,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 21 and 40) > 4595804
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 21 and 40) 
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 21 and 40) end bucket2,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 41 and 60) > 7887297
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 41 and 60)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 41 and 60) end bucket3,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 61 and 80) > 10872978
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 61 and 80)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 61 and 80) end bucket4,
+       case when (select count(*)
+                  from store_sales
+                  where ss_quantity between 81 and 100) > 43571537
+            then (select avg(ss_ext_list_price)
+                  from store_sales
+                  where ss_quantity between 81 and 100)
+            else (select avg(ss_net_paid_inc_tax)
+                  from store_sales
+                  where ss_quantity between 81 and 100) end bucket5
+from reason
+where r_reason_sk = 1
+;
+
+-- end query 1 in stream 0 using template query9.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query90.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query90.q b/ql/src/test/queries/clientpositive/perf/cbo_query90.q
new file mode 100644
index 0000000..fc75e67
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query90.q
@@ -0,0 +1,24 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query90.tpl and seed 2031708268
+explain cbo
+select  cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio
+ from ( select count(*) amc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 6 and 6+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) at,
+      ( select count(*) pmc
+       from web_sales, household_demographics , time_dim, web_page
+       where ws_sold_time_sk = time_dim.t_time_sk
+         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
+         and ws_web_page_sk = web_page.wp_web_page_sk
+         and time_dim.t_hour between 14 and 14+1
+         and household_demographics.hd_dep_count = 8
+         and web_page.wp_char_count between 5000 and 5200) pt
+ order by am_pm_ratio
+ limit 100;
+
+-- end query 1 in stream 0 using template query90.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query91.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query91.q b/ql/src/test/queries/clientpositive/perf/cbo_query91.q
new file mode 100644
index 0000000..7f1f8d8
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query91.q
@@ -0,0 +1,33 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query91.tpl and seed 1930872976
+explain cbo
+select  
+        cc_call_center_id Call_Center,
+        cc_name Call_Center_Name,
+        cc_manager Manager,
+        sum(cr_net_loss) Returns_Loss
+from
+        call_center,
+        catalog_returns,
+        date_dim,
+        customer,
+        customer_address,
+        customer_demographics,
+        household_demographics
+where
+        cr_call_center_sk       = cc_call_center_sk
+and     cr_returned_date_sk     = d_date_sk
+and     cr_returning_customer_sk= c_customer_sk
+and     cd_demo_sk              = c_current_cdemo_sk
+and     hd_demo_sk              = c_current_hdemo_sk
+and     ca_address_sk           = c_current_addr_sk
+and     d_year                  = 1999 
+and     d_moy                   = 11
+and     ( (cd_marital_status       = 'M' and cd_education_status     = 'Unknown')
+        or(cd_marital_status       = 'W' and cd_education_status     = 'Advanced Degree'))
+and     hd_buy_potential like '0-500%'
+and     ca_gmt_offset           = -7
+group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status
+order by sum(cr_net_loss) desc;
+
+-- end query 1 in stream 0 using template query91.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query92.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query92.q b/ql/src/test/queries/clientpositive/perf/cbo_query92.q
new file mode 100644
index 0000000..23b32ea
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query92.q
@@ -0,0 +1,32 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query92.tpl and seed 2031708268
+explain cbo
+select  
+   sum(ws_ext_discount_amt)  as `Excess Discount Amount` 
+from 
+    web_sales 
+   ,item 
+   ,date_dim
+where
+i_manufact_id = 269
+and i_item_sk = ws_item_sk 
+and d_date between '1998-03-18' and 
+        (cast('1998-03-18' as date) + 90 days)
+and d_date_sk = ws_sold_date_sk 
+and ws_ext_discount_amt  
+     > ( 
+         SELECT 
+            1.3 * avg(ws_ext_discount_amt) 
+         FROM 
+            web_sales 
+           ,date_dim
+         WHERE 
+              ws_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 = ws_sold_date_sk 
+      ) 
+order by sum(ws_ext_discount_amt)
+limit 100;
+
+-- end query 1 in stream 0 using template query92.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query93.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query93.q b/ql/src/test/queries/clientpositive/perf/cbo_query93.q
new file mode 100644
index 0000000..c6a7d12
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query93.q
@@ -0,0 +1,20 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query93.tpl and seed 1200409435
+explain cbo
+select  ss_customer_sk
+            ,sum(act_sales) sumsales
+      from (select ss_item_sk
+                  ,ss_ticket_number
+                  ,ss_customer_sk
+                  ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price
+                                                            else (ss_quantity*ss_sales_price) end act_sales
+            from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk
+                                                               and sr_ticket_number = ss_ticket_number)
+                ,reason
+            where sr_reason_sk = r_reason_sk
+              and r_reason_desc = 'Did not like the warranty') t
+      group by ss_customer_sk
+      order by sumsales, ss_customer_sk
+limit 100;
+
+-- end query 1 in stream 0 using template query93.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query94.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query94.q b/ql/src/test/queries/clientpositive/perf/cbo_query94.q
new file mode 100644
index 0000000..4ae01bf
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query94.q
@@ -0,0 +1,31 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query94.tpl and seed 2031708268
+explain cbo
+select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and exists (select *
+            from web_sales ws2
+            where ws1.ws_order_number = ws2.ws_order_number
+              and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+and not exists(select *
+               from web_returns wr1
+               where ws1.ws_order_number = wr1.wr_order_number)
+order by count(distinct ws_order_number)
+limit 100;
+
+-- end query 1 in stream 0 using template query94.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query95.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query95.q b/ql/src/test/queries/clientpositive/perf/cbo_query95.q
new file mode 100644
index 0000000..58c9be5
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query95.q
@@ -0,0 +1,34 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query95.tpl and seed 2031708268
+explain cbo
+with ws_wh as
+(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2
+ from web_sales ws1,web_sales ws2
+ where ws1.ws_order_number = ws2.ws_order_number
+   and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
+ select  
+   count(distinct ws_order_number) as `order count`
+  ,sum(ws_ext_ship_cost) as `total shipping cost`
+  ,sum(ws_net_profit) as `total net profit`
+from
+   web_sales ws1
+  ,date_dim
+  ,customer_address
+  ,web_site
+where
+    d_date between '1999-5-01' and 
+           (cast('1999-5-01' as date) + 60 days)
+and ws1.ws_ship_date_sk = d_date_sk
+and ws1.ws_ship_addr_sk = ca_address_sk
+and ca_state = 'TX'
+and ws1.ws_web_site_sk = web_site_sk
+and web_company_name = 'pri'
+and ws1.ws_order_number in (select ws_order_number
+                            from ws_wh)
+and ws1.ws_order_number in (select wr_order_number
+                            from web_returns,ws_wh
+                            where wr_order_number = ws_wh.ws_order_number)
+order by count(distinct ws_order_number)
+limit 100;
+
+-- end query 1 in stream 0 using template query95.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query96.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query96.q b/ql/src/test/queries/clientpositive/perf/cbo_query96.q
new file mode 100644
index 0000000..1561fe3
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query96.q
@@ -0,0 +1,18 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query96.tpl and seed 1819994127
+explain cbo
+select  count(*) 
+from store_sales
+    ,household_demographics 
+    ,time_dim, store
+where ss_sold_time_sk = time_dim.t_time_sk   
+    and ss_hdemo_sk = household_demographics.hd_demo_sk 
+    and ss_store_sk = s_store_sk
+    and time_dim.t_hour = 8
+    and time_dim.t_minute >= 30
+    and household_demographics.hd_dep_count = 5
+    and store.s_store_name = 'ese'
+order by count(*)
+limit 100;
+
+-- end query 1 in stream 0 using template query96.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query97.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query97.q b/ql/src/test/queries/clientpositive/perf/cbo_query97.q
new file mode 100644
index 0000000..cb754dd
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query97.q
@@ -0,0 +1,27 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query97.tpl and seed 1819994127
+explain cbo
+with ssci as (
+select ss_customer_sk customer_sk
+      ,ss_item_sk item_sk
+from store_sales,date_dim
+where ss_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by ss_customer_sk
+        ,ss_item_sk),
+csci as(
+ select cs_bill_customer_sk customer_sk
+      ,cs_item_sk item_sk
+from catalog_sales,date_dim
+where cs_sold_date_sk = d_date_sk
+  and d_month_seq between 1212 and 1212 + 11
+group by cs_bill_customer_sk
+        ,cs_item_sk)
+ select  sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
+      ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
+      ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
+from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk
+                               and ssci.item_sk = csci.item_sk)
+limit 100;
+
+-- end query 1 in stream 0 using template query97.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query98.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query98.q b/ql/src/test/queries/clientpositive/perf/cbo_query98.q
new file mode 100644
index 0000000..a48f81e
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query98.q
@@ -0,0 +1,34 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query98.tpl and seed 345591136
+explain cbo
+select i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ss_ext_sales_price) as itemrevenue 
+      ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	store_sales
+    	,item 
+    	,date_dim
+where 
+	ss_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ss_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio;
+
+-- end query 1 in stream 0 using template query98.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query99.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query99.q b/ql/src/test/queries/clientpositive/perf/cbo_query99.q
new file mode 100644
index 0000000..be098fa
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query99.q
@@ -0,0 +1,37 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query99.tpl and seed 1819994127
+explain cbo
+select  
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and 
+                 (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and
+                 (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (cs_ship_date_sk - cs_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   catalog_sales
+  ,warehouse
+  ,ship_mode
+  ,call_center
+  ,date_dim
+where
+    d_month_seq between 1212 and 1212 + 11
+and cs_ship_date_sk   = d_date_sk
+and cs_warehouse_sk   = w_warehouse_sk
+and cs_ship_mode_sk   = sm_ship_mode_sk
+and cs_call_center_sk = cc_call_center_sk
+group by
+   substr(w_warehouse_name,1,20)
+  ,sm_type
+  ,cc_name
+order by substr(w_warehouse_name,1,20)
+        ,sm_type
+        ,cc_name
+limit 100;
+
+-- end query 1 in stream 0 using template query99.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query1.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query1.q.out
new file mode 100644
index 0000000..295ba99
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query1.q.out
@@ -0,0 +1,91 @@
+PREHOOK: query: explain cbo
+with customer_total_return as
+(select sr_customer_sk as ctr_customer_sk
+,sr_store_sk as ctr_store_sk
+,sum(SR_FEE) as ctr_total_return
+from store_returns
+,date_dim
+where sr_returned_date_sk = d_date_sk
+and d_year =2000
+group by sr_customer_sk
+,sr_store_sk)
+ select  c_customer_id
+from customer_total_return ctr1
+,store
+,customer
+where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+from customer_total_return ctr2
+where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
+and s_store_sk = ctr1.ctr_store_sk
+and s_state = 'NM'
+and ctr1.ctr_customer_sk = c_customer_sk
+order by c_customer_id
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with customer_total_return as
+(select sr_customer_sk as ctr_customer_sk
+,sr_store_sk as ctr_store_sk
+,sum(SR_FEE) as ctr_total_return
+from store_returns
+,date_dim
+where sr_returned_date_sk = d_date_sk
+and d_year =2000
+group by sr_customer_sk
+,sr_store_sk)
+ select  c_customer_id
+from customer_total_return ctr1
+,store
+,customer
+where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+from customer_total_return ctr2
+where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
+and s_store_sk = ctr1.ctr_store_sk
+and s_state = 'NM'
+and ctr1.ctr_customer_sk = c_customer_sk
+order by c_customer_id
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject(c_customer_id=[$1])
+    HiveJoin(condition=[AND(=($3, $8), >($4, $7))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($2, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_customer_id=[$1])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveJoin(condition=[=($3, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(sr_customer_sk=[$0], sr_store_sk=[$1], $f2=[$2])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_returned_date_sk=[$0], sr_customer_sk=[$3], sr_store_sk=[$7], sr_fee=[$14])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER])
+                  HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(s_store_sk=[$0], s_state=[CAST(_UTF-16LE'NM'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+            HiveFilter(condition=[AND(=($24, _UTF-16LE'NM'), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, store]], table:alias=[store])
+      HiveProject(_o__c0=[*(/($1, $2), 1.2)], ctr_store_sk=[$0])
+        HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+          HiveProject(sr_customer_sk=[$0], sr_store_sk=[$1], $f2=[$2])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(sr_returned_date_sk=[$0], sr_customer_sk=[$3], sr_store_sk=[$7], sr_fee=[$14])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                    HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER])
+                  HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+


[26/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query11.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query11.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query11.q.out
new file mode 100644
index 0000000..658ae27
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query11.q.out
@@ -0,0 +1,427 @@
+PREHOOK: query: explain
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year 
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.c_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.dyear = 2001
+         and t_s_secyear.dyear = 2001+1
+         and t_w_firstyear.dyear = 2001
+         and t_w_secyear.dyear = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+             > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by t_s_secyear.c_preferred_cust_flag
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,d_year
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year 
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.c_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+         and t_s_firstyear.customer_id = t_w_secyear.customer_id
+         and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+         and t_s_firstyear.sale_type = 's'
+         and t_w_firstyear.sale_type = 'w'
+         and t_s_secyear.sale_type = 's'
+         and t_w_secyear.sale_type = 'w'
+         and t_s_firstyear.dyear = 2001
+         and t_s_secyear.dyear = 2001+1
+         and t_w_firstyear.dyear = 2001
+         and t_w_secyear.dyear = 2001+1
+         and t_s_firstyear.year_total > 0
+         and t_w_firstyear.year_total > 0
+         and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+             > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+ order by t_s_secyear.c_preferred_cust_flag
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 23 (BROADCAST_EDGE)
+Map 13 <- Reducer 25 (BROADCAST_EDGE)
+Map 17 <- Reducer 22 (BROADCAST_EDGE)
+Map 9 <- Reducer 24 (BROADCAST_EDGE)
+Reducer 10 <- Map 21 (SIMPLE_EDGE), Map 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 26 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 12 <- Reducer 11 (SIMPLE_EDGE)
+Reducer 14 <- Map 13 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 15 <- Map 26 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
+Reducer 18 <- Map 17 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 19 <- Map 26 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 20 <- Reducer 19 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 23 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 24 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Map 21 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 26 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 12 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 16 (SIMPLE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 20 (SIMPLE_EDGE), Reducer 6 (ONE_TO_ONE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_349]
+        Limit [LIM_348] (rows=100 width=85)
+          Number of rows:100
+          Select Operator [SEL_347] (rows=12248093 width=85)
+            Output:["_col0"]
+          <-Reducer 7 [SIMPLE_EDGE]
+            SHUFFLE [RS_89]
+              Select Operator [SEL_88] (rows=12248093 width=85)
+                Output:["_col0"]
+                Filter Operator [FIL_87] (rows=12248093 width=541)
+                  predicate:CASE WHEN (_col4) THEN (CASE WHEN (_col7) THEN (((_col1 / _col6) > (_col10 / _col3))) ELSE ((null > (_col10 / _col3))) END) ELSE (CASE WHEN (_col7) THEN (((_col1 / _col6) > null)) ELSE (null) END) END
+                  Merge Join Operator [MERGEJOIN_283] (rows=24496186 width=541)
+                    Conds:RS_84._col2=RS_346._col0(Inner),Output:["_col1","_col3","_col4","_col6","_col7","_col9","_col10"]
+                  <-Reducer 20 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_346]
+                      PartitionCols:_col0
+                      Select Operator [SEL_345] (rows=80000000 width=297)
+                        Output:["_col0","_col1","_col2"]
+                        Group By Operator [GBY_344] (rows=80000000 width=764)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                        <-Reducer 19 [SIMPLE_EDGE]
+                          SHUFFLE [RS_75]
+                            PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                            Group By Operator [GBY_74] (rows=80000000 width=764)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                              Merge Join Operator [MERGEJOIN_280] (rows=187573258 width=764)
+                                Conds:RS_70._col1=RS_312._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                              <-Map 26 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_312]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_311] (rows=80000000 width=656)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                    TableScan [TS_65] (rows=80000000 width=656)
+                                      default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_customer_id","c_first_name","c_last_name","c_preferred_cust_flag","c_birth_country","c_login","c_email_address"]
+                              <-Reducer 18 [SIMPLE_EDGE]
+                                SHUFFLE [RS_70]
+                                  PartitionCols:_col1
+                                  Merge Join Operator [MERGEJOIN_279] (rows=187573258 width=115)
+                                    Conds:RS_343._col0=RS_290._col0(Inner),Output:["_col1","_col2"]
+                                  <-Map 21 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_290]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_287] (rows=652 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_284] (rows=652 width=8)
+                                          predicate:(d_year = 2002)
+                                          TableScan [TS_62] (rows=73049 width=8)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                  <-Map 17 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_343]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_342] (rows=525327388 width=119)
+                                        Output:["_col0","_col1","_col2"]
+                                        Filter Operator [FIL_341] (rows=525327388 width=221)
+                                          predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_68_date_dim_d_date_sk_min) AND DynamicValue(RS_68_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_68_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                          TableScan [TS_59] (rows=575995635 width=221)
+                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_ext_discount_amt","ss_ext_list_price"]
+                                          <-Reducer 22 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_340]
+                                              Group By Operator [GBY_339] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_302]
+                                                  Group By Operator [GBY_298] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_291] (rows=652 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_287]
+                  <-Reducer 6 [ONE_TO_ONE_EDGE]
+                    FORWARD [RS_84]
+                      PartitionCols:_col2
+                      Merge Join Operator [MERGEJOIN_282] (rows=20485011 width=444)
+                        Conds:RS_81._col2=RS_338._col0(Inner),Output:["_col1","_col2","_col3","_col4","_col6","_col7"]
+                      <-Reducer 16 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_338]
+                          PartitionCols:_col0
+                          Select Operator [SEL_337] (rows=17130654 width=216)
+                            Output:["_col0","_col1","_col2"]
+                            Filter Operator [FIL_336] (rows=17130654 width=212)
+                              predicate:(_col7 > 0)
+                              Select Operator [SEL_335] (rows=51391963 width=212)
+                                Output:["_col0","_col7"]
+                                Group By Operator [GBY_334] (rows=51391963 width=764)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                                <-Reducer 15 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_55]
+                                    PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                    Group By Operator [GBY_54] (rows=51391963 width=764)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                      Merge Join Operator [MERGEJOIN_278] (rows=51391963 width=764)
+                                        Conds:RS_50._col1=RS_315._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                      <-Map 26 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_315]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_311]
+                                      <-Reducer 14 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_50]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_277] (rows=51391963 width=115)
+                                            Conds:RS_333._col0=RS_296._col0(Inner),Output:["_col1","_col2"]
+                                          <-Map 21 [SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_296]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_289] (rows=652 width=4)
+                                                Output:["_col0"]
+                                                Filter Operator [FIL_286] (rows=652 width=8)
+                                                  predicate:(d_year = 2001)
+                                                   Please refer to the previous TableScan [TS_62]
+                                          <-Map 13 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_333]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_332] (rows=143930993 width=119)
+                                                Output:["_col0","_col1","_col2"]
+                                                Filter Operator [FIL_331] (rows=143930993 width=231)
+                                                  predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_48_date_dim_d_date_sk_min) AND DynamicValue(RS_48_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_48_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                  TableScan [TS_39] (rows=144002668 width=231)
+                                                    default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk","ws_ext_discount_amt","ws_ext_list_price"]
+                                                  <-Reducer 25 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_330]
+                                                      Group By Operator [GBY_329] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_305]
+                                                          Group By Operator [GBY_301] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_297] (rows=652 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_289]
+                      <-Reducer 5 [ONE_TO_ONE_EDGE]
+                        FORWARD [RS_81]
+                          PartitionCols:_col2
+                          Merge Join Operator [MERGEJOIN_281] (rows=31888273 width=328)
+                            Conds:RS_318._col0=RS_328._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                          <-Reducer 12 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_328]
+                              PartitionCols:_col0
+                              Select Operator [SEL_327] (rows=26666666 width=216)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_326] (rows=26666666 width=212)
+                                  predicate:(_col7 > 0)
+                                  Select Operator [SEL_325] (rows=80000000 width=212)
+                                    Output:["_col0","_col7"]
+                                    Group By Operator [GBY_324] (rows=80000000 width=764)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                                    <-Reducer 11 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_35]
+                                        PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                        Group By Operator [GBY_34] (rows=80000000 width=764)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                          Merge Join Operator [MERGEJOIN_276] (rows=187573258 width=764)
+                                            Conds:RS_30._col1=RS_314._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                          <-Map 26 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_314]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_311]
+                                          <-Reducer 10 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_30]
+                                              PartitionCols:_col1
+                                              Merge Join Operator [MERGEJOIN_275] (rows=187573258 width=115)
+                                                Conds:RS_323._col0=RS_294._col0(Inner),Output:["_col1","_col2"]
+                                              <-Map 21 [SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_294]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_288] (rows=652 width=4)
+                                                    Output:["_col0"]
+                                                    Filter Operator [FIL_285] (rows=652 width=8)
+                                                      predicate:(d_year = 2001)
+                                                       Please refer to the previous TableScan [TS_62]
+                                              <-Map 9 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_323]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_322] (rows=525327388 width=119)
+                                                    Output:["_col0","_col1","_col2"]
+                                                    Filter Operator [FIL_321] (rows=525327388 width=221)
+                                                      predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_28_date_dim_d_date_sk_min) AND DynamicValue(RS_28_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_28_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                      TableScan [TS_19] (rows=575995635 width=221)
+                                                        default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk","ss_ext_discount_amt","ss_ext_list_price"]
+                                                      <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                        BROADCAST [RS_320]
+                                                          Group By Operator [GBY_319] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                          <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                            PARTITION_ONLY_SHUFFLE [RS_304]
+                                                              Group By Operator [GBY_300] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                Select Operator [SEL_295] (rows=652 width=4)
+                                                                  Output:["_col0"]
+                                                                   Please refer to the previous Select Operator [SEL_288]
+                          <-Reducer 4 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_318]
+                              PartitionCols:_col0
+                              Select Operator [SEL_317] (rows=51391963 width=212)
+                                Output:["_col0","_col1"]
+                                Group By Operator [GBY_316] (rows=51391963 width=764)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6
+                                <-Reducer 3 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_16]
+                                    PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6
+                                    Group By Operator [GBY_15] (rows=51391963 width=764)
+                                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)"],keys:_col5, _col6, _col7, _col8, _col9, _col10, _col11
+                                      Merge Join Operator [MERGEJOIN_274] (rows=51391963 width=764)
+                                        Conds:RS_11._col1=RS_313._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                      <-Map 26 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_313]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_311]
+                                      <-Reducer 2 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_11]
+                                          PartitionCols:_col1
+                                          Merge Join Operator [MERGEJOIN_273] (rows=51391963 width=115)
+                                            Conds:RS_310._col0=RS_292._col0(Inner),Output:["_col1","_col2"]
+                                          <-Map 21 [SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_292]
+                                              PartitionCols:_col0
+                                               Please refer to the previous Select Operator [SEL_287]
+                                          <-Map 1 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_310]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_309] (rows=143930993 width=119)
+                                                Output:["_col0","_col1","_col2"]
+                                                Filter Operator [FIL_308] (rows=143930993 width=231)
+                                                  predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_9_date_dim_d_date_sk_min) AND DynamicValue(RS_9_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_9_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                  TableScan [TS_0] (rows=144002668 width=231)
+                                                    default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk","ws_ext_discount_amt","ws_ext_list_price"]
+                                                  <-Reducer 23 [BROADCAST_EDGE] vectorized
+                                                    BROADCAST [RS_307]
+                                                      Group By Operator [GBY_306] (rows=1 width=12)
+                                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                      <-Map 21 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                        PARTITION_ONLY_SHUFFLE [RS_303]
+                                                          Group By Operator [GBY_299] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                            Select Operator [SEL_293] (rows=652 width=4)
+                                                              Output:["_col0"]
+                                                               Please refer to the previous Select Operator [SEL_287]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query12.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query12.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query12.q.out
new file mode 100644
index 0000000..741bd90
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query12.q.out
@@ -0,0 +1,169 @@
+PREHOOK: query: explain
+select  i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ws_ext_sales_price) as itemrevenue 
+      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	web_sales
+    	,item 
+    	,date_dim
+where 
+	ws_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ws_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_desc 
+      ,i_category 
+      ,i_class 
+      ,i_current_price
+      ,sum(ws_ext_sales_price) as itemrevenue 
+      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
+          (partition by i_class) as revenueratio
+from	
+	web_sales
+    	,item 
+    	,date_dim
+where 
+	ws_item_sk = i_item_sk 
+  	and i_category in ('Jewelry', 'Sports', 'Books')
+  	and ws_sold_date_sk = d_date_sk
+	and d_date between cast('2001-01-12' as date) 
+				and (cast('2001-01-12' as date) + 30 days)
+group by 
+	i_item_id
+        ,i_item_desc 
+        ,i_category
+        ,i_class
+        ,i_current_price
+order by 
+	i_category
+        ,i_class
+        ,i_item_id
+        ,i_item_desc
+        ,revenueratio
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 10 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 3 <- Map 9 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 8 <- Map 7 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_86]
+        Limit [LIM_85] (rows=100 width=802)
+          Number of rows:100
+          Select Operator [SEL_84] (rows=138600 width=801)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_83]
+              Select Operator [SEL_82] (rows=138600 width=801)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                PTF Operator [PTF_81] (rows=138600 width=689)
+                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 ASC NULLS FIRST","partition by:":"_col1"}]
+                  Select Operator [SEL_80] (rows=138600 width=689)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                  <-Reducer 4 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_79]
+                      PartitionCols:_col1
+                      Group By Operator [GBY_78] (rows=138600 width=689)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                      <-Reducer 3 [SIMPLE_EDGE]
+                        SHUFFLE [RS_17]
+                          PartitionCols:_col0, _col1, _col2, _col3, _col4
+                          Group By Operator [GBY_16] (rows=138600 width=689)
+                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)"],keys:_col9, _col8, _col5, _col6, _col7
+                            Merge Join Operator [MERGEJOIN_58] (rows=4798568 width=689)
+                              Conds:RS_12._col1=RS_69._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9"]
+                            <-Map 9 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_69]
+                                PartitionCols:_col0
+                                Select Operator [SEL_68] (rows=138600 width=581)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Filter Operator [FIL_67] (rows=138600 width=581)
+                                    predicate:(i_category) IN ('Jewelry', 'Sports', 'Books')
+                                    TableScan [TS_6] (rows=462000 width=581)
+                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id","i_item_desc","i_current_price","i_class","i_category"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_12]
+                                PartitionCols:_col1
+                                Merge Join Operator [MERGEJOIN_57] (rows=15995224 width=115)
+                                  Conds:RS_77._col0=RS_61._col0(Inner),Output:["_col1","_col2"]
+                                <-Map 7 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_61]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_60] (rows=8116 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_59] (rows=8116 width=98)
+                                        predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'2001-01-12 00:00:00' AND TIMESTAMP'2001-02-11 00:00:00'
+                                        TableScan [TS_3] (rows=73049 width=98)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_77]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_76] (rows=143966864 width=119)
+                                      Output:["_col0","_col1","_col2"]
+                                      Filter Operator [FIL_75] (rows=143966864 width=119)
+                                        predicate:((ws_item_sk BETWEEN DynamicValue(RS_13_item_i_item_sk_min) AND DynamicValue(RS_13_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_13_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_10_date_dim_d_date_sk_min) AND DynamicValue(RS_10_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_10_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                        TableScan [TS_0] (rows=144002668 width=119)
+                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_ext_sales_price"]
+                                        <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_74]
+                                            Group By Operator [GBY_73] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_72]
+                                                Group By Operator [GBY_71] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_70] (rows=138600 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_68]
+                                        <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_66]
+                                            Group By Operator [GBY_65] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 7 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_64]
+                                                Group By Operator [GBY_63] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_62] (rows=8116 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_60]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query13.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query13.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query13.q.out
new file mode 100644
index 0000000..02966e4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query13.q.out
@@ -0,0 +1,255 @@
+PREHOOK: query: explain
+select avg(ss_quantity)
+       ,avg(ss_ext_sales_price)
+       ,avg(ss_ext_wholesale_cost)
+       ,sum(ss_ext_wholesale_cost)
+ from store_sales
+     ,store
+     ,customer_demographics
+     ,household_demographics
+     ,customer_address
+     ,date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 2001
+ and((ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'M'
+  and cd_education_status = '4 yr Degree'
+  and ss_sales_price between 100.00 and 150.00
+  and hd_dep_count = 3   
+     )or
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'D'
+  and cd_education_status = 'Primary'
+  and ss_sales_price between 50.00 and 100.00   
+  and hd_dep_count = 1
+     ) or 
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'U'
+  and cd_education_status = 'Advanced Degree'
+  and ss_sales_price between 150.00 and 200.00 
+  and hd_dep_count = 1  
+     ))
+ and((ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 100 and 200  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 300  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 250  
+     ))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select avg(ss_quantity)
+       ,avg(ss_ext_sales_price)
+       ,avg(ss_ext_wholesale_cost)
+       ,sum(ss_ext_wholesale_cost)
+ from store_sales
+     ,store
+     ,customer_demographics
+     ,household_demographics
+     ,customer_address
+     ,date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 2001
+ and((ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'M'
+  and cd_education_status = '4 yr Degree'
+  and ss_sales_price between 100.00 and 150.00
+  and hd_dep_count = 3   
+     )or
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'D'
+  and cd_education_status = 'Primary'
+  and ss_sales_price between 50.00 and 100.00   
+  and hd_dep_count = 1
+     ) or 
+     (ss_hdemo_sk=hd_demo_sk
+  and cd_demo_sk = ss_cdemo_sk
+  and cd_marital_status = 'U'
+  and cd_education_status = 'Advanced Degree'
+  and ss_sales_price between 150.00 and 200.00 
+  and hd_dep_count = 1  
+     ))
+ and((ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 100 and 200  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 300  
+     ) or
+     (ss_addr_sk = ca_address_sk
+  and ca_country = 'United States'
+  and ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 250  
+     ))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 8 <- Reducer 10 (BROADCAST_EDGE), Reducer 12 (BROADCAST_EDGE), Reducer 14 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Reducer 10 <- Map 9 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 13 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 9 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 11 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 13 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Map 1 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_135]
+        Select Operator [SEL_134] (rows=1 width=344)
+          Output:["_col0","_col1","_col2","_col3"]
+          Group By Operator [GBY_133] (rows=1 width=256)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)"]
+          <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+            PARTITION_ONLY_SHUFFLE [RS_31]
+              Group By Operator [GBY_30] (rows=1 width=256)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col5)","count(_col5)","sum(_col6)","count(_col6)","sum(_col7)","count(_col7)"]
+                Select Operator [SEL_29] (rows=40950 width=44)
+                  Output:["_col5","_col6","_col7"]
+                  Filter Operator [FIL_28] (rows=40950 width=44)
+                    predicate:((_col22 and _col23 and _col11 and _col15) or (_col24 and _col25 and _col12 and _col16) or (_col26 and _col27 and _col13 and _col16))
+                    Merge Join Operator [MERGEJOIN_97] (rows=218403 width=44)
+                      Conds:RS_25._col2=RS_124._col0(Inner),Output:["_col5","_col6","_col7","_col11","_col12","_col13","_col15","_col16","_col22","_col23","_col24","_col25","_col26","_col27"]
+                    <-Map 13 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_124]
+                        PartitionCols:_col0
+                        Select Operator [SEL_123] (rows=265971 width=28)
+                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                          Filter Operator [FIL_122] (rows=265971 width=183)
+                            predicate:((cd_education_status) IN ('4 yr Degree', 'Primary', 'Advanced Degree') and (cd_marital_status) IN ('M', 'D', 'U'))
+                            TableScan [TS_12] (rows=1861800 width=183)
+                              default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_marital_status","cd_education_status"]
+                    <-Reducer 4 [SIMPLE_EDGE]
+                      SHUFFLE [RS_25]
+                        PartitionCols:_col2
+                        Filter Operator [FIL_24] (rows=218403 width=44)
+                          predicate:((_col18 and _col8) or (_col19 and _col9) or (_col20 and _col10))
+                          Merge Join Operator [MERGEJOIN_96] (rows=291204 width=44)
+                            Conds:RS_21._col4=RS_116._col0(Inner),Output:["_col2","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col15","_col16","_col18","_col19","_col20"]
+                          <-Map 11 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_116]
+                              PartitionCols:_col0
+                              Select Operator [SEL_115] (rows=3529412 width=16)
+                                Output:["_col0","_col1","_col2","_col3"]
+                                Filter Operator [FIL_114] (rows=3529412 width=187)
+                                  predicate:((ca_country = 'United States') and (ca_state) IN ('KY', 'GA', 'NM', 'MT', 'OR', 'IN', 'WI', 'MO', 'WV'))
+                                  TableScan [TS_9] (rows=40000000 width=187)
+                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state","ca_country"]
+                          <-Reducer 3 [SIMPLE_EDGE]
+                            SHUFFLE [RS_21]
+                              PartitionCols:_col4
+                              Merge Join Operator [MERGEJOIN_95] (rows=3300311 width=104)
+                                Conds:RS_18._col3=RS_108._col0(Inner),Output:["_col2","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col15","_col16"]
+                              <-Map 9 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_108]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_107] (rows=1309 width=12)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_106] (rows=1309 width=8)
+                                      predicate:(hd_dep_count) IN (3, 1)
+                                      TableScan [TS_6] (rows=7200 width=8)
+                                        default@household_demographics,household_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["hd_demo_sk","hd_dep_count"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_18]
+                                  PartitionCols:_col3
+                                  Merge Join Operator [MERGEJOIN_94] (rows=18152968 width=233)
+                                    Conds:RS_100._col0=RS_132._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    PARTITION_ONLY_SHUFFLE [RS_100]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_99] (rows=652 width=4)
+                                        Output:["_col0"]
+                                        Filter Operator [FIL_98] (rows=652 width=8)
+                                          predicate:(d_year = 2001)
+                                          TableScan [TS_0] (rows=73049 width=8)
+                                            default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                  <-Map 8 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_132]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_131] (rows=50840141 width=257)
+                                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12"]
+                                        Filter Operator [FIL_130] (rows=50840141 width=450)
+                                          predicate:((ss_addr_sk BETWEEN DynamicValue(RS_22_customer_address_ca_address_sk_min) AND DynamicValue(RS_22_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_22_customer_address_ca_address_sk_bloom_filter))) and (ss_cdemo_sk BETWEEN DynamicValue(RS_26_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_26_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_26_customer_demographics_cd_demo_sk_bloom_filter))) and (ss_hdemo_sk BETWEEN DynamicValue(RS_19_household_demographics_hd_demo_sk_min) AND DynamicValue(RS_19_household_demographics_hd_demo_sk_max) and in_bloom_filter(ss_hdemo_sk, DynamicValue(RS_19_household_demographics_hd_demo_sk_bloom_filter))) and (ss_net_profit BETWEEN 100 AND 200 or ss_net_profit BETWEEN 150 AND 300 or ss_net_profit BETWEEN 50 AND 250) and (ss_sales_price BETWEEN 100 AND 150 or ss_sales_price BETWEEN 50 AND 100 or ss_sales_price BETWEEN 150 A
 ND 200) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_cdemo_sk is not null and ss_hdemo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                          TableScan [TS_3] (rows=575995635 width=450)
+                                            default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_cdemo_sk","ss_hdemo_sk","ss_addr_sk","ss_store_sk","ss_quantity","ss_sales_price","ss_ext_sales_price","ss_ext_wholesale_cost","ss_net_profit"]
+                                          <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_113]
+                                              Group By Operator [GBY_112] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 9 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_111]
+                                                  Group By Operator [GBY_110] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_109] (rows=1309 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_107]
+                                          <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_121]
+                                              Group By Operator [GBY_120] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=3529412)"]
+                                              <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_119]
+                                                  Group By Operator [GBY_118] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=3529412)"]
+                                                    Select Operator [SEL_117] (rows=3529412 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_115]
+                                          <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_129]
+                                              Group By Operator [GBY_128] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 13 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_127]
+                                                  Group By Operator [GBY_126] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_125] (rows=265971 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_123]
+                                          <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                            BROADCAST [RS_105]
+                                              Group By Operator [GBY_104] (rows=1 width=12)
+                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                              <-Map 1 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                PARTITION_ONLY_SHUFFLE [RS_103]
+                                                  Group By Operator [GBY_102] (rows=1 width=12)
+                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                    Select Operator [SEL_101] (rows=652 width=4)
+                                                      Output:["_col0"]
+                                                       Please refer to the previous Select Operator [SEL_99]
+


[55/75] [abbrv] hive git commit: HIVE-20679: DDL operations on hive might create large messages for DBNotification (Anishek Agarwal, reviewed by Sankar Hariappan)

Posted by se...@apache.org.
HIVE-20679: DDL operations on hive might create large messages for DBNotification (Anishek Agarwal, reviewed by Sankar Hariappan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b4302bb7
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b4302bb7
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b4302bb7

Branch: refs/heads/master-tez092
Commit: b4302bb7ad967f15ca1b708685b2ac669e3cf037
Parents: b829955
Author: Anishek Agarwal <an...@gmail.com>
Authored: Mon Oct 22 13:51:43 2018 +0530
Committer: Anishek Agarwal <an...@gmail.com>
Committed: Mon Oct 22 13:51:43 2018 +0530

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/conf/HiveConf.java   |   2 +-
 .../listener/DbNotificationListener.java        | 182 +++++---
 .../json/JSONCreateFunctionMessage.java         |   3 +-
 .../messaging/json/JSONDropFunctionMessage.java |   3 +-
 .../messaging/json/JSONMessageFactory.java      |  39 +-
 .../listener/TestDbNotificationListener.java    |  14 +-
 .../TestReplAcidTablesWithJsonMessage.java      |  43 ++
 ...eplAcrossInstancesWithJsonMessageFormat.java |  45 ++
 ...ncrementalLoadAcidTablesWithJsonMessage.java |  46 ++
 .../ql/parse/TestReplWithJsonMessageFormat.java |  39 ++
 .../hive/ql/parse/TestReplicationScenarios.java |  82 ++--
 .../TestReplicationScenariosAcidTables.java     |  61 +--
 ...TestReplicationScenariosAcrossInstances.java | 103 +++--
 ...ationScenariosIncrementalLoadAcidTables.java |  55 ++-
 .../hadoop/hive/ql/parse/WarehouseInstance.java |   2 +-
 .../ql/cache/results/QueryResultsCache.java     |  14 +-
 .../hadoop/hive/ql/exec/repl/ReplDumpTask.java  |   5 +-
 .../repl/bootstrap/load/LoadConstraint.java     |   4 +-
 .../parse/repl/dump/events/AbortTxnHandler.java |  12 +-
 .../events/AbstractConstraintEventHandler.java  |   3 +-
 .../repl/dump/events/AbstractEventHandler.java  |  32 +-
 .../repl/dump/events/AddForeignKeyHandler.java  |  12 +-
 .../events/AddNotNullConstraintHandler.java     |  12 +-
 .../repl/dump/events/AddPartitionHandler.java   |  10 +-
 .../repl/dump/events/AddPrimaryKeyHandler.java  |  12 +-
 .../dump/events/AddUniqueConstraintHandler.java |  13 +-
 .../repl/dump/events/AllocWriteIdHandler.java   |  12 +-
 .../repl/dump/events/AlterDatabaseHandler.java  |  12 +-
 .../repl/dump/events/AlterPartitionHandler.java |  21 +-
 .../repl/dump/events/AlterTableHandler.java     |  18 +-
 .../repl/dump/events/CommitTxnHandler.java      |  28 +-
 .../repl/dump/events/CreateDatabaseHandler.java |  13 +-
 .../repl/dump/events/CreateFunctionHandler.java |  13 +-
 .../repl/dump/events/CreateTableHandler.java    |  15 +-
 .../parse/repl/dump/events/DefaultHandler.java  |   9 +
 .../repl/dump/events/DropConstraintHandler.java |  13 +-
 .../repl/dump/events/DropDatabaseHandler.java   |  12 +-
 .../repl/dump/events/DropFunctionHandler.java   |  12 +-
 .../repl/dump/events/DropPartitionHandler.java  |  12 +-
 .../repl/dump/events/DropTableHandler.java      |  12 +-
 .../repl/dump/events/EventHandlerFactory.java   |  44 +-
 .../parse/repl/dump/events/InsertHandler.java   |  22 +-
 .../parse/repl/dump/events/OpenTxnHandler.java  |  12 +-
 .../repl/dump/io/ConstraintsSerializer.java     |  10 +-
 .../load/message/AbstractMessageHandler.java    |   4 +-
 .../dump/events/TestEventHandlerFactory.java    |   7 +-
 .../hive/metastore/conf/MetastoreConf.java      |   2 +-
 .../hive/metastore/messaging/EventMessage.java  |  64 +--
 .../metastore/messaging/MessageBuilder.java     | 425 ++++++++++++++++++
 .../metastore/messaging/MessageEncoder.java     |  27 ++
 .../metastore/messaging/MessageFactory.java     | 367 +++-------------
 .../metastore/messaging/MessageSerializer.java  |  24 ++
 .../event/filters/DatabaseAndTableFilter.java   |   8 +-
 .../messaging/json/JSONAcidWriteMessage.java    |   9 +-
 .../json/JSONAddForeignKeyMessage.java          |   5 +-
 .../json/JSONAddNotNullConstraintMessage.java   |   5 +-
 .../messaging/json/JSONAddPartitionMessage.java |  11 +-
 .../json/JSONAddPrimaryKeyMessage.java          |   5 +-
 .../json/JSONAddUniqueConstraintMessage.java    |   5 +-
 .../messaging/json/JSONAlterCatalogMessage.java |   9 +-
 .../json/JSONAlterDatabaseMessage.java          |   9 +-
 .../json/JSONAlterPartitionMessage.java         |  15 +-
 .../messaging/json/JSONAlterTableMessage.java   |   9 +-
 .../messaging/json/JSONCommitTxnMessage.java    |   5 +-
 .../json/JSONCreateDatabaseMessage.java         |   5 +-
 .../json/JSONCreateFunctionMessage.java         |   5 +-
 .../messaging/json/JSONCreateTableMessage.java  |   5 +-
 .../json/JSONDropPartitionMessage.java          |   5 +-
 .../messaging/json/JSONDropTableMessage.java    |   5 +-
 .../messaging/json/JSONInsertMessage.java       |   9 +-
 .../messaging/json/JSONMessageEncoder.java      |  70 +++
 .../messaging/json/JSONMessageFactory.java      | 432 -------------------
 .../messaging/json/gzip/DeSerializer.java       | 181 ++++++++
 .../json/gzip/GzipJSONMessageEncoder.java       |  68 +++
 .../messaging/json/gzip/Serializer.java         |  32 ++
 .../hive/metastore/MetaStoreTestUtils.java      |  11 +
 .../ptest2/conf/deployed/master-mr2.properties  |   2 +-
 77 files changed, 1781 insertions(+), 1202 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
index bcf1e9e..ed6d3d8 100644
--- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
+++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
@@ -1176,7 +1176,7 @@ public class HiveConf extends Configuration {
      */
     @Deprecated
     METASTORE_EVENT_MESSAGE_FACTORY("hive.metastore.event.message.factory",
-        "org.apache.hadoop.hive.metastore.messaging.json.JSONMessageFactory",
+        "org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder",
         "Factory class for making encoding and decoding messages in the events generated."),
     /**
      * @deprecated Use MetastoreConf.EXECUTE_SET_UGI

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
----------------------------------------------------------------------
diff --git a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
index 4313e12..c23aab2 100644
--- a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
+++ b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
@@ -78,9 +78,32 @@ import org.apache.hadoop.hive.metastore.events.AbortTxnEvent;
 import org.apache.hadoop.hive.metastore.events.AllocWriteIdEvent;
 import org.apache.hadoop.hive.metastore.events.ListenerEvent;
 import org.apache.hadoop.hive.metastore.events.AcidWriteEvent;
+import org.apache.hadoop.hive.metastore.messaging.AbortTxnMessage;
 import org.apache.hadoop.hive.metastore.messaging.AcidWriteMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddForeignKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddNotNullConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage;
+import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.AllocWriteIdMessage;
+import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.AlterTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.CommitTxnMessage;
+import org.apache.hadoop.hive.metastore.messaging.CreateDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage;
+import org.apache.hadoop.hive.metastore.messaging.CreateTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
+import org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropDatabaseMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropFunctionMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.DropTableMessage;
+import org.apache.hadoop.hive.metastore.messaging.EventMessage;
 import org.apache.hadoop.hive.metastore.messaging.EventMessage.EventType;
+import org.apache.hadoop.hive.metastore.messaging.InsertMessage;
+import org.apache.hadoop.hive.metastore.messaging.MessageEncoder;
 import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.MessageSerializer;
 import org.apache.hadoop.hive.metastore.messaging.OpenTxnMessage;
 import org.apache.hadoop.hive.metastore.messaging.PartitionFiles;
 import org.apache.hadoop.hive.metastore.tools.SQLGenerator;
@@ -110,7 +133,7 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   private static CleanerThread cleaner = null;
 
   private Configuration conf;
-  private MessageFactory msgFactory;
+  private MessageEncoder msgEncoder;
 
   //cleaner is a static object, use static synchronized to make sure its thread-safe
   private static synchronized void init(Configuration conf) throws MetaException {
@@ -126,7 +149,7 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
     super(config);
     conf = config;
     DbNotificationListener.init(conf);
-    msgFactory = MessageFactory.getInstance();
+    msgEncoder = MessageFactory.getDefaultInstance(conf);
   }
 
   /**
@@ -172,9 +195,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
     Table t = tableEvent.getTable();
     FileIterator fileIter = MetaStoreUtils.isExternalTable(t)
                               ? null : new FileIterator(t.getSd().getLocation());
+    CreateTableMessage msg =
+        MessageBuilder.getInstance().buildCreateTableMessage(t, fileIter);
     NotificationEvent event =
         new NotificationEvent(0, now(), EventType.CREATE_TABLE.toString(),
-                msgFactory.buildCreateTableMessage(t, fileIter).toString());
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(t.isSetCatName() ? t.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(t.getDbName());
     event.setTableName(t.getTableName());
@@ -188,9 +213,10 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onDropTable(DropTableEvent tableEvent) throws MetaException {
     Table t = tableEvent.getTable();
+    DropTableMessage msg = MessageBuilder.getInstance().buildDropTableMessage(t);
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.DROP_TABLE.toString(), msgFactory
-            .buildDropTableMessage(t).toString());
+        new NotificationEvent(0, now(), EventType.DROP_TABLE.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(t.isSetCatName() ? t.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(t.getDbName());
     event.setTableName(t.getTableName());
@@ -205,9 +231,13 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   public void onAlterTable(AlterTableEvent tableEvent) throws MetaException {
     Table before = tableEvent.getOldTable();
     Table after = tableEvent.getNewTable();
+    AlterTableMessage msg = MessageBuilder.getInstance()
+        .buildAlterTableMessage(before, after, tableEvent.getIsTruncateOp(),
+            tableEvent.getWriteId());
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.ALTER_TABLE.toString(), msgFactory
-            .buildAlterTableMessage(before, after, tableEvent.getIsTruncateOp(), tableEvent.getWriteId()).toString());
+        new NotificationEvent(0, now(), EventType.ALTER_TABLE.toString(),
+            msgEncoder.getSerializer().serialize(msg)
+        );
     event.setCatName(after.isSetCatName() ? after.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(after.getDbName());
     event.setTableName(after.getTableName());
@@ -320,10 +350,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
     Table t = partitionEvent.getTable();
     PartitionFilesIterator fileIter = MetaStoreUtils.isExternalTable(t)
             ? null : new PartitionFilesIterator(partitionEvent.getPartitionIterator(), t);
-    String msg = msgFactory
-        .buildAddPartitionMessage(t, partitionEvent.getPartitionIterator(), fileIter).toString();
-    NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.ADD_PARTITION.toString(), msg);
+    EventMessage msg = MessageBuilder.getInstance()
+        .buildAddPartitionMessage(t, partitionEvent.getPartitionIterator(), fileIter);
+    MessageSerializer serializer = msgEncoder.getSerializer();
+
+    NotificationEvent event = new NotificationEvent(0, now(),
+        EventType.ADD_PARTITION.toString(), serializer.serialize(msg));
     event.setCatName(t.isSetCatName() ? t.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(t.getDbName());
     event.setTableName(t.getTableName());
@@ -337,9 +369,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException {
     Table t = partitionEvent.getTable();
-    NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.DROP_PARTITION.toString(), msgFactory
-            .buildDropPartitionMessage(t, partitionEvent.getPartitionIterator()).toString());
+    DropPartitionMessage msg =
+        MessageBuilder.getInstance()
+            .buildDropPartitionMessage(t, partitionEvent.getPartitionIterator());
+    NotificationEvent event = new NotificationEvent(0, now(), EventType.DROP_PARTITION.toString(),
+        msgEncoder.getSerializer().serialize(msg));
     event.setCatName(t.isSetCatName() ? t.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(t.getDbName());
     event.setTableName(t.getTableName());
@@ -354,10 +388,13 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   public void onAlterPartition(AlterPartitionEvent partitionEvent) throws MetaException {
     Partition before = partitionEvent.getOldPartition();
     Partition after = partitionEvent.getNewPartition();
+    AlterPartitionMessage msg = MessageBuilder.getInstance()
+        .buildAlterPartitionMessage(partitionEvent.getTable(), before, after,
+            partitionEvent.getIsTruncateOp(),
+            partitionEvent.getWriteId());
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.ALTER_PARTITION.toString(), msgFactory
-            .buildAlterPartitionMessage(partitionEvent.getTable(), before, after, partitionEvent.getIsTruncateOp(),
-                    partitionEvent.getWriteId()).toString());
+        new NotificationEvent(0, now(), EventType.ALTER_PARTITION.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(before.isSetCatName() ? before.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(before.getDbName());
     event.setTableName(before.getTableName());
@@ -371,9 +408,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onCreateDatabase(CreateDatabaseEvent dbEvent) throws MetaException {
     Database db = dbEvent.getDatabase();
+    CreateDatabaseMessage msg = MessageBuilder.getInstance()
+        .buildCreateDatabaseMessage(db);
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.CREATE_DATABASE.toString(), msgFactory
-            .buildCreateDatabaseMessage(db).toString());
+        new NotificationEvent(0, now(), EventType.CREATE_DATABASE.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(db.isSetCatalogName() ? db.getCatalogName() : DEFAULT_CATALOG_NAME);
     event.setDbName(db.getName());
     process(event, dbEvent);
@@ -386,9 +425,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException {
     Database db = dbEvent.getDatabase();
+    DropDatabaseMessage msg = MessageBuilder.getInstance()
+        .buildDropDatabaseMessage(db);
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.DROP_DATABASE.toString(), msgFactory
-            .buildDropDatabaseMessage(db).toString());
+        new NotificationEvent(0, now(), EventType.DROP_DATABASE.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(db.isSetCatalogName() ? db.getCatalogName() : DEFAULT_CATALOG_NAME);
     event.setDbName(db.getName());
     process(event, dbEvent);
@@ -402,9 +443,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   public void onAlterDatabase(AlterDatabaseEvent dbEvent) throws MetaException {
     Database oldDb = dbEvent.getOldDatabase();
     Database newDb = dbEvent.getNewDatabase();
+    AlterDatabaseMessage msg = MessageBuilder.getInstance()
+        .buildAlterDatabaseMessage(oldDb, newDb);
     NotificationEvent event =
-            new NotificationEvent(0, now(), EventType.ALTER_DATABASE.toString(), msgFactory
-                    .buildAlterDatabaseMessage(oldDb, newDb).toString());
+        new NotificationEvent(0, now(), EventType.ALTER_DATABASE.toString(),
+            msgEncoder.getSerializer().serialize(msg)
+        );
     event.setCatName(oldDb.isSetCatalogName() ? oldDb.getCatalogName() : DEFAULT_CATALOG_NAME);
     event.setDbName(oldDb.getName());
     process(event, dbEvent);
@@ -417,9 +461,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onCreateFunction(CreateFunctionEvent fnEvent) throws MetaException {
     Function fn = fnEvent.getFunction();
+    CreateFunctionMessage msg = MessageBuilder.getInstance()
+        .buildCreateFunctionMessage(fn);
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.CREATE_FUNCTION.toString(), msgFactory
-            .buildCreateFunctionMessage(fn).toString());
+        new NotificationEvent(0, now(), EventType.CREATE_FUNCTION.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(fn.isSetCatName() ? fn.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(fn.getDbName());
     process(event, fnEvent);
@@ -432,9 +478,10 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onDropFunction(DropFunctionEvent fnEvent) throws MetaException {
     Function fn = fnEvent.getFunction();
+    DropFunctionMessage msg = MessageBuilder.getInstance().buildDropFunctionMessage(fn);
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.DROP_FUNCTION.toString(), msgFactory
-            .buildDropFunctionMessage(fn).toString());
+        new NotificationEvent(0, now(), EventType.DROP_FUNCTION.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(fn.isSetCatName() ? fn.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(fn.getDbName());
     process(event, fnEvent);
@@ -481,11 +528,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onInsert(InsertEvent insertEvent) throws MetaException {
     Table tableObj = insertEvent.getTableObj();
+    InsertMessage msg = MessageBuilder.getInstance().buildInsertMessage(tableObj,
+        insertEvent.getPartitionObj(), insertEvent.isReplace(),
+        new FileChksumIterator(insertEvent.getFiles(), insertEvent.getFileChecksums()));
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.INSERT.toString(), msgFactory.buildInsertMessage(tableObj,
-                insertEvent.getPartitionObj(), insertEvent.isReplace(),
-            new FileChksumIterator(insertEvent.getFiles(), insertEvent.getFileChecksums()))
-                .toString());
+        new NotificationEvent(0, now(), EventType.INSERT.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(tableObj.isSetCatName() ? tableObj.getCatName() : DEFAULT_CATALOG_NAME);
     event.setDbName(tableObj.getDbName());
     event.setTableName(tableObj.getTableName());
@@ -495,10 +543,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onOpenTxn(OpenTxnEvent openTxnEvent, Connection dbConn, SQLGenerator sqlGenerator) throws MetaException {
     int lastTxnIdx = openTxnEvent.getTxnIds().size() - 1;
-    OpenTxnMessage msg = msgFactory.buildOpenTxnMessage(openTxnEvent.getTxnIds().get(0),
+    OpenTxnMessage msg =
+        MessageBuilder.getInstance().buildOpenTxnMessage(openTxnEvent.getTxnIds().get(0),
             openTxnEvent.getTxnIds().get(lastTxnIdx));
     NotificationEvent event =
-            new NotificationEvent(0, now(), EventType.OPEN_TXN.toString(), msg.toString());
+        new NotificationEvent(0, now(), EventType.OPEN_TXN.toString(),
+            msgEncoder.getSerializer().serialize(msg));
 
     try {
       addNotificationLog(event, openTxnEvent, dbConn, sqlGenerator);
@@ -510,10 +560,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onCommitTxn(CommitTxnEvent commitTxnEvent, Connection dbConn, SQLGenerator sqlGenerator)
           throws MetaException {
+    CommitTxnMessage msg =
+        MessageBuilder.getInstance().buildCommitTxnMessage(commitTxnEvent.getTxnId());
+
     NotificationEvent event =
-            new NotificationEvent(0, now(), EventType.COMMIT_TXN.toString(), msgFactory.buildCommitTxnMessage(
-                    commitTxnEvent.getTxnId())
-                    .toString());
+        new NotificationEvent(0, now(), EventType.COMMIT_TXN.toString(),
+            msgEncoder.getSerializer().serialize(msg));
 
     try {
       addNotificationLog(event, commitTxnEvent, dbConn, sqlGenerator);
@@ -525,10 +577,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onAbortTxn(AbortTxnEvent abortTxnEvent, Connection dbConn, SQLGenerator sqlGenerator)
           throws MetaException {
+    AbortTxnMessage msg =
+        MessageBuilder.getInstance().buildAbortTxnMessage(abortTxnEvent.getTxnId());
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.ABORT_TXN.toString(), msgFactory.buildAbortTxnMessage(
-            abortTxnEvent.getTxnId())
-            .toString());
+        new NotificationEvent(0, now(), EventType.ABORT_TXN.toString(),
+            msgEncoder.getSerializer().serialize(msg));
 
     try {
       addNotificationLog(event, abortTxnEvent, dbConn, sqlGenerator);
@@ -555,9 +608,10 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   public void onAddPrimaryKey(AddPrimaryKeyEvent addPrimaryKeyEvent) throws MetaException {
     List<SQLPrimaryKey> cols = addPrimaryKeyEvent.getPrimaryKeyCols();
     if (cols.size() > 0) {
-      NotificationEvent event =
-          new NotificationEvent(0, now(), EventType.ADD_PRIMARYKEY.toString(), msgFactory
-              .buildAddPrimaryKeyMessage(addPrimaryKeyEvent.getPrimaryKeyCols()).toString());
+      AddPrimaryKeyMessage msg = MessageBuilder.getInstance()
+          .buildAddPrimaryKeyMessage(addPrimaryKeyEvent.getPrimaryKeyCols());
+      NotificationEvent event = new NotificationEvent(0, now(), EventType.ADD_PRIMARYKEY.toString(),
+          msgEncoder.getSerializer().serialize(msg));
       event.setCatName(cols.get(0).isSetCatName() ? cols.get(0).getCatName() : DEFAULT_CATALOG_NAME);
       event.setDbName(cols.get(0).getTable_db());
       event.setTableName(cols.get(0).getTable_name());
@@ -573,9 +627,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   public void onAddForeignKey(AddForeignKeyEvent addForeignKeyEvent) throws MetaException {
     List<SQLForeignKey> cols = addForeignKeyEvent.getForeignKeyCols();
     if (cols.size() > 0) {
+      AddForeignKeyMessage msg = MessageBuilder.getInstance()
+          .buildAddForeignKeyMessage(addForeignKeyEvent.getForeignKeyCols());
       NotificationEvent event =
-          new NotificationEvent(0, now(), EventType.ADD_FOREIGNKEY.toString(), msgFactory
-              .buildAddForeignKeyMessage(addForeignKeyEvent.getForeignKeyCols()).toString());
+          new NotificationEvent(0, now(), EventType.ADD_FOREIGNKEY.toString(),
+              msgEncoder.getSerializer().serialize(msg));
       event.setCatName(cols.get(0).isSetCatName() ? cols.get(0).getCatName() : DEFAULT_CATALOG_NAME);
       event.setDbName(cols.get(0).getPktable_db());
       event.setTableName(cols.get(0).getPktable_name());
@@ -591,9 +647,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   public void onAddUniqueConstraint(AddUniqueConstraintEvent addUniqueConstraintEvent) throws MetaException {
     List<SQLUniqueConstraint> cols = addUniqueConstraintEvent.getUniqueConstraintCols();
     if (cols.size() > 0) {
+      AddUniqueConstraintMessage msg = MessageBuilder.getInstance()
+          .buildAddUniqueConstraintMessage(addUniqueConstraintEvent.getUniqueConstraintCols());
       NotificationEvent event =
-          new NotificationEvent(0, now(), EventType.ADD_UNIQUECONSTRAINT.toString(), msgFactory
-              .buildAddUniqueConstraintMessage(addUniqueConstraintEvent.getUniqueConstraintCols()).toString());
+          new NotificationEvent(0, now(), EventType.ADD_UNIQUECONSTRAINT.toString(),
+              msgEncoder.getSerializer().serialize(msg)
+          );
       event.setCatName(cols.get(0).isSetCatName() ? cols.get(0).getCatName() : DEFAULT_CATALOG_NAME);
       event.setDbName(cols.get(0).getTable_db());
       event.setTableName(cols.get(0).getTable_name());
@@ -609,9 +668,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   public void onAddNotNullConstraint(AddNotNullConstraintEvent addNotNullConstraintEvent) throws MetaException {
     List<SQLNotNullConstraint> cols = addNotNullConstraintEvent.getNotNullConstraintCols();
     if (cols.size() > 0) {
+      AddNotNullConstraintMessage msg = MessageBuilder.getInstance()
+          .buildAddNotNullConstraintMessage(addNotNullConstraintEvent.getNotNullConstraintCols());
       NotificationEvent event =
-          new NotificationEvent(0, now(), EventType.ADD_NOTNULLCONSTRAINT.toString(), msgFactory
-              .buildAddNotNullConstraintMessage(addNotNullConstraintEvent.getNotNullConstraintCols()).toString());
+          new NotificationEvent(0, now(), EventType.ADD_NOTNULLCONSTRAINT.toString(),
+              msgEncoder.getSerializer().serialize(msg)
+          );
       event.setCatName(cols.get(0).isSetCatName() ? cols.get(0).getCatName() : DEFAULT_CATALOG_NAME);
       event.setDbName(cols.get(0).getTable_db());
       event.setTableName(cols.get(0).getTable_name());
@@ -628,9 +690,11 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
     String dbName = dropConstraintEvent.getDbName();
     String tableName = dropConstraintEvent.getTableName();
     String constraintName = dropConstraintEvent.getConstraintName();
+    DropConstraintMessage msg = MessageBuilder.getInstance()
+        .buildDropConstraintMessage(dbName, tableName, constraintName);
     NotificationEvent event =
-        new NotificationEvent(0, now(), EventType.DROP_CONSTRAINT.toString(), msgFactory
-            .buildDropConstraintMessage(dbName, tableName, constraintName).toString());
+        new NotificationEvent(0, now(), EventType.DROP_CONSTRAINT.toString(),
+            msgEncoder.getSerializer().serialize(msg));
     event.setCatName(dropConstraintEvent.getCatName());
     event.setDbName(dbName);
     event.setTableName(tableName);
@@ -646,9 +710,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
           throws MetaException {
     String tableName = allocWriteIdEvent.getTableName();
     String dbName = allocWriteIdEvent.getDbName();
+    AllocWriteIdMessage msg = MessageBuilder.getInstance()
+        .buildAllocWriteIdMessage(allocWriteIdEvent.getTxnToWriteIdList(), dbName, tableName);
     NotificationEvent event =
-            new NotificationEvent(0, now(), EventType.ALLOC_WRITE_ID.toString(), msgFactory
-                    .buildAllocWriteIdMessage(allocWriteIdEvent.getTxnToWriteIdList(), dbName, tableName).toString());
+        new NotificationEvent(0, now(), EventType.ALLOC_WRITE_ID.toString(),
+            msgEncoder.getSerializer().serialize(msg)
+        );
     event.setTableName(tableName);
     event.setDbName(dbName);
     try {
@@ -661,11 +728,12 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
   @Override
   public void onAcidWrite(AcidWriteEvent acidWriteEvent, Connection dbConn, SQLGenerator sqlGenerator)
           throws MetaException {
-    AcidWriteMessage msg = msgFactory.buildAcidWriteMessage(acidWriteEvent,
+    AcidWriteMessage msg = MessageBuilder.getInstance().buildAcidWriteMessage(acidWriteEvent,
             new FileChksumIterator(acidWriteEvent.getFiles(), acidWriteEvent.getChecksums(),
                     acidWriteEvent.getSubDirs()));
-    NotificationEvent event = new NotificationEvent(0, now(), EventType.ACID_WRITE.toString(), msg.toString());
-    event.setMessageFormat(msgFactory.getMessageFormat());
+    NotificationEvent event = new NotificationEvent(0, now(), EventType.ACID_WRITE.toString(),
+        msgEncoder.getSerializer().serialize(msg));
+    event.setMessageFormat(msgEncoder.getMessageFormat());
     event.setDbName(acidWriteEvent.getDatabase());
     event.setTableName(acidWriteEvent.getTable());
     try {
@@ -848,7 +916,7 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
     ResultSet rs = null;
     try {
       stmt = dbConn.createStatement();
-      event.setMessageFormat(msgFactory.getMessageFormat());
+      event.setMessageFormat(msgEncoder.getMessageFormat());
 
       if (sqlGenerator.getDbProduct() == MYSQL) {
         stmt.execute("SET @@session.sql_mode=ANSI_QUOTES");
@@ -910,7 +978,7 @@ public class DbNotificationListener extends TransactionalMetaStoreEventListener
    *                      DB_NOTIFICATION_EVENT_ID_KEY_NAME for future reference by other listeners.
    */
   private void process(NotificationEvent event, ListenerEvent listenerEvent) throws MetaException {
-    event.setMessageFormat(msgFactory.getMessageFormat());
+    event.setMessageFormat(msgEncoder.getMessageFormat());
     LOG.debug("DbNotificationListener: Processing : {}:{}", event.getEventId(),
         event.getMessage());
     HMSHandler.getMSForConf(conf).addNotificationEvent(event);

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateFunctionMessage.java
----------------------------------------------------------------------
diff --git a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateFunctionMessage.java b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateFunctionMessage.java
index 4707d0e..17d3b73 100644
--- a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateFunctionMessage.java
+++ b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateFunctionMessage.java
@@ -20,6 +20,7 @@
 package org.apache.hive.hcatalog.messaging.json;
 
 import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hive.hcatalog.messaging.CreateFunctionMessage;
 import org.apache.thrift.TException;
 import org.codehaus.jackson.annotate.JsonProperty;
@@ -46,7 +47,7 @@ public class JSONCreateFunctionMessage extends CreateFunctionMessage {
     this.db = fn.getDbName();
     this.timestamp = timestamp;
     try {
-      this.functionObjJson = JSONMessageFactory.createFunctionObjJson(fn);
+      this.functionObjJson = MessageBuilder.createFunctionObjJson(fn);
     } catch (TException ex) {
       throw new IllegalArgumentException("Could not serialize Function object", ex);
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropFunctionMessage.java
----------------------------------------------------------------------
diff --git a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropFunctionMessage.java b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropFunctionMessage.java
index 010c4a6..7fb7d1c 100644
--- a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropFunctionMessage.java
+++ b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropFunctionMessage.java
@@ -20,6 +20,7 @@
 package org.apache.hive.hcatalog.messaging.json;
 
 import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hive.hcatalog.messaging.DropFunctionMessage;
 import org.apache.thrift.TException;
 import org.codehaus.jackson.annotate.JsonProperty;
@@ -46,7 +47,7 @@ public class JSONDropFunctionMessage extends DropFunctionMessage {
     this.db = fn.getDbName();
     this.timestamp = timestamp;
     try {
-      this.functionObjJson = JSONMessageFactory.createFunctionObjJson(fn);
+      this.functionObjJson = MessageBuilder.createFunctionObjJson(fn);
     } catch (TException ex) {
       throw new IllegalArgumentException("Could not serialize Function object", ex);
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java
----------------------------------------------------------------------
diff --git a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java
index ec573a3..770dd1e 100644
--- a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java
+++ b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java
@@ -20,16 +20,14 @@
 package org.apache.hive.hcatalog.messaging.json;
 
 import java.util.Iterator;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.annotation.Nullable;
-
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.Function;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
 import org.apache.hive.hcatalog.messaging.AddPartitionMessage;
 import org.apache.hive.hcatalog.messaging.AlterPartitionMessage;
 import org.apache.hive.hcatalog.messaging.AlterTableMessage;
@@ -43,15 +41,9 @@ import org.apache.hive.hcatalog.messaging.DropTableMessage;
 import org.apache.hive.hcatalog.messaging.InsertMessage;
 import org.apache.hive.hcatalog.messaging.MessageDeserializer;
 import org.apache.hive.hcatalog.messaging.MessageFactory;
-import org.apache.thrift.TException;
-import org.apache.thrift.TSerializer;
-import org.apache.thrift.protocol.TJSONProtocol;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-
 /**
  * The JSON implementation of the MessageFactory. Constructs JSON implementations of
  * each message-type.
@@ -111,7 +103,7 @@ public class JSONMessageFactory extends MessageFactory {
   public AddPartitionMessage buildAddPartitionMessage(Table table, Iterator<Partition> partitionsIterator) {
     return new JSONAddPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(),
         table.getTableName(), table.getTableType(),
-        getPartitionKeyValues(table, partitionsIterator), now());
+        MessageBuilder.getPartitionKeyValues(table, partitionsIterator), now());
   }
 
   @Override
@@ -119,14 +111,14 @@ public class JSONMessageFactory extends MessageFactory {
                                                           Long writeId) {
     return new JSONAlterPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL,
         before.getDbName(), before.getTableName(), table.getTableType(),
-        getPartitionKeyValues(table,before), writeId, now());
+        MessageBuilder.getPartitionKeyValues(table,before), writeId, now());
   }
 
   @Override
   public DropPartitionMessage buildDropPartitionMessage(Table table, Iterator<Partition> partitions) {
     return new JSONDropPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(),
         table.getTableName(), table.getTableType(),
-        getPartitionKeyValues(table, partitions), now());
+        MessageBuilder.getPartitionKeyValues(table, partitions), now());
   }
 
   @Override
@@ -159,27 +151,4 @@ public class JSONMessageFactory extends MessageFactory {
     return System.currentTimeMillis() / 1000;
   }
 
-  private static Map<String, String> getPartitionKeyValues(Table table, Partition partition) {
-    Map<String, String> partitionKeys = new LinkedHashMap<String, String>();
-    for (int i=0; i<table.getPartitionKeysSize(); ++i) {
-      partitionKeys.put(table.getPartitionKeys().get(i).getName(),
-          partition.getValues().get(i));
-    }
-    return partitionKeys;
-  }
-
-  private static List<Map<String, String>> getPartitionKeyValues(final Table table, Iterator<Partition> iterator) {
-    return Lists.newArrayList(Iterators.transform(iterator, new com.google.common.base.Function<Partition, Map<String, String>>() {
-      @Override
-      public Map<String, String> apply(@Nullable Partition partition) {
-        return getPartitionKeyValues(table, partition);
-      }
-    }));
-  }
-
-  static String createFunctionObjJson(Function functionObj) throws TException {
-    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
-    return serializer.toString(functionObj, "UTF-8");
-  }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
----------------------------------------------------------------------
diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
index a00ea17..dc555a4 100644
--- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
+++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
@@ -93,6 +93,7 @@ import org.apache.hadoop.hive.metastore.messaging.EventMessage.EventType;
 import org.apache.hadoop.hive.metastore.messaging.InsertMessage;
 import org.apache.hadoop.hive.metastore.messaging.MessageDeserializer;
 import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
 import org.apache.hadoop.hive.ql.DriverFactory;
 import org.apache.hadoop.hive.ql.IDriver;
 import org.apache.hadoop.hive.ql.session.SessionState;
@@ -119,7 +120,16 @@ public class TestDbNotificationListener {
   private static Map<String, String> emptyParameters = new HashMap<String, String>();
   private static IMetaStoreClient msClient;
   private static IDriver driver;
-  private static MessageDeserializer md = null;
+  private static MessageDeserializer md;
+
+  static {
+    try {
+      md = MessageFactory.getInstance(JSONMessageEncoder.FORMAT).getDeserializer();
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+  }
+
   private int startTime;
   private long firstEventId;
   private final String testTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "testDbNotif").toString();
@@ -267,7 +277,7 @@ public class TestDbNotificationListener {
     SessionState.start(new CliSessionState(conf));
     msClient = new HiveMetaStoreClient(conf);
     driver = DriverFactory.newDriver(conf);
-    md = MessageFactory.getInstance().getDeserializer();
+    md = JSONMessageEncoder.getInstance().getDeserializer();
 
     bcompat = new ReplicationV1CompatRule(msClient, conf, testsToSkipForReplV1BackwardCompatTesting );
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcidTablesWithJsonMessage.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcidTablesWithJsonMessage.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcidTablesWithJsonMessage.java
new file mode 100644
index 0000000..c16799d
--- /dev/null
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcidTablesWithJsonMessage.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.parse;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+
+import java.util.Collections;
+
+public class TestReplAcidTablesWithJsonMessage extends TestReplicationScenariosAcidTables {
+
+  @Rule
+  public TestRule replV1BackwardCompat;
+
+  @BeforeClass
+  public static void classLevelSetup() throws Exception {
+    internalBeforeClassSetup(Collections.emptyMap(), TestReplAcidTablesWithJsonMessage.class);
+  }
+
+  @Before
+  public void setup() throws Throwable {
+    replV1BackwardCompat = primary.getReplivationV1CompatRule(Collections.emptyList());
+    super.setup();
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcrossInstancesWithJsonMessageFormat.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcrossInstancesWithJsonMessageFormat.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcrossInstancesWithJsonMessageFormat.java
new file mode 100644
index 0000000..0ec0275
--- /dev/null
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplAcrossInstancesWithJsonMessageFormat.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.parse;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class TestReplAcrossInstancesWithJsonMessageFormat
+    extends TestReplicationScenariosAcrossInstances {
+
+  @Rule
+  public TestRule replV1BackwardCompat;
+
+  @BeforeClass
+  public static void classLevelSetup() throws Exception {
+    internalBeforeClassSetup(Collections.emptyMap(), TestReplicationScenarios.class);
+  }
+
+  @Before
+  public void setup() throws Throwable {
+    replV1BackwardCompat = primary.getReplivationV1CompatRule(new ArrayList<>());
+    super.setup();
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplIncrementalLoadAcidTablesWithJsonMessage.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplIncrementalLoadAcidTablesWithJsonMessage.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplIncrementalLoadAcidTablesWithJsonMessage.java
new file mode 100644
index 0000000..792ec1c
--- /dev/null
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplIncrementalLoadAcidTablesWithJsonMessage.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.parse;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+
+import java.util.Collections;
+
+public class TestReplIncrementalLoadAcidTablesWithJsonMessage
+    extends TestReplicationScenariosIncrementalLoadAcidTables {
+
+  @Rule
+  public TestRule replV1BackwardCompat;
+
+  @BeforeClass
+  public static void classLevelSetup() throws Exception {
+    internalBeforeClassSetup(Collections.emptyMap(),
+        TestReplIncrementalLoadAcidTablesWithJsonMessage.class);
+  }
+
+  @Before
+  public void setup() throws Throwable {
+    replV1BackwardCompat = primary.getReplivationV1CompatRule(Collections.emptyList());
+    super.setup();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplWithJsonMessageFormat.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplWithJsonMessageFormat.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplWithJsonMessageFormat.java
new file mode 100644
index 0000000..faf1ced
--- /dev/null
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplWithJsonMessageFormat.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.parse;
+
+import org.apache.hive.hcatalog.api.repl.ReplicationV1CompatRule;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class TestReplWithJsonMessageFormat extends TestReplicationScenarios {
+  @Rule
+  public TestRule replV1BackwardCompatibleRule =
+      new ReplicationV1CompatRule(metaStoreClient, hconf,
+          new ArrayList<>(Collections.singletonList("testEventFilters")));
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    internalBeforeClassSetup(Collections.emptyMap());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
index 9c35aa6..75cd68a 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
@@ -18,11 +18,11 @@
 package org.apache.hadoop.hive.ql.parse;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.fs.ContentSummary;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathFilter;
-import org.apache.hadoop.fs.ContentSummary;
 import org.apache.hadoop.hive.cli.CliSessionState;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
@@ -33,7 +33,6 @@ import org.apache.hadoop.hive.metastore.MetaStoreTestUtils;
 import org.apache.hadoop.hive.metastore.ObjectStore;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.ForeignKeysRequest;
-import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.NotNullConstraintsRequest;
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
@@ -47,13 +46,18 @@ import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.UniqueConstraintsRequest;
 import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.messaging.MessageBuilder;
+import org.apache.hadoop.hive.metastore.messaging.MessageEncoder;
 import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.AndFilter;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.DatabaseAndTableFilter;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.EventBoundaryFilter;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.MessageFormatFilter;
 import org.apache.hadoop.hive.ql.DriverContext;
+import org.apache.hadoop.hive.metastore.messaging.json.JSONMessageEncoder;
+import org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder;
 import org.apache.hadoop.hive.ql.DriverFactory;
+import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.IDriver;
 import org.apache.hadoop.hive.ql.exec.DDLTask;
 import org.apache.hadoop.hive.ql.exec.MoveTask;
@@ -62,45 +66,42 @@ import org.apache.hadoop.hive.ql.exec.TaskFactory;
 import org.apache.hadoop.hive.ql.exec.repl.ReplDumpWork;
 import org.apache.hadoop.hive.ql.exec.repl.ReplLoadWork;
 import org.apache.hadoop.hive.ql.metadata.Hive;
-import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.parse.repl.load.EventDumpDirComparator;
 import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
 import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.ql.stats.StatsUtils;
 import org.apache.hadoop.hive.shims.Utils;
 import org.apache.hadoop.security.authorize.ProxyUsers;
-import org.apache.hive.hcatalog.api.repl.ReplicationV1CompatRule;
 import org.apache.thrift.TException;
 import org.junit.After;
 import org.junit.AfterClass;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
-import org.junit.rules.TestRule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.hadoop.hive.ql.ErrorMsg;
 
 import javax.annotation.Nullable;
-
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import static org.apache.hadoop.hive.metastore.ReplChangeManager.SOURCE_OF_REPLICATION;
 import static org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.apache.hadoop.hive.metastore.ReplChangeManager.SOURCE_OF_REPLICATION;
-import org.junit.Assert;
+import static org.junit.Assert.assertTrue;
 
 public class TestReplicationScenarios {
 
@@ -115,18 +116,14 @@ public class TestReplicationScenarios {
   private final static String TEST_PATH =
       System.getProperty("test.warehouse.dir", "/tmp") + Path.SEPARATOR + tid;
 
-  private static HiveConf hconf;
+  static HiveConf hconf;
+  static HiveMetaStoreClient metaStoreClient;
   private static IDriver driver;
-  private static HiveMetaStoreClient metaStoreClient;
   private static String proxySettingName;
-  static HiveConf hconfMirror;
-  static IDriver driverMirror;
-  static HiveMetaStoreClient metaStoreClientMirror;
+  private static HiveConf hconfMirror;
+  private static IDriver driverMirror;
+  private static HiveMetaStoreClient metaStoreClientMirror;
 
-  @Rule
-  public TestRule replV1BackwardCompatibleRule =
-      new ReplicationV1CompatRule(metaStoreClient, hconf,
-          new ArrayList<>(Arrays.asList("testEventFilters")));
   // Make sure we skip backward-compat checking for those tests that don't generate events
 
   protected static final Logger LOG = LoggerFactory.getLogger(TestReplicationScenarios.class);
@@ -141,23 +138,30 @@ public class TestReplicationScenarios {
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
+    HashMap<String, String> overrideProperties = new HashMap<>();
+    overrideProperties.put(MetastoreConf.ConfVars.EVENT_MESSAGE_FACTORY.getHiveName(),
+        GzipJSONMessageEncoder.class.getCanonicalName());
+    internalBeforeClassSetup(overrideProperties);
+  }
+
+  static void internalBeforeClassSetup(Map<String, String> additionalProperties)
+      throws Exception {
     hconf = new HiveConf(TestReplicationScenarios.class);
-    String metastoreUri = System.getProperty("test."+HiveConf.ConfVars.METASTOREURIS.varname);
+    String metastoreUri = System.getProperty("test."+MetastoreConf.ConfVars.THRIFT_URIS.getHiveName());
     if (metastoreUri != null) {
-      hconf.setVar(HiveConf.ConfVars.METASTOREURIS, metastoreUri);
+      hconf.set(MetastoreConf.ConfVars.THRIFT_URIS.getHiveName(), metastoreUri);
       return;
     }
 
-    hconf.setVar(HiveConf.ConfVars.METASTORE_TRANSACTIONAL_EVENT_LISTENERS,
+    hconf.set(MetastoreConf.ConfVars.TRANSACTIONAL_EVENT_LISTENERS.getHiveName(),
         DBNOTIF_LISTENER_CLASSNAME); // turn on db notification listener on metastore
     hconf.setBoolVar(HiveConf.ConfVars.REPLCMENABLED, true);
     hconf.setBoolVar(HiveConf.ConfVars.FIRE_EVENTS_FOR_DML, true);
     hconf.setVar(HiveConf.ConfVars.REPLCMDIR, TEST_PATH + "/cmroot/");
     proxySettingName = "hadoop.proxyuser." + Utils.getUGI().getShortUserName() + ".hosts";
     hconf.set(proxySettingName, "*");
-    MetaStoreTestUtils.startMetaStoreWithRetry(hconf);
     hconf.setVar(HiveConf.ConfVars.REPLDIR,TEST_PATH + "/hrepl/");
-    hconf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
+    hconf.set(MetastoreConf.ConfVars.THRIFT_CONNECTION_RETRIES.getHiveName(), "3");
     hconf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
     hconf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
     hconf.set(HiveConf.ConfVars.HIVE_IN_TEST_REPL.varname, "true");
@@ -166,11 +170,17 @@ public class TestReplicationScenarios {
     hconf.set(HiveConf.ConfVars.HIVE_TXN_MANAGER.varname,
         "org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager");
     hconf.set(HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL.varname,
-              "org.apache.hadoop.hive.metastore.InjectableBehaviourObjectStore");
+        "org.apache.hadoop.hive.metastore.InjectableBehaviourObjectStore");
     hconf.setBoolVar(HiveConf.ConfVars.HIVEOPTIMIZEMETADATAQUERIES, true);
     System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " ");
     System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " ");
 
+    additionalProperties.forEach((key, value) -> {
+      hconf.set(key, value);
+    });
+
+    MetaStoreTestUtils.startMetaStoreWithRetry(hconf);
+
     Path testPath = new Path(TEST_PATH);
     FileSystem fs = FileSystem.get(testPath.toUri(),hconf);
     fs.mkdirs(testPath);
@@ -3077,12 +3087,12 @@ public class TestReplicationScenarios {
     // that match a provided message format
 
     IMetaStoreClient.NotificationFilter restrictByDefaultMessageFormat =
-        new MessageFormatFilter(MessageFactory.getInstance().getMessageFormat());
+        new MessageFormatFilter(JSONMessageEncoder.FORMAT);
     IMetaStoreClient.NotificationFilter restrictByArbitraryMessageFormat =
-        new MessageFormatFilter(MessageFactory.getInstance().getMessageFormat() + "_bogus");
+        new MessageFormatFilter(JSONMessageEncoder.FORMAT + "_bogus");
     NotificationEvent dummyEvent = createDummyEvent(dbname,tblname,0);
 
-    assertEquals(MessageFactory.getInstance().getMessageFormat(),dummyEvent.getMessageFormat());
+    assertEquals(JSONMessageEncoder.FORMAT,dummyEvent.getMessageFormat());
 
     assertFalse(restrictByDefaultMessageFormat.accept(null));
     assertTrue(restrictByDefaultMessageFormat.accept(dummyEvent));
@@ -3431,19 +3441,25 @@ public class TestReplicationScenarios {
   }
 
   private NotificationEvent createDummyEvent(String dbname, String tblname, long evid) {
-    MessageFactory msgFactory = MessageFactory.getInstance();
+    MessageEncoder msgEncoder = null;
+    try {
+      msgEncoder = MessageFactory.getInstance(JSONMessageEncoder.FORMAT);
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
     Table t = new Table();
     t.setDbName(dbname);
     t.setTableName(tblname);
     NotificationEvent event = new NotificationEvent(
         evid,
         (int)System.currentTimeMillis(),
-        MessageFactory.CREATE_TABLE_EVENT,
-        msgFactory.buildCreateTableMessage(t, Arrays.asList("/tmp/").iterator()).toString()
+        MessageBuilder.CREATE_TABLE_EVENT,
+        MessageBuilder.getInstance().buildCreateTableMessage(t, Arrays.asList("/tmp/").iterator())
+            .toString()
     );
     event.setDbName(t.getDbName());
     event.setTableName(t.getTableName());
-    event.setMessageFormat(msgFactory.getMessageFormat());
+    event.setMessageFormat(msgEncoder.getMessageFormat());
     return event;
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
index e043e54..4ceb9fa 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
@@ -17,16 +17,16 @@
  */
 package org.apache.hadoop.hive.ql.parse;
 
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hive.cli.CliSessionState;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsRequest;
-import org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsResponse;
 import org.apache.hadoop.hive.metastore.api.OpenTxnRequest;
 import org.apache.hadoop.hive.metastore.api.OpenTxnsResponse;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder;
 import org.apache.hadoop.hive.metastore.txn.TxnDbUtil;
 import org.apache.hadoop.hive.metastore.txn.TxnStore;
 import org.apache.hadoop.hive.metastore.txn.TxnUtils;
@@ -41,7 +41,6 @@ import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.shims.Utils;
 
 import org.junit.rules.TestName;
-import org.junit.rules.TestRule;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -54,13 +53,11 @@ import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nullable;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Collections;
-import com.google.common.collect.Lists;
-import org.junit.Ignore;
+import java.util.Map;
 
 import static org.junit.Assert.assertTrue;
 import static org.apache.hadoop.hive.metastore.ReplChangeManager.SOURCE_OF_REPLICATION;
@@ -72,12 +69,10 @@ public class TestReplicationScenariosAcidTables {
   @Rule
   public final TestName testName = new TestName();
 
-  @Rule
-  public TestRule replV1BackwardCompat;
-
   protected static final Logger LOG = LoggerFactory.getLogger(TestReplicationScenarios.class);
-  private static WarehouseInstance primary, replica, replicaNonAcid;
-  private static HiveConf conf;
+  static WarehouseInstance primary;
+  private static WarehouseInstance replica, replicaNonAcid;
+  static HiveConf conf;
   private String primaryDbName, replicatedDbName, primaryDbNameExtra;
   private enum OperationType {
     REPL_TEST_ACID_INSERT, REPL_TEST_ACID_INSERT_SELECT, REPL_TEST_ACID_CTAS,
@@ -87,25 +82,38 @@ public class TestReplicationScenariosAcidTables {
 
   @BeforeClass
   public static void classLevelSetup() throws Exception {
-    conf = new HiveConf(TestReplicationScenariosAcidTables.class);
+    HashMap<String, String> overrides = new HashMap<>();
+    overrides.put(MetastoreConf.ConfVars.EVENT_MESSAGE_FACTORY.getHiveName(),
+        GzipJSONMessageEncoder.class.getCanonicalName());
+
+    internalBeforeClassSetup(overrides, TestReplicationScenariosAcidTables.class);
+  }
+
+  static void internalBeforeClassSetup(Map<String, String> overrides,
+      Class clazz) throws Exception {
+
+    conf = new HiveConf(clazz);
     conf.set("dfs.client.use.datanode.hostname", "true");
     conf.set("hadoop.proxyuser." + Utils.getUGI().getShortUserName() + ".hosts", "*");
     MiniDFSCluster miniDFSCluster =
-           new MiniDFSCluster.Builder(conf).numDataNodes(1).format(true).build();
-    HashMap<String, String> overridesForHiveConf = new HashMap<String, String>() {{
-        put("fs.defaultFS", miniDFSCluster.getFileSystem().getUri().toString());
-        put("hive.support.concurrency", "true");
-        put("hive.txn.manager", "org.apache.hadoop.hive.ql.lockmgr.DbTxnManager");
-        put("hive.metastore.client.capability.check", "false");
-        put("hive.repl.bootstrap.dump.open.txn.timeout", "1s");
-        put("hive.exec.dynamic.partition.mode", "nonstrict");
-        put("hive.strict.checks.bucketing", "false");
-        put("hive.mapred.mode", "nonstrict");
-        put("mapred.input.dir.recursive", "true");
-        put("hive.metastore.disallow.incompatible.col.type.changes", "false");
+        new MiniDFSCluster.Builder(conf).numDataNodes(1).format(true).build();
+    HashMap<String, String> acidEnableConf = new HashMap<String, String>() {{
+      put("fs.defaultFS", miniDFSCluster.getFileSystem().getUri().toString());
+      put("hive.support.concurrency", "true");
+      put("hive.txn.manager", "org.apache.hadoop.hive.ql.lockmgr.DbTxnManager");
+      put("hive.metastore.client.capability.check", "false");
+      put("hive.repl.bootstrap.dump.open.txn.timeout", "1s");
+      put("hive.exec.dynamic.partition.mode", "nonstrict");
+      put("hive.strict.checks.bucketing", "false");
+      put("hive.mapred.mode", "nonstrict");
+      put("mapred.input.dir.recursive", "true");
+      put("hive.metastore.disallow.incompatible.col.type.changes", "false");
     }};
-    primary = new WarehouseInstance(LOG, miniDFSCluster, overridesForHiveConf);
-    replica = new WarehouseInstance(LOG, miniDFSCluster, overridesForHiveConf);
+
+    acidEnableConf.putAll(overrides);
+
+    primary = new WarehouseInstance(LOG, miniDFSCluster, acidEnableConf);
+    replica = new WarehouseInstance(LOG, miniDFSCluster, acidEnableConf);
     HashMap<String, String> overridesForHiveConf1 = new HashMap<String, String>() {{
         put("fs.defaultFS", miniDFSCluster.getFileSystem().getUri().toString());
         put("hive.support.concurrency", "false");
@@ -123,7 +131,6 @@ public class TestReplicationScenariosAcidTables {
 
   @Before
   public void setup() throws Throwable {
-    replV1BackwardCompat = primary.getReplivationV1CompatRule(new ArrayList<>());
     primaryDbName = testName.getMethodName() + "_" + +System.currentTimeMillis();
     replicatedDbName = "replicated_" + primaryDbName;
     primary.run("create database " + primaryDbName + " WITH DBPROPERTIES ( '" +

http://git-wip-us.apache.org/repos/asf/hive/blob/b4302bb7/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
index 61473a8..7e8caf0 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
@@ -19,12 +19,13 @@ package org.apache.hadoop.hive.ql.parse;
 
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder;
 import org.apache.hadoop.hive.ql.exec.repl.util.ReplUtils;
 import org.apache.hadoop.hive.ql.parse.repl.PathBuilder;
 import org.apache.hadoop.hive.ql.util.DependencyResolver;
@@ -43,7 +44,6 @@ import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
-import org.junit.rules.TestRule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.hive.ql.exec.repl.incremental.IncrementalLoadTasksBuilder;
@@ -53,7 +53,6 @@ import java.io.IOException;
 import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -72,33 +71,40 @@ import static org.junit.Assert.assertTrue;
 import static org.apache.hadoop.hive.metastore.ReplChangeManager.SOURCE_OF_REPLICATION;
 import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
 import org.apache.hadoop.hive.ql.ErrorMsg;
-import org.junit.Assert;
 
 public class TestReplicationScenariosAcrossInstances {
   @Rule
   public final TestName testName = new TestName();
 
-  @Rule
-  public TestRule replV1BackwardCompat;
-
   protected static final Logger LOG = LoggerFactory.getLogger(TestReplicationScenarios.class);
-  private static WarehouseInstance primary, replica;
+  static WarehouseInstance primary;
+  private static WarehouseInstance replica;
   private String primaryDbName, replicatedDbName;
   private static HiveConf conf;
 
   @BeforeClass
   public static void classLevelSetup() throws Exception {
-    conf = new HiveConf(TestReplicationScenarios.class);
+    HashMap<String, String> overrides = new HashMap<>();
+    overrides.put(MetastoreConf.ConfVars.EVENT_MESSAGE_FACTORY.getHiveName(),
+        GzipJSONMessageEncoder.class.getCanonicalName());
+
+    internalBeforeClassSetup(overrides, TestReplicationScenarios.class);
+  }
+
+  static void internalBeforeClassSetup(Map<String, String> overrides, Class clazz)
+      throws Exception {
+    conf = new HiveConf(clazz);
     conf.set("dfs.client.use.datanode.hostname", "true");
     conf.set("hadoop.proxyuser." + Utils.getUGI().getShortUserName() + ".hosts", "*");
     MiniDFSCluster miniDFSCluster =
         new MiniDFSCluster.Builder(conf).numDataNodes(1).format(true).build();
-    HashMap<String, String> overridesForHiveConf = new HashMap<String, String>() {{
+    Map<String, String> localOverrides = new HashMap<String, String>() {{
       put("fs.defaultFS", miniDFSCluster.getFileSystem().getUri().toString());
       put(HiveConf.ConfVars.HIVE_IN_TEST_REPL.varname, "true");
     }};
-    primary = new WarehouseInstance(LOG, miniDFSCluster, overridesForHiveConf);
-    replica = new WarehouseInstance(LOG, miniDFSCluster, overridesForHiveConf);
+    localOverrides.putAll(overrides);
+    primary = new WarehouseInstance(LOG, miniDFSCluster, localOverrides);
+    replica = new WarehouseInstance(LOG, miniDFSCluster, localOverrides);
   }
 
   @AfterClass
@@ -109,7 +115,6 @@ public class TestReplicationScenariosAcrossInstances {
 
   @Before
   public void setup() throws Throwable {
-    replV1BackwardCompat = primary.getReplivationV1CompatRule(new ArrayList<>());
     primaryDbName = testName.getMethodName() + "_" + +System.currentTimeMillis();
     replicatedDbName = "replicated_" + primaryDbName;
     primary.run("create database " + primaryDbName + " WITH DBPROPERTIES ( '" +
@@ -323,7 +328,8 @@ public class TestReplicationScenariosAcrossInstances {
             "clustered by(key) into 2 buckets stored as orc tblproperties ('transactional'='true')")
         .run("create table table1 (i int, j int)")
         .run("insert into table1 values (1,2)")
-        .dump(primaryDbName, null, Arrays.asList("'hive.repl.dump.metadata.only'='true'"));
+        .dump(primaryDbName, null,
+            Collections.singletonList("'hive.repl.dump.metadata.only'='true'"));
 
     replica.load(replicatedDbName, tuple.dumpLocation)
         .run("use " + replicatedDbName)
@@ -419,7 +425,7 @@ public class TestReplicationScenariosAcrossInstances {
             .run("create table table2 (a int, city string) partitioned by (country string)")
             .run("create table table3 (i int, j int)")
             .run("insert into table1 values (1,2)")
-            .dump(dbName, null, Arrays.asList("'hive.repl.dump.metadata.only'='true'"));
+        .dump(dbName, null, Collections.singletonList("'hive.repl.dump.metadata.only'='true'"));
 
     replica.load(replicatedDbName, tuple.dumpLocation)
             .run("use " + replicatedDbName)
@@ -433,7 +439,8 @@ public class TestReplicationScenariosAcrossInstances {
             .run("alter table table1 rename to renamed_table1")
             .run("insert into table2 partition(country='india') values (1,'mumbai') ")
             .run("create table table4 (i int, j int)")
-            .dump(dbName, tuple.lastReplicationId, Arrays.asList("'hive.repl.dump.metadata.only'='true'"));
+        .dump(dbName, tuple.lastReplicationId,
+            Collections.singletonList("'hive.repl.dump.metadata.only'='true'"));
 
     replica.load(replicatedDbName, tuple.dumpLocation)
             .run("use " + replicatedDbName)
@@ -467,7 +474,7 @@ public class TestReplicationScenariosAcrossInstances {
                 SOURCE_OF_REPLICATION + "' = '1,2,3')")
         .run("use " + dbTwo)
         .run("create table t1 (i int, j int)")
-        .dump("`*`", null, Arrays.asList("'hive.repl.dump.metadata.only'='true'"));
+        .dump("`*`", null, Collections.singletonList("'hive.repl.dump.metadata.only'='true'"));
 
     /*
       Due to the limitation that we can only have one instance of Persistence Manager Factory in a JVM
@@ -526,7 +533,7 @@ public class TestReplicationScenariosAcrossInstances {
         .run("use " + dbOne)
         .run("create table t1 (i int, j int) partitioned by (load_date date) "
             + "clustered by(i) into 2 buckets stored as orc tblproperties ('transactional'='true') ")
-        .dump("`*`", null, Arrays.asList("'hive.repl.dump.metadata.only'='true'"));
+        .dump("`*`", null, Collections.singletonList("'hive.repl.dump.metadata.only'='true'"));
 
     String dbTwo = primaryDbName + randomTwo;
     WarehouseInstance.Tuple incrementalTuple = primary
@@ -905,15 +912,20 @@ public class TestReplicationScenariosAcrossInstances {
 
     // Incremental load to non existing db should return database not exist error.
     tuple = primary.dump("someJunkDB", tuple.lastReplicationId);
-    CommandProcessorResponse response = replica.runCommand("REPL LOAD someJunkDB from " + tuple.dumpLocation);
-    response.getErrorMessage().toLowerCase().contains("org.apache.hadoop.hive.ql.metadata.hiveException: " +
-            "database does not exist");
+    CommandProcessorResponse response =
+        replica.runCommand("REPL LOAD someJunkDB from '" + tuple.dumpLocation + "'");
+    assertTrue(response.getErrorMessage().toLowerCase()
+        .contains("org.apache.hadoop.hive.ql.exec.DDLTask. Database does not exist: someJunkDB"
+            .toLowerCase()));
 
     // Bootstrap load from an empty dump directory should return empty load directory error.
     tuple = primary.dump("someJunkDB", null);
-    response = replica.runCommand("REPL LOAD someJunkDB from " + tuple.dumpLocation);
-    response.getErrorMessage().toLowerCase().contains("org.apache.hadoop.hive.ql.parse.semanticException:" +
-            " no data to load in path");
+    response = replica.runCommand("REPL LOAD someJunkDB from '" + tuple.dumpLocation+"'");
+    assertTrue(response.getErrorMessage().toLowerCase()
+        .contains(
+            "semanticException no data to load in path"
+                .toLowerCase())
+    );
 
     primary.run(" drop database if exists " + testDbName + " cascade");
   }
@@ -935,7 +947,8 @@ public class TestReplicationScenariosAcrossInstances {
             .run("insert into table3 partition(country='india') values(3)")
             .dump(primaryDbName, bootstrapTuple.lastReplicationId);
 
-    replica.load(replicatedDbName, incremental.dumpLocation, Arrays.asList("'hive.repl.approx.max.load.tasks'='10'"))
+    replica.load(replicatedDbName, incremental.dumpLocation,
+        Collections.singletonList("'hive.repl.approx.max.load.tasks'='10'"))
             .status(replicatedDbName)
             .verifyResult(incremental.lastReplicationId)
             .run("use " + replicatedDbName)
@@ -959,7 +972,8 @@ public class TestReplicationScenariosAcrossInstances {
     FileStatus[] fileStatus = fs.listStatus(path);
     int numEvents = fileStatus.length - 1; //one is metadata file
 
-    replica.load(replicatedDbName, incremental.dumpLocation, Arrays.asList("'hive.repl.approx.max.load.tasks'='1'"))
+    replica.load(replicatedDbName, incremental.dumpLocation,
+        Collections.singletonList("'hive.repl.approx.max.load.tasks'='1'"))
             .run("use " + replicatedDbName)
             .run("show tables")
             .verifyResults(new String[] {"table1", "table2", "table3", "table4", "table5" })
@@ -1112,7 +1126,7 @@ public class TestReplicationScenariosAcrossInstances {
             .run("show tables")
             .verifyResults(new String[] { "t1", "t2" })
             .run("select id from t1")
-            .verifyResults(Arrays.asList("10"))
+        .verifyResults(Collections.singletonList("10"))
             .run("select country from t2 order by country")
             .verifyResults(Arrays.asList("india", "uk", "us"));
     verifyIfCkptSet(replica, replicatedDbName, tuple.dumpLocation);
@@ -1154,9 +1168,8 @@ public class TestReplicationScenariosAcrossInstances {
     // also not loaded.
     BehaviourInjection<CallerArguments, Boolean> callerVerifier
             = new BehaviourInjection<CallerArguments, Boolean>() {
-      @Nullable
       @Override
-      public Boolean apply(@Nullable CallerArguments args) {
+      public Boolean apply(CallerArguments args) {
         injectionPathCalled = true;
         if (!args.dbName.equalsIgnoreCase(replicatedDbName) || (args.constraintTblName != null)) {
           LOG.warn("Verifier - DB: " + String.valueOf(args.dbName)
@@ -1197,9 +1210,8 @@ public class TestReplicationScenariosAcrossInstances {
     // Verify if create table is not called on table t1 but called for t2 and t3.
     // Also, allow constraint creation only on t1 and t3. Foreign key creation on t2 fails.
     callerVerifier = new BehaviourInjection<CallerArguments, Boolean>() {
-      @Nullable
       @Override
-      public Boolean apply(@Nullable CallerArguments args) {
+      public Boolean apply(CallerArguments args) {
         injectionPathCalled = true;
         if (!args.dbName.equalsIgnoreCase(replicatedDbName) || (args.funcName != null)) {
           LOG.warn("Verifier - DB: " + String.valueOf(args.dbName) + " Func: " + String.valueOf(args.funcName));
@@ -1235,9 +1247,8 @@ public class TestReplicationScenariosAcrossInstances {
 
     // Verify if no create table/function calls. Only add foreign key constraints on table t2.
     callerVerifier = new BehaviourInjection<CallerArguments, Boolean>() {
-      @Nullable
       @Override
-      public Boolean apply(@Nullable CallerArguments args) {
+      public Boolean apply(CallerArguments args) {
         injectionPathCalled = true;
         if (!args.dbName.equalsIgnoreCase(replicatedDbName) || (args.tblName != null)) {
           LOG.warn("Verifier - DB: " + String.valueOf(args.dbName)
@@ -1307,7 +1318,7 @@ public class TestReplicationScenariosAcrossInstances {
     };
     InjectableBehaviourObjectStore.setGetPartitionBehaviour(getPartitionStub);
 
-    List<String> withConfigs = Arrays.asList("'hive.repl.approx.max.load.tasks'='1'");
+    List<String> withConfigs = Collections.singletonList("'hive.repl.approx.max.load.tasks'='1'");
     replica.loadFailure(replicatedDbName, tuple.dumpLocation, withConfigs);
     InjectableBehaviourObjectStore.resetGetPartitionBehaviour(); // reset the behaviour
     getPartitionStub.assertInjectionsPerformed(true, false);
@@ -1318,7 +1329,7 @@ public class TestReplicationScenariosAcrossInstances {
             .run("show tables")
             .verifyResults(new String[] {"t2" })
             .run("select country from t2 order by country")
-            .verifyResults(Arrays.asList("india"))
+        .verifyResults(Collections.singletonList("india"))
             .run("show functions like '" + replicatedDbName + "*'")
             .verifyResult(replicatedDbName + ".testFunctionOne");
 
@@ -1378,7 +1389,8 @@ public class TestReplicationScenariosAcrossInstances {
 
   @Test
   public void testMoveOptimizationIncrementalFailureAfterCopyReplace() throws Throwable {
-    List<String> withConfigs = Arrays.asList("'hive.repl.enable.move.optimization'='true'");
+    List<String> withConfigs =
+        Collections.singletonList("'hive.repl.enable.move.optimization'='true'");
     String replicatedDbName_CM = replicatedDbName + "_CM";
     WarehouseInstance.Tuple tuple = primary.run("use " + primaryDbName)
             .run("create table t2 (place string) partitioned by (country string)")
@@ -1399,7 +1411,8 @@ public class TestReplicationScenariosAcrossInstances {
 
   @Test
   public void testMoveOptimizationIncrementalFailureAfterCopy() throws Throwable {
-    List<String> withConfigs = Arrays.asList("'hive.repl.enable.move.optimization'='true'");
+    List<String> withConfigs =
+        Collections.singletonList("'hive.repl.enable.move.optimization'='true'");
     String replicatedDbName_CM = replicatedDbName + "_CM";
     WarehouseInstance.Tuple tuple = primary.run("use " + primaryDbName)
             .run("create table t2 (place string) partitioned by (country string)")
@@ -1417,16 +1430,16 @@ public class TestReplicationScenariosAcrossInstances {
     testMoveOptimization(primaryDbName, replicatedDbName, replicatedDbName_CM, "t2", "INSERT", tuple);
   }
 
-  private void testMoveOptimization(String primarydb, String replicadb, String replicatedDbName_CM,
+  private void testMoveOptimization(String primaryDb, String replicaDb, String replicatedDbName_CM,
                                     String tbl,  String eventType, WarehouseInstance.Tuple tuple) throws Throwable {
-    List<String> withConfigs = Arrays.asList("'hive.repl.enable.move.optimization'='true'");
+    List<String> withConfigs =
+        Collections.singletonList("'hive.repl.enable.move.optimization'='true'");
 
     // fail add notification for given event type.
     BehaviourInjection<NotificationEvent, Boolean> callerVerifier
             = new BehaviourInjection<NotificationEvent, Boolean>() {
-      @Nullable
       @Override
-      public Boolean apply(@Nullable NotificationEvent entry) {
+      public Boolean apply(NotificationEvent entry) {
         if (entry.getEventType().equalsIgnoreCase(eventType) && entry.getTableName().equalsIgnoreCase(tbl)) {
           injectionPathCalled = true;
           LOG.warn("Verifier - DB: " + String.valueOf(entry.getDbName())
@@ -1440,19 +1453,19 @@ public class TestReplicationScenariosAcrossInstances {
 
     InjectableBehaviourObjectStore.setAddNotificationModifier(callerVerifier);
     try {
-      replica.loadFailure(replicadb, tuple.dumpLocation, withConfigs);
+      replica.loadFailure(replicaDb, tuple.dumpLocation, withConfigs);
     } finally {
       InjectableBehaviourObjectStore.resetAddNotificationModifier();
     }
 
     callerVerifier.assertInjectionsPerformed(true, false);
-    replica.load(replicadb, tuple.dumpLocation, withConfigs);
+    replica.load(replicaDb, tuple.dumpLocation, withConfigs);
 
-    replica.run("use " + replicadb)
+    replica.run("use " + replicaDb)
             .run("select country from " + tbl + " where country == 'india'")
             .verifyResults(Arrays.asList("india"));
 
-    primary.run("use " + primarydb)
+    primary.run("use " + primaryDb)
             .run("drop table " + tbl);
 
     InjectableBehaviourObjectStore.setAddNotificationModifier(callerVerifier);


[03/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query87.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query87.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query87.q.out
new file mode 100644
index 0000000..b6d3904
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query87.q.out
@@ -0,0 +1,288 @@
+PREHOOK: query: explain
+select count(*) 
+from ((select distinct c_last_name, c_first_name, d_date
+       from store_sales, date_dim, customer
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from catalog_sales, date_dim, customer
+       where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+         and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from web_sales, date_dim, customer
+       where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+         and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+) cool_cust
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select count(*) 
+from ((select distinct c_last_name, c_first_name, d_date
+       from store_sales, date_dim, customer
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from catalog_sales, date_dim, customer
+       where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+         and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+       except
+      (select distinct c_last_name, c_first_name, d_date
+       from web_sales, date_dim, customer
+       where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+         and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+         and d_month_seq between 1212 and 1212+11)
+) cool_cust
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE)
+Map 21 <- Reducer 15 (BROADCAST_EDGE)
+Map 22 <- Reducer 19 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 10 (SIMPLE_EDGE), Map 21 (SIMPLE_EDGE)
+Reducer 13 <- Map 20 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 15 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Map 10 (SIMPLE_EDGE), Map 22 (SIMPLE_EDGE)
+Reducer 17 <- Map 20 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 19 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 3 <- Map 20 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 8 <- Union 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 9 vectorized
+      File Output Operator [FS_268]
+        Group By Operator [GBY_267] (rows=1 width=8)
+          Output:["_col0"],aggregations:["count(VALUE._col0)"]
+        <-Reducer 8 [CUSTOM_SIMPLE_EDGE] vectorized
+          PARTITION_ONLY_SHUFFLE [RS_266]
+            Group By Operator [GBY_265] (rows=1 width=8)
+              Output:["_col0"],aggregations:["count()"]
+              Select Operator [SEL_264] (rows=8062883 width=16)
+                Filter Operator [FIL_263] (rows=8062883 width=16)
+                  predicate:(((_col3 * 2) = _col4) and (_col3 > 0L))
+                  Select Operator [SEL_262] (rows=48377300 width=16)
+                    Output:["_col3","_col4"]
+                    Group By Operator [GBY_261] (rows=48377300 width=290)
+                      Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2
+                    <-Union 7 [SIMPLE_EDGE]
+                      <-Reducer 18 [CONTAINS] vectorized
+                        Reduce Output Operator [RS_292]
+                          PartitionCols:_col0, _col1, _col2
+                          Group By Operator [GBY_291] (rows=48377300 width=290)
+                            Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col3)","sum(_col4)"],keys:_col0, _col1, _col2
+                            Select Operator [SEL_290] (rows=48377300 width=290)
+                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                              Select Operator [SEL_289] (rows=24986582 width=290)
+                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                Group By Operator [GBY_288] (rows=24986582 width=282)
+                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                  Select Operator [SEL_287] (rows=24986582 width=274)
+                                    Output:["_col0","_col1","_col2"]
+                                    Group By Operator [GBY_286] (rows=24986582 width=274)
+                                      Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+                                    <-Reducer 17 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_77]
+                                        PartitionCols:_col0, _col1, _col2
+                                        Group By Operator [GBY_76] (rows=24986582 width=274)
+                                          Output:["_col0","_col1","_col2"],keys:_col6, _col5, _col3
+                                          Merge Join Operator [MERGEJOIN_189] (rows=24986582 width=274)
+                                            Conds:RS_72._col1=RS_245._col0(Inner),Output:["_col3","_col5","_col6"]
+                                          <-Map 20 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_245]
+                                              PartitionCols:_col0
+                                              Select Operator [SEL_242] (rows=80000000 width=184)
+                                                Output:["_col0","_col1","_col2"]
+                                                TableScan [TS_6] (rows=80000000 width=184)
+                                                  default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_first_name","c_last_name"]
+                                          <-Reducer 16 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_72]
+                                              PartitionCols:_col1
+                                              Merge Join Operator [MERGEJOIN_188] (rows=24986582 width=97)
+                                                Conds:RS_285._col0=RS_229._col0(Inner),Output:["_col1","_col3"]
+                                              <-Map 10 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_229]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_224] (rows=317 width=98)
+                                                    Output:["_col0","_col1"]
+                                                    Filter Operator [FIL_223] (rows=317 width=102)
+                                                      predicate:d_month_seq BETWEEN 1212 AND 1223
+                                                      TableScan [TS_3] (rows=73049 width=102)
+                                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date","d_month_seq"]
+                                              <-Map 22 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_285]
+                                                  PartitionCols:_col0
+                                                  Select Operator [SEL_284] (rows=143930993 width=7)
+                                                    Output:["_col0","_col1"]
+                                                    Filter Operator [FIL_283] (rows=143930993 width=7)
+                                                      predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_70_date_dim_d_date_sk_min) AND DynamicValue(RS_70_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_70_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                      TableScan [TS_61] (rows=144002668 width=7)
+                                                        default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk"]
+                                                      <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                        BROADCAST [RS_282]
+                                                          Group By Operator [GBY_281] (rows=1 width=12)
+                                                            Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                          <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_236]
+                                                              Group By Operator [GBY_233] (rows=1 width=12)
+                                                                Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                Select Operator [SEL_230] (rows=317 width=4)
+                                                                  Output:["_col0"]
+                                                                   Please refer to the previous Select Operator [SEL_224]
+                      <-Reducer 6 [CONTAINS] vectorized
+                        Reduce Output Operator [RS_260]
+                          PartitionCols:_col0, _col1, _col2
+                          Group By Operator [GBY_259] (rows=48377300 width=290)
+                            Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col3)","sum(_col4)"],keys:_col0, _col1, _col2
+                            Select Operator [SEL_258] (rows=48377300 width=290)
+                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                              Select Operator [SEL_257] (rows=23390718 width=290)
+                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                Group By Operator [GBY_256] (rows=23390718 width=282)
+                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col0, _col1, _col2
+                                  Select Operator [SEL_255] (rows=23390718 width=290)
+                                    Output:["_col0","_col1","_col2"]
+                                    Filter Operator [FIL_254] (rows=23390718 width=290)
+                                      predicate:(((_col3 * 2) = _col4) and (_col3 > 0L))
+                                      Group By Operator [GBY_253] (rows=140344308 width=290)
+                                        Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)"],keys:KEY._col0, KEY._col1, KEY._col2
+                                      <-Union 5 [SIMPLE_EDGE]
+                                        <-Reducer 14 [CONTAINS] vectorized
+                                          Reduce Output Operator [RS_280]
+                                            PartitionCols:_col0, _col1, _col2
+                                            Group By Operator [GBY_279] (rows=140344308 width=290)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col3)","sum(_col4)"],keys:_col0, _col1, _col2
+                                              Select Operator [SEL_278] (rows=140344308 width=290)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Select Operator [SEL_277] (rows=49146883 width=290)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                  Group By Operator [GBY_276] (rows=49146883 width=282)
+                                                    Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                                    Select Operator [SEL_275] (rows=49146883 width=274)
+                                                      Output:["_col0","_col1","_col2"]
+                                                      Group By Operator [GBY_274] (rows=49146883 width=274)
+                                                        Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                      <-Reducer 13 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_40]
+                                                          PartitionCols:_col0, _col1, _col2
+                                                          Group By Operator [GBY_39] (rows=49146883 width=274)
+                                                            Output:["_col0","_col1","_col2"],keys:_col6, _col5, _col3
+                                                            Merge Join Operator [MERGEJOIN_187] (rows=49146883 width=274)
+                                                              Conds:RS_35._col1=RS_244._col0(Inner),Output:["_col3","_col5","_col6"]
+                                                            <-Map 20 [SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_244]
+                                                                PartitionCols:_col0
+                                                                 Please refer to the previous Select Operator [SEL_242]
+                                                            <-Reducer 12 [SIMPLE_EDGE]
+                                                              SHUFFLE [RS_35]
+                                                                PartitionCols:_col1
+                                                                Merge Join Operator [MERGEJOIN_186] (rows=49146883 width=97)
+                                                                  Conds:RS_273._col0=RS_227._col0(Inner),Output:["_col1","_col3"]
+                                                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_227]
+                                                                    PartitionCols:_col0
+                                                                     Please refer to the previous Select Operator [SEL_224]
+                                                                <-Map 21 [SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_273]
+                                                                    PartitionCols:_col0
+                                                                    Select Operator [SEL_272] (rows=285117831 width=7)
+                                                                      Output:["_col0","_col1"]
+                                                                      Filter Operator [FIL_271] (rows=285117831 width=7)
+                                                                        predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_33_date_dim_d_date_sk_min) AND DynamicValue(RS_33_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_33_date_dim_d_date_sk_bloom_filter))) and cs_bill_customer_sk is not null and cs_sold_date_sk is not null)
+                                                                        TableScan [TS_24] (rows=287989836 width=7)
+                                                                          default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_customer_sk"]
+                                                                        <-Reducer 15 [BROADCAST_EDGE] vectorized
+                                                                          BROADCAST [RS_270]
+                                                                            Group By Operator [GBY_269] (rows=1 width=12)
+                                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                            <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                              SHUFFLE [RS_235]
+                                                                                Group By Operator [GBY_232] (rows=1 width=12)
+                                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                  Select Operator [SEL_228] (rows=317 width=4)
+                                                                                    Output:["_col0"]
+                                                                                     Please refer to the previous Select Operator [SEL_224]
+                                        <-Reducer 4 [CONTAINS] vectorized
+                                          Reduce Output Operator [RS_252]
+                                            PartitionCols:_col0, _col1, _col2
+                                            Group By Operator [GBY_251] (rows=140344308 width=290)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col3)","sum(_col4)"],keys:_col0, _col1, _col2
+                                              Select Operator [SEL_250] (rows=140344308 width=290)
+                                                Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                Select Operator [SEL_249] (rows=91197425 width=290)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                  Group By Operator [GBY_248] (rows=91197425 width=282)
+                                                    Output:["_col0","_col1","_col2","_col3"],aggregations:["count()"],keys:_col1, _col0, _col2
+                                                    Select Operator [SEL_247] (rows=91197425 width=274)
+                                                      Output:["_col0","_col1","_col2"]
+                                                      Group By Operator [GBY_246] (rows=91197425 width=274)
+                                                        Output:["_col0","_col1","_col2"],keys:KEY._col0, KEY._col1, KEY._col2
+                                                      <-Reducer 3 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_16]
+                                                          PartitionCols:_col0, _col1, _col2
+                                                          Group By Operator [GBY_15] (rows=91197425 width=274)
+                                                            Output:["_col0","_col1","_col2"],keys:_col6, _col5, _col3
+                                                            Merge Join Operator [MERGEJOIN_185] (rows=91197425 width=274)
+                                                              Conds:RS_11._col1=RS_243._col0(Inner),Output:["_col3","_col5","_col6"]
+                                                            <-Map 20 [SIMPLE_EDGE] vectorized
+                                                              SHUFFLE [RS_243]
+                                                                PartitionCols:_col0
+                                                                 Please refer to the previous Select Operator [SEL_242]
+                                                            <-Reducer 2 [SIMPLE_EDGE]
+                                                              SHUFFLE [RS_11]
+                                                                PartitionCols:_col1
+                                                                Merge Join Operator [MERGEJOIN_184] (rows=91197425 width=96)
+                                                                  Conds:RS_241._col0=RS_225._col0(Inner),Output:["_col1","_col3"]
+                                                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_225]
+                                                                    PartitionCols:_col0
+                                                                     Please refer to the previous Select Operator [SEL_224]
+                                                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_241]
+                                                                    PartitionCols:_col0
+                                                                    Select Operator [SEL_240] (rows=525327388 width=7)
+                                                                      Output:["_col0","_col1"]
+                                                                      Filter Operator [FIL_239] (rows=525327388 width=7)
+                                                                        predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_9_date_dim_d_date_sk_min) AND DynamicValue(RS_9_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_9_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                                        TableScan [TS_0] (rows=575995635 width=7)
+                                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk"]
+                                                                        <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                                          BROADCAST [RS_238]
+                                                                            Group By Operator [GBY_237] (rows=1 width=12)
+                                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                            <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                              SHUFFLE [RS_234]
+                                                                                Group By Operator [GBY_231] (rows=1 width=12)
+                                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                  Select Operator [SEL_226] (rows=317 width=4)
+                                                                                    Output:["_col0"]
+                                                                                     Please refer to the previous Select Operator [SEL_224]
+


[05/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query8.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query8.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query8.q.out
new file mode 100644
index 0000000..93bce2e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query8.q.out
@@ -0,0 +1,397 @@
+PREHOOK: query: explain
+select  s_store_name
+      ,sum(ss_net_profit)
+ from store_sales
+     ,date_dim
+     ,store,
+     (select ca_zip
+     from (
+     (SELECT substr(ca_zip,1,5) ca_zip
+      FROM customer_address
+      WHERE substr(ca_zip,1,5) IN (
+                          '89436','30868','65085','22977','83927','77557',
+                          '58429','40697','80614','10502','32779',
+                          '91137','61265','98294','17921','18427',
+                          '21203','59362','87291','84093','21505',
+                          '17184','10866','67898','25797','28055',
+                          '18377','80332','74535','21757','29742',
+                          '90885','29898','17819','40811','25990',
+                          '47513','89531','91068','10391','18846',
+                          '99223','82637','41368','83658','86199',
+                          '81625','26696','89338','88425','32200',
+                          '81427','19053','77471','36610','99823',
+                          '43276','41249','48584','83550','82276',
+                          '18842','78890','14090','38123','40936',
+                          '34425','19850','43286','80072','79188',
+                          '54191','11395','50497','84861','90733',
+                          '21068','57666','37119','25004','57835',
+                          '70067','62878','95806','19303','18840',
+                          '19124','29785','16737','16022','49613',
+                          '89977','68310','60069','98360','48649',
+                          '39050','41793','25002','27413','39736',
+                          '47208','16515','94808','57648','15009',
+                          '80015','42961','63982','21744','71853',
+                          '81087','67468','34175','64008','20261',
+                          '11201','51799','48043','45645','61163',
+                          '48375','36447','57042','21218','41100',
+                          '89951','22745','35851','83326','61125',
+                          '78298','80752','49858','52940','96976',
+                          '63792','11376','53582','18717','90226',
+                          '50530','94203','99447','27670','96577',
+                          '57856','56372','16165','23427','54561',
+                          '28806','44439','22926','30123','61451',
+                          '92397','56979','92309','70873','13355',
+                          '21801','46346','37562','56458','28286',
+                          '47306','99555','69399','26234','47546',
+                          '49661','88601','35943','39936','25632',
+                          '24611','44166','56648','30379','59785',
+                          '11110','14329','93815','52226','71381',
+                          '13842','25612','63294','14664','21077',
+                          '82626','18799','60915','81020','56447',
+                          '76619','11433','13414','42548','92713',
+                          '70467','30884','47484','16072','38936',
+                          '13036','88376','45539','35901','19506',
+                          '65690','73957','71850','49231','14276',
+                          '20005','18384','76615','11635','38177',
+                          '55607','41369','95447','58581','58149',
+                          '91946','33790','76232','75692','95464',
+                          '22246','51061','56692','53121','77209',
+                          '15482','10688','14868','45907','73520',
+                          '72666','25734','17959','24677','66446',
+                          '94627','53535','15560','41967','69297',
+                          '11929','59403','33283','52232','57350',
+                          '43933','40921','36635','10827','71286',
+                          '19736','80619','25251','95042','15526',
+                          '36496','55854','49124','81980','35375',
+                          '49157','63512','28944','14946','36503',
+                          '54010','18767','23969','43905','66979',
+                          '33113','21286','58471','59080','13395',
+                          '79144','70373','67031','38360','26705',
+                          '50906','52406','26066','73146','15884',
+                          '31897','30045','61068','45550','92454',
+                          '13376','14354','19770','22928','97790',
+                          '50723','46081','30202','14410','20223',
+                          '88500','67298','13261','14172','81410',
+                          '93578','83583','46047','94167','82564',
+                          '21156','15799','86709','37931','74703',
+                          '83103','23054','70470','72008','49247',
+                          '91911','69998','20961','70070','63197',
+                          '54853','88191','91830','49521','19454',
+                          '81450','89091','62378','25683','61869',
+                          '51744','36580','85778','36871','48121',
+                          '28810','83712','45486','67393','26935',
+                          '42393','20132','55349','86057','21309',
+                          '80218','10094','11357','48819','39734',
+                          '40758','30432','21204','29467','30214',
+                          '61024','55307','74621','11622','68908',
+                          '33032','52868','99194','99900','84936',
+                          '69036','99149','45013','32895','59004',
+                          '32322','14933','32936','33562','72550',
+                          '27385','58049','58200','16808','21360',
+                          '32961','18586','79307','15492'))
+     intersect
+     (select ca_zip
+      from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
+            FROM customer_address, customer
+            WHERE ca_address_sk = c_current_addr_sk and
+                  c_preferred_cust_flag='Y'
+            group by ca_zip
+            having count(*) > 10)A1))A2) V1
+ where ss_store_sk = s_store_sk
+  and ss_sold_date_sk = d_date_sk
+  and d_qoy = 1 and d_year = 2002
+  and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
+ group by s_store_name
+ order by s_store_name
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  s_store_name
+      ,sum(ss_net_profit)
+ from store_sales
+     ,date_dim
+     ,store,
+     (select ca_zip
+     from (
+     (SELECT substr(ca_zip,1,5) ca_zip
+      FROM customer_address
+      WHERE substr(ca_zip,1,5) IN (
+                          '89436','30868','65085','22977','83927','77557',
+                          '58429','40697','80614','10502','32779',
+                          '91137','61265','98294','17921','18427',
+                          '21203','59362','87291','84093','21505',
+                          '17184','10866','67898','25797','28055',
+                          '18377','80332','74535','21757','29742',
+                          '90885','29898','17819','40811','25990',
+                          '47513','89531','91068','10391','18846',
+                          '99223','82637','41368','83658','86199',
+                          '81625','26696','89338','88425','32200',
+                          '81427','19053','77471','36610','99823',
+                          '43276','41249','48584','83550','82276',
+                          '18842','78890','14090','38123','40936',
+                          '34425','19850','43286','80072','79188',
+                          '54191','11395','50497','84861','90733',
+                          '21068','57666','37119','25004','57835',
+                          '70067','62878','95806','19303','18840',
+                          '19124','29785','16737','16022','49613',
+                          '89977','68310','60069','98360','48649',
+                          '39050','41793','25002','27413','39736',
+                          '47208','16515','94808','57648','15009',
+                          '80015','42961','63982','21744','71853',
+                          '81087','67468','34175','64008','20261',
+                          '11201','51799','48043','45645','61163',
+                          '48375','36447','57042','21218','41100',
+                          '89951','22745','35851','83326','61125',
+                          '78298','80752','49858','52940','96976',
+                          '63792','11376','53582','18717','90226',
+                          '50530','94203','99447','27670','96577',
+                          '57856','56372','16165','23427','54561',
+                          '28806','44439','22926','30123','61451',
+                          '92397','56979','92309','70873','13355',
+                          '21801','46346','37562','56458','28286',
+                          '47306','99555','69399','26234','47546',
+                          '49661','88601','35943','39936','25632',
+                          '24611','44166','56648','30379','59785',
+                          '11110','14329','93815','52226','71381',
+                          '13842','25612','63294','14664','21077',
+                          '82626','18799','60915','81020','56447',
+                          '76619','11433','13414','42548','92713',
+                          '70467','30884','47484','16072','38936',
+                          '13036','88376','45539','35901','19506',
+                          '65690','73957','71850','49231','14276',
+                          '20005','18384','76615','11635','38177',
+                          '55607','41369','95447','58581','58149',
+                          '91946','33790','76232','75692','95464',
+                          '22246','51061','56692','53121','77209',
+                          '15482','10688','14868','45907','73520',
+                          '72666','25734','17959','24677','66446',
+                          '94627','53535','15560','41967','69297',
+                          '11929','59403','33283','52232','57350',
+                          '43933','40921','36635','10827','71286',
+                          '19736','80619','25251','95042','15526',
+                          '36496','55854','49124','81980','35375',
+                          '49157','63512','28944','14946','36503',
+                          '54010','18767','23969','43905','66979',
+                          '33113','21286','58471','59080','13395',
+                          '79144','70373','67031','38360','26705',
+                          '50906','52406','26066','73146','15884',
+                          '31897','30045','61068','45550','92454',
+                          '13376','14354','19770','22928','97790',
+                          '50723','46081','30202','14410','20223',
+                          '88500','67298','13261','14172','81410',
+                          '93578','83583','46047','94167','82564',
+                          '21156','15799','86709','37931','74703',
+                          '83103','23054','70470','72008','49247',
+                          '91911','69998','20961','70070','63197',
+                          '54853','88191','91830','49521','19454',
+                          '81450','89091','62378','25683','61869',
+                          '51744','36580','85778','36871','48121',
+                          '28810','83712','45486','67393','26935',
+                          '42393','20132','55349','86057','21309',
+                          '80218','10094','11357','48819','39734',
+                          '40758','30432','21204','29467','30214',
+                          '61024','55307','74621','11622','68908',
+                          '33032','52868','99194','99900','84936',
+                          '69036','99149','45013','32895','59004',
+                          '32322','14933','32936','33562','72550',
+                          '27385','58049','58200','16808','21360',
+                          '32961','18586','79307','15492'))
+     intersect
+     (select ca_zip
+      from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt
+            FROM customer_address, customer
+            WHERE ca_address_sk = c_current_addr_sk and
+                  c_preferred_cust_flag='Y'
+            group by ca_zip
+            having count(*) > 10)A1))A2) V1
+ where ss_store_sk = s_store_sk
+  and ss_sold_date_sk = d_date_sk
+  and d_qoy = 1 and d_year = 2002
+  and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
+ group by s_store_name
+ order by s_store_name
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 13 (BROADCAST_EDGE), Reducer 7 (BROADCAST_EDGE)
+Reducer 11 <- Union 10 (SIMPLE_EDGE)
+Reducer 12 <- Map 19 (SIMPLE_EDGE), Reducer 11 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Map 18 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (SIMPLE_EDGE), Union 10 (CONTAINS)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 12 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 7 <- Map 6 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Map 8 (SIMPLE_EDGE), Union 10 (CONTAINS)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5 vectorized
+      File Output Operator [FS_151]
+        Limit [LIM_150] (rows=1 width=200)
+          Number of rows:100
+          Select Operator [SEL_149] (rows=1 width=200)
+            Output:["_col0","_col1"]
+          <-Reducer 4 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_148]
+              Group By Operator [GBY_147] (rows=1 width=200)
+                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Reducer 3 [SIMPLE_EDGE]
+                SHUFFLE [RS_57]
+                  PartitionCols:_col0
+                  Group By Operator [GBY_56] (rows=1 width=200)
+                    Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col6
+                    Top N Key Operator [TNK_84] (rows=1 width=200)
+                      keys:_col6,sort order:+,top n:100
+                      Merge Join Operator [MERGEJOIN_118] (rows=1 width=200)
+                        Conds:RS_52._col1=RS_53._col1(Inner),Output:["_col2","_col6"]
+                      <-Reducer 12 [SIMPLE_EDGE]
+                        SHUFFLE [RS_53]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_117] (rows=1 width=92)
+                            Conds:RS_138._col0=RS_141._col2(Inner),Output:["_col1","_col2"]
+                          <-Map 19 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_141]
+                              PartitionCols:_col2
+                              Select Operator [SEL_140] (rows=1704 width=276)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_139] (rows=1704 width=181)
+                                  predicate:substr(s_zip, 1, 2) is not null
+                                  TableScan [TS_42] (rows=1704 width=181)
+                                    default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_zip"]
+                          <-Reducer 11 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_138]
+                              PartitionCols:_col0
+                              Select Operator [SEL_137] (rows=1 width=184)
+                                Output:["_col0"]
+                                Filter Operator [FIL_136] (rows=1 width=192)
+                                  predicate:(_col1 = 2L)
+                                  Group By Operator [GBY_135] (rows=3098 width=192)
+                                    Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                                  <-Union 10 [SIMPLE_EDGE]
+                                    <-Reducer 17 [CONTAINS] vectorized
+                                      Reduce Output Operator [RS_172]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_171] (rows=3098 width=192)
+                                          Output:["_col0","_col1"],aggregations:["count(_col1)"],keys:_col0
+                                          Group By Operator [GBY_170] (rows=1126 width=192)
+                                            Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                                          <-Reducer 16 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_169]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_168] (rows=1126 width=192)
+                                                Output:["_col0","_col1"],aggregations:["count()"],keys:_col0
+                                                Select Operator [SEL_167] (rows=2253 width=97)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_166] (rows=2253 width=97)
+                                                    predicate:(_col1 > 10L)
+                                                    Group By Operator [GBY_165] (rows=6761 width=97)
+                                                      Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                                                    <-Reducer 15 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_25]
+                                                        PartitionCols:_col0
+                                                        Group By Operator [GBY_24] (rows=67610 width=97)
+                                                          Output:["_col0","_col1"],aggregations:["count()"],keys:_col1
+                                                          Merge Join Operator [MERGEJOIN_116] (rows=26666667 width=89)
+                                                            Conds:RS_161._col0=RS_164._col0(Inner),Output:["_col1"]
+                                                          <-Map 14 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_161]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_160] (rows=40000000 width=93)
+                                                                Output:["_col0","_col1"]
+                                                                Filter Operator [FIL_159] (rows=40000000 width=93)
+                                                                  predicate:substr(substr(ca_zip, 1, 5), 1, 2) is not null
+                                                                  TableScan [TS_14] (rows=40000000 width=93)
+                                                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_zip"]
+                                                          <-Map 18 [SIMPLE_EDGE] vectorized
+                                                            SHUFFLE [RS_164]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_163] (rows=26666667 width=4)
+                                                                Output:["_col0"]
+                                                                Filter Operator [FIL_162] (rows=26666667 width=89)
+                                                                  predicate:((c_preferred_cust_flag = 'Y') and c_current_addr_sk is not null)
+                                                                  TableScan [TS_17] (rows=80000000 width=89)
+                                                                    default@customer,customer,Tbl:COMPLETE,Col:COMPLETE,Output:["c_current_addr_sk","c_preferred_cust_flag"]
+                                    <-Reducer 9 [CONTAINS] vectorized
+                                      Reduce Output Operator [RS_158]
+                                        PartitionCols:_col0
+                                        Group By Operator [GBY_157] (rows=3098 width=192)
+                                          Output:["_col0","_col1"],aggregations:["count(_col1)"],keys:_col0
+                                          Group By Operator [GBY_156] (rows=5071 width=192)
+                                            Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                                          <-Map 8 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_155]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_154] (rows=70994 width=192)
+                                                Output:["_col0","_col1"],aggregations:["count()"],keys:_col0
+                                                Select Operator [SEL_153] (rows=20000000 width=89)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_152] (rows=20000000 width=89)
+                                                    predicate:((substr(ca_zip, 1, 5)) IN ('89436', '30868', '65085', '22977', '83927', '77557', '58429', '40697', '80614', '10502', '32779', '91137', '61265', '98294', '17921', '18427', '21203', '59362', '87291', '84093', '21505', '17184', '10866', '67898', '25797', '28055', '18377', '80332', '74535', '21757', '29742', '90885', '29898', '17819', '40811', '25990', '47513', '89531', '91068', '10391', '18846', '99223', '82637', '41368', '83658', '86199', '81625', '26696', '89338', '88425', '32200', '81427', '19053', '77471', '36610', '99823', '43276', '41249', '48584', '83550', '82276', '18842', '78890', '14090', '38123', '40936', '34425', '19850', '43286', '80072', '79188', '54191', '11395', '50497', '84861', '90733', '21068', '57666', '37119', '25004', '57835', '70067', '62878', '95806', '19303', '18840', '19124', '29785', '16737', '16022', '49613', '89977', '68310', '60069', '98360', '48649', '39050', '41793', '25002', '27413', '39736'
 , '47208', '16515', '94808', '57648', '15009', '80015', '42961', '63982', '21744', '71853', '81087', '67468', '34175', '64008', '20261', '11201', '51799', '48043', '45645', '61163', '48375', '36447', '57042', '21218', '41100', '89951', '22745', '35851', '83326', '61125', '78298', '80752', '49858', '52940', '96976', '63792', '11376', '53582', '18717', '90226', '50530', '94203', '99447', '27670', '96577', '57856', '56372', '16165', '23427', '54561', '28806', '44439', '22926', '30123', '61451', '92397', '56979', '92309', '70873', '13355', '21801', '46346', '37562', '56458', '28286', '47306', '99555', '69399', '26234', '47546', '49661', '88601', '35943', '39936', '25632', '24611', '44166', '56648', '30379', '59785', '11110', '14329', '93815', '52226', '71381', '13842', '25612', '63294', '14664', '21077', '82626', '18799', '60915', '81020', '56447', '76619', '11433', '13414', '42548', '92713', '70467', '30884', '47484', '16072', '38936', '13036', '88376', '45539', '35901', '19506', '6569
 0', '73957', '71850', '49231', '14276', '20005', '18384', '76615', '11635', '38177', '55607', '41369', '95447', '58581', '58149', '91946', '33790', '76232', '75692', '95464', '22246', '51061', '56692', '53121', '77209', '15482', '10688', '14868', '45907', '73520', '72666', '25734', '17959', '24677', '66446', '94627', '53535', '15560', '41967', '69297', '11929', '59403', '33283', '52232', '57350', '43933', '40921', '36635', '10827', '71286', '19736', '80619', '25251', '95042', '15526', '36496', '55854', '49124', '81980', '35375', '49157', '63512', '28944', '14946', '36503', '54010', '18767', '23969', '43905', '66979', '33113', '21286', '58471', '59080', '13395', '79144', '70373', '67031', '38360', '26705', '50906', '52406', '26066', '73146', '15884', '31897', '30045', '61068', '45550', '92454', '13376', '14354', '19770', '22928', '97790', '50723', '46081', '30202', '14410', '20223', '88500', '67298', '13261', '14172', '81410', '93578', '83583', '46047', '94167', '82564', '21156', '15
 799', '86709', '37931', '74703', '83103', '23054', '70470', '72008', '49247', '91911', '69998', '20961', '70070', '63197', '54853', '88191', '91830', '49521', '19454', '81450', '89091', '62378', '25683', '61869', '51744', '36580', '85778', '36871', '48121', '28810', '83712', '45486', '67393', '26935', '42393', '20132', '55349', '86057', '21309', '80218', '10094', '11357', '48819', '39734', '40758', '30432', '21204', '29467', '30214', '61024', '55307', '74621', '11622', '68908', '33032', '52868', '99194', '99900', '84936', '69036', '99149', '45013', '32895', '59004', '32322', '14933', '32936', '33562', '72550', '27385', '58049', '58200', '16808', '21360', '32961', '18586', '79307', '15492') and substr(substr(ca_zip, 1, 5), 1, 2) is not null)
+                                                    TableScan [TS_6] (rows=40000000 width=89)
+                                                      default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_zip"]
+                      <-Reducer 2 [SIMPLE_EDGE]
+                        SHUFFLE [RS_52]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_115] (rows=37399754 width=42)
+                            Conds:RS_146._col0=RS_129._col0(Inner),Output:["_col1","_col2"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            PARTITION_ONLY_SHUFFLE [RS_129]
+                              PartitionCols:_col0
+                              Select Operator [SEL_128] (rows=130 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_127] (rows=130 width=12)
+                                  predicate:((d_qoy = 1) and (d_year = 2002))
+                                  TableScan [TS_3] (rows=73049 width=12)
+                                    default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_qoy"]
+                          <-Map 1 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_146]
+                              PartitionCols:_col0
+                              Select Operator [SEL_145] (rows=525329897 width=114)
+                                Output:["_col0","_col1","_col2"]
+                                Filter Operator [FIL_144] (rows=525329897 width=114)
+                                  predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_50_date_dim_d_date_sk_min) AND DynamicValue(RS_50_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_50_date_dim_d_date_sk_bloom_filter))) and (ss_store_sk BETWEEN DynamicValue(RS_53_store_s_store_sk_min) AND DynamicValue(RS_53_store_s_store_sk_max) and in_bloom_filter(ss_store_sk, DynamicValue(RS_53_store_s_store_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                  TableScan [TS_0] (rows=575995635 width=114)
+                                    default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_store_sk","ss_net_profit"]
+                                  <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_143]
+                                      Group By Operator [GBY_142] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Reducer 12 [CUSTOM_SIMPLE_EDGE]
+                                        SHUFFLE [RS_92]
+                                          Group By Operator [GBY_91] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_90] (rows=1 width=8)
+                                              Output:["_col0"]
+                                               Please refer to the previous Merge Join Operator [MERGEJOIN_117]
+                                  <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_134]
+                                      Group By Operator [GBY_133] (rows=1 width=12)
+                                        Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                      <-Map 6 [CUSTOM_SIMPLE_EDGE] vectorized
+                                        PARTITION_ONLY_SHUFFLE [RS_132]
+                                          Group By Operator [GBY_131] (rows=1 width=12)
+                                            Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                            Select Operator [SEL_130] (rows=130 width=4)
+                                              Output:["_col0"]
+                                               Please refer to the previous Select Operator [SEL_128]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out
new file mode 100644
index 0000000..dbaecf8
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query80.q.out
@@ -0,0 +1,609 @@
+PREHOOK: query: explain
+with ssr as
+ (select  s_store_id as store_id,
+          sum(ss_ext_sales_price) as sales,
+          sum(coalesce(sr_return_amt, 0)) as returns,
+          sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit
+  from store_sales left outer join store_returns on
+         (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number),
+     date_dim,
+     store,
+     item,
+     promotion
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ss_store_sk = s_store_sk
+       and ss_item_sk = i_item_sk
+       and i_current_price > 50
+       and ss_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+ group by s_store_id)
+ ,
+ csr as
+ (select  cp_catalog_page_id as catalog_page_id,
+          sum(cs_ext_sales_price) as sales,
+          sum(coalesce(cr_return_amount, 0)) as returns,
+          sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit
+  from catalog_sales left outer join catalog_returns on
+         (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number),
+     date_dim,
+     catalog_page,
+     item,
+     promotion
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and cs_catalog_page_sk = cp_catalog_page_sk
+       and cs_item_sk = i_item_sk
+       and i_current_price > 50
+       and cs_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select  web_site_id,
+          sum(ws_ext_sales_price) as sales,
+          sum(coalesce(wr_return_amt, 0)) as returns,
+          sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit
+  from web_sales left outer join web_returns on
+         (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number),
+     date_dim,
+     web_site,
+     item,
+     promotion
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and ws_web_site_sk = web_site_sk
+       and ws_item_sk = i_item_sk
+       and i_current_price > 50
+       and ws_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || store_id as id
+        , sales
+        , returns
+        , profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || catalog_page_id as id
+        , sales
+        , returns
+        , profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_page
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with ssr as
+ (select  s_store_id as store_id,
+          sum(ss_ext_sales_price) as sales,
+          sum(coalesce(sr_return_amt, 0)) as returns,
+          sum(ss_net_profit - coalesce(sr_net_loss, 0)) as profit
+  from store_sales left outer join store_returns on
+         (ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number),
+     date_dim,
+     store,
+     item,
+     promotion
+ where ss_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  30 days)
+       and ss_store_sk = s_store_sk
+       and ss_item_sk = i_item_sk
+       and i_current_price > 50
+       and ss_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+ group by s_store_id)
+ ,
+ csr as
+ (select  cp_catalog_page_id as catalog_page_id,
+          sum(cs_ext_sales_price) as sales,
+          sum(coalesce(cr_return_amount, 0)) as returns,
+          sum(cs_net_profit - coalesce(cr_net_loss, 0)) as profit
+  from catalog_sales left outer join catalog_returns on
+         (cs_item_sk = cr_item_sk and cs_order_number = cr_order_number),
+     date_dim,
+     catalog_page,
+     item,
+     promotion
+ where cs_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and cs_catalog_page_sk = cp_catalog_page_sk
+       and cs_item_sk = i_item_sk
+       and i_current_price > 50
+       and cs_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select  web_site_id,
+          sum(ws_ext_sales_price) as sales,
+          sum(coalesce(wr_return_amt, 0)) as returns,
+          sum(ws_net_profit - coalesce(wr_net_loss, 0)) as profit
+  from web_sales left outer join web_returns on
+         (ws_item_sk = wr_item_sk and ws_order_number = wr_order_number),
+     date_dim,
+     web_site,
+     item,
+     promotion
+ where ws_sold_date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  30 days)
+        and ws_web_site_sk = web_site_sk
+       and ws_item_sk = i_item_sk
+       and i_current_price > 50
+       and ws_promo_sk = p_promo_sk
+       and p_channel_tv = 'N'
+group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || store_id as id
+        , sales
+        , returns
+        , profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || catalog_page_id as id
+        , sales
+        , returns
+        , profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_page
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 13 (BROADCAST_EDGE), Reducer 27 (BROADCAST_EDGE), Reducer 31 (BROADCAST_EDGE)
+Map 35 <- Reducer 19 (BROADCAST_EDGE), Reducer 28 (BROADCAST_EDGE), Reducer 32 (BROADCAST_EDGE)
+Map 39 <- Reducer 25 (BROADCAST_EDGE), Reducer 29 (BROADCAST_EDGE), Reducer 33 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 12 (SIMPLE_EDGE), Reducer 36 (SIMPLE_EDGE)
+Reducer 15 <- Map 26 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Map 30 (SIMPLE_EDGE), Reducer 15 (SIMPLE_EDGE)
+Reducer 17 <- Map 38 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE), Union 8 (CONTAINS)
+Reducer 19 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 11 (SIMPLE_EDGE)
+Reducer 20 <- Map 12 (SIMPLE_EDGE), Reducer 40 (SIMPLE_EDGE)
+Reducer 21 <- Map 26 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Map 30 (SIMPLE_EDGE), Reducer 21 (SIMPLE_EDGE)
+Reducer 23 <- Map 42 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Reducer 23 (SIMPLE_EDGE), Union 8 (CONTAINS)
+Reducer 25 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 27 <- Map 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 28 <- Map 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 26 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 12 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 31 <- Map 30 (CUSTOM_SIMPLE_EDGE)
+Reducer 32 <- Map 30 (CUSTOM_SIMPLE_EDGE)
+Reducer 33 <- Map 30 (CUSTOM_SIMPLE_EDGE)
+Reducer 36 <- Map 35 (SIMPLE_EDGE), Map 37 (SIMPLE_EDGE)
+Reducer 4 <- Map 26 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 40 <- Map 39 (SIMPLE_EDGE), Map 41 (SIMPLE_EDGE)
+Reducer 5 <- Map 30 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Map 34 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE), Union 8 (CONTAINS)
+Reducer 9 <- Union 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 10 vectorized
+      File Output Operator [FS_452]
+        Limit [LIM_451] (rows=100 width=619)
+          Number of rows:100
+          Select Operator [SEL_450] (rows=38846 width=619)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 9 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_449]
+              Select Operator [SEL_448] (rows=38846 width=619)
+                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Group By Operator [GBY_447] (rows=38846 width=627)
+                  Output:["_col0","_col1","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2
+                <-Union 8 [SIMPLE_EDGE]
+                  <-Reducer 18 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_470]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_469] (rows=59581 width=627)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_468] (rows=39721 width=618)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_467] (rows=38846 width=619)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Group By Operator [GBY_466] (rows=38846 width=436)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0
+                            <-Reducer 17 [SIMPLE_EDGE]
+                              SHUFFLE [RS_71]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_70] (rows=46000 width=436)
+                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col1)","sum(_col2)","sum(_col3)"],keys:_col0
+                                  Select Operator [SEL_68] (rows=8592843 width=305)
+                                    Output:["_col0","_col1","_col2","_col3"]
+                                    Merge Join Operator [MERGEJOIN_363] (rows=8592843 width=305)
+                                      Conds:RS_65._col1=RS_465._col0(Inner),Output:["_col5","_col6","_col9","_col10","_col15"]
+                                    <-Map 38 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_465]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_464] (rows=46000 width=104)
+                                          Output:["_col0","_col1"]
+                                          TableScan [TS_51] (rows=46000 width=104)
+                                            default@catalog_page,catalog_page,Tbl:COMPLETE,Col:COMPLETE,Output:["cp_catalog_page_sk","cp_catalog_page_id"]
+                                    <-Reducer 16 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_65]
+                                        PartitionCols:_col1
+                                        Merge Join Operator [MERGEJOIN_362] (rows=8592843 width=208)
+                                          Conds:RS_62._col3=RS_423._col0(Inner),Output:["_col1","_col5","_col6","_col9","_col10"]
+                                        <-Map 30 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_423]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_420] (rows=1150 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_419] (rows=1150 width=89)
+                                                predicate:(p_channel_tv = 'N')
+                                                TableScan [TS_11] (rows=2300 width=89)
+                                                  default@promotion,promotion,Tbl:COMPLETE,Col:COMPLETE,Output:["p_promo_sk","p_channel_tv"]
+                                        <-Reducer 15 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_62]
+                                            PartitionCols:_col3
+                                            Merge Join Operator [MERGEJOIN_361] (rows=17185686 width=222)
+                                              Conds:RS_59._col2=RS_407._col0(Inner),Output:["_col1","_col3","_col5","_col6","_col9","_col10"]
+                                            <-Map 26 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_407]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_404] (rows=154000 width=4)
+                                                  Output:["_col0"]
+                                                  Filter Operator [FIL_403] (rows=154000 width=115)
+                                                    predicate:(i_current_price > 50)
+                                                    TableScan [TS_8] (rows=462000 width=115)
+                                                      default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price"]
+                                            <-Reducer 14 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_59]
+                                                PartitionCols:_col2
+                                                Merge Join Operator [MERGEJOIN_360] (rows=51557056 width=232)
+                                                  Conds:RS_56._col0=RS_391._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col9","_col10"]
+                                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_391]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_388] (rows=8116 width=4)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_387] (rows=8116 width=98)
+                                                        predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-08-04 00:00:00' AND TIMESTAMP'1998-09-03 00:00:00'
+                                                        TableScan [TS_5] (rows=73049 width=98)
+                                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                                <-Reducer 36 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_56]
+                                                    PartitionCols:_col0
+                                                    Merge Join Operator [MERGEJOIN_359] (rows=464045263 width=326)
+                                                      Conds:RS_461._col2, _col4=RS_463._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col9","_col10"]
+                                                    <-Map 35 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_461]
+                                                        PartitionCols:_col2, _col4
+                                                        Select Operator [SEL_460] (rows=283691906 width=243)
+                                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                          Filter Operator [FIL_459] (rows=283691906 width=243)
+                                                            predicate:((cs_item_sk BETWEEN DynamicValue(RS_60_item_i_item_sk_min) AND DynamicValue(RS_60_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_60_item_i_item_sk_bloom_filter))) and (cs_promo_sk BETWEEN DynamicValue(RS_63_promotion_p_promo_sk_min) AND DynamicValue(RS_63_promotion_p_promo_sk_max) and in_bloom_filter(cs_promo_sk, DynamicValue(RS_63_promotion_p_promo_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_57_date_dim_d_date_sk_min) AND DynamicValue(RS_57_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_57_date_dim_d_date_sk_bloom_filter))) and cs_catalog_page_sk is not null and cs_promo_sk is not null and cs_sold_date_sk is not null)
+                                                            TableScan [TS_37] (rows=287989836 width=243)
+                                                              default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_catalog_page_sk","cs_item_sk","cs_promo_sk","cs_order_number","cs_ext_sales_price","cs_net_profit"]
+                                                            <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_454]
+                                                                Group By Operator [GBY_453] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_399]
+                                                                    Group By Operator [GBY_396] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_392] (rows=8116 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_388]
+                                                            <-Reducer 28 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_456]
+                                                                Group By Operator [GBY_455] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 26 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_415]
+                                                                    Group By Operator [GBY_412] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_408] (rows=154000 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_404]
+                                                            <-Reducer 32 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_458]
+                                                                Group By Operator [GBY_457] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 30 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_431]
+                                                                    Group By Operator [GBY_428] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_424] (rows=1150 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_420]
+                                                    <-Map 37 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_463]
+                                                        PartitionCols:_col0, _col1
+                                                        Select Operator [SEL_462] (rows=28798881 width=227)
+                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                          TableScan [TS_40] (rows=28798881 width=227)
+                                                            default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_item_sk","cr_order_number","cr_return_amount","cr_net_loss"]
+                  <-Reducer 24 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_488]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_487] (rows=59581 width=627)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_486] (rows=39721 width=618)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_485] (rows=53 width=615)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Group By Operator [GBY_484] (rows=53 width=436)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0
+                            <-Reducer 23 [SIMPLE_EDGE]
+                              SHUFFLE [RS_109]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_108] (rows=318 width=436)
+                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col1)","sum(_col2)","sum(_col3)"],keys:_col0
+                                  Select Operator [SEL_106] (rows=4714659 width=323)
+                                    Output:["_col0","_col1","_col2","_col3"]
+                                    Merge Join Operator [MERGEJOIN_368] (rows=4714659 width=323)
+                                      Conds:RS_103._col2=RS_483._col0(Inner),Output:["_col5","_col6","_col9","_col10","_col15"]
+                                    <-Map 42 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_483]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_482] (rows=84 width=104)
+                                          Output:["_col0","_col1"]
+                                          TableScan [TS_89] (rows=84 width=104)
+                                            default@web_site,web_site,Tbl:COMPLETE,Col:COMPLETE,Output:["web_site_sk","web_site_id"]
+                                    <-Reducer 22 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_103]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_367] (rows=4714659 width=227)
+                                          Conds:RS_100._col3=RS_425._col0(Inner),Output:["_col2","_col5","_col6","_col9","_col10"]
+                                        <-Map 30 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_425]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_420]
+                                        <-Reducer 21 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_100]
+                                            PartitionCols:_col3
+                                            Merge Join Operator [MERGEJOIN_366] (rows=9429318 width=231)
+                                              Conds:RS_97._col1=RS_409._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col9","_col10"]
+                                            <-Map 26 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_409]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_404]
+                                            <-Reducer 20 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_97]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_365] (rows=28287952 width=235)
+                                                  Conds:RS_94._col0=RS_393._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col9","_col10"]
+                                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_393]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_388]
+                                                <-Reducer 40 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_94]
+                                                    PartitionCols:_col0
+                                                    Merge Join Operator [MERGEJOIN_364] (rows=254608997 width=363)
+                                                      Conds:RS_479._col1, _col4=RS_481._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col9","_col10"]
+                                                    <-Map 39 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_479]
+                                                        PartitionCols:_col1, _col4
+                                                        Select Operator [SEL_478] (rows=143894769 width=243)
+                                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                          Filter Operator [FIL_477] (rows=143894769 width=243)
+                                                            predicate:((ws_item_sk BETWEEN DynamicValue(RS_98_item_i_item_sk_min) AND DynamicValue(RS_98_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_98_item_i_item_sk_bloom_filter))) and (ws_promo_sk BETWEEN DynamicValue(RS_101_promotion_p_promo_sk_min) AND DynamicValue(RS_101_promotion_p_promo_sk_max) and in_bloom_filter(ws_promo_sk, DynamicValue(RS_101_promotion_p_promo_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_95_date_dim_d_date_sk_min) AND DynamicValue(RS_95_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_95_date_dim_d_date_sk_bloom_filter))) and ws_promo_sk is not null and ws_sold_date_sk is not null and ws_web_site_sk is not null)
+                                                            TableScan [TS_75] (rows=144002668 width=243)
+                                                              default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_web_site_sk","ws_promo_sk","ws_order_number","ws_ext_sales_price","ws_net_profit"]
+                                                            <-Reducer 25 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_472]
+                                                                Group By Operator [GBY_471] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_400]
+                                                                    Group By Operator [GBY_397] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_394] (rows=8116 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_388]
+                                                            <-Reducer 29 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_474]
+                                                                Group By Operator [GBY_473] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 26 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_416]
+                                                                    Group By Operator [GBY_413] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_410] (rows=154000 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_404]
+                                                            <-Reducer 33 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_476]
+                                                                Group By Operator [GBY_475] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 30 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_432]
+                                                                    Group By Operator [GBY_429] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_426] (rows=1150 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_420]
+                                                    <-Map 41 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_481]
+                                                        PartitionCols:_col0, _col1
+                                                        Select Operator [SEL_480] (rows=14398467 width=221)
+                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                          TableScan [TS_78] (rows=14398467 width=221)
+                                                            default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_item_sk","wr_order_number","wr_return_amt","wr_net_loss"]
+                  <-Reducer 7 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_446]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_445] (rows=59581 width=627)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_444] (rows=39721 width=618)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_443] (rows=822 width=617)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Group By Operator [GBY_442] (rows=822 width=436)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0
+                            <-Reducer 6 [SIMPLE_EDGE]
+                              SHUFFLE [RS_34]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_33] (rows=1704 width=436)
+                                  Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col1)","sum(_col2)","sum(_col3)"],keys:_col0
+                                  Select Operator [SEL_31] (rows=15038783 width=100)
+                                    Output:["_col0","_col1","_col2","_col3"]
+                                    Merge Join Operator [MERGEJOIN_358] (rows=15038783 width=100)
+                                      Conds:RS_28._col2=RS_441._col0(Inner),Output:["_col5","_col6","_col9","_col10","_col15"]
+                                    <-Map 34 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_441]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_440] (rows=1704 width=104)
+                                          Output:["_col0","_col1"]
+                                          TableScan [TS_14] (rows=1704 width=104)
+                                            default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id"]
+                                    <-Reducer 5 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_28]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_357] (rows=15038783 width=0)
+                                          Conds:RS_25._col3=RS_421._col0(Inner),Output:["_col2","_col5","_col6","_col9","_col10"]
+                                        <-Map 30 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_421]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_420]
+                                        <-Reducer 4 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_25]
+                                            PartitionCols:_col3
+                                            Merge Join Operator [MERGEJOIN_356] (rows=30077566 width=57)
+                                              Conds:RS_22._col1=RS_405._col0(Inner),Output:["_col2","_col3","_col5","_col6","_col9","_col10"]
+                                            <-Map 26 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_405]
+                                                PartitionCols:_col0
+                                                 Please refer to the previous Select Operator [SEL_404]
+                                            <-Reducer 3 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_22]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_355] (rows=90232695 width=177)
+                                                  Conds:RS_19._col0=RS_389._col0(Inner),Output:["_col1","_col2","_col3","_col5","_col6","_col9","_col10"]
+                                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_389]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_388]
+                                                <-Reducer 2 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_19]
+                                                    PartitionCols:_col0
+                                                    Merge Join Operator [MERGEJOIN_354] (rows=812149846 width=374)
+                                                      Conds:RS_437._col1, _col4=RS_439._col0, _col1(Left Outer),Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col9","_col10"]
+                                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_437]
+                                                        PartitionCols:_col1, _col4
+                                                        Select Operator [SEL_436] (rows=501693263 width=233)
+                                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6"]
+                                                          Filter Operator [FIL_435] (rows=501693263 width=233)
+                                                            predicate:((ss_item_sk BETWEEN DynamicValue(RS_23_item_i_item_sk_min) AND DynamicValue(RS_23_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_23_item_i_item_sk_bloom_filter))) and (ss_promo_sk BETWEEN DynamicValue(RS_26_promotion_p_promo_sk_min) AND DynamicValue(RS_26_promotion_p_promo_sk_max) and in_bloom_filter(ss_promo_sk, DynamicValue(RS_26_promotion_p_promo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_20_date_dim_d_date_sk_min) AND DynamicValue(RS_20_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_20_date_dim_d_date_sk_bloom_filter))) and ss_promo_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                            TableScan [TS_0] (rows=575995635 width=233)
+                                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_store_sk","ss_promo_sk","ss_ticket_number","ss_ext_sales_price","ss_net_profit"]
+                                                            <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_402]
+                                                                Group By Operator [GBY_401] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_398]
+                                                                    Group By Operator [GBY_395] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_390] (rows=8116 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_388]
+                                                            <-Reducer 27 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_418]
+                                                                Group By Operator [GBY_417] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 26 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_414]
+                                                                    Group By Operator [GBY_411] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_406] (rows=154000 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_404]
+                                                            <-Reducer 31 [BROADCAST_EDGE] vectorized
+                                                              BROADCAST [RS_434]
+                                                                Group By Operator [GBY_433] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                <-Map 30 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                  SHUFFLE [RS_430]
+                                                                    Group By Operator [GBY_427] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                      Select Operator [SEL_422] (rows=1150 width=4)
+                                                                        Output:["_col0"]
+                                                                         Please refer to the previous Select Operator [SEL_420]
+                                                    <-Map 11 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_439]
+                                                        PartitionCols:_col0, _col1
+                                                        Select Operator [SEL_438] (rows=57591150 width=224)
+                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                          TableScan [TS_3] (rows=57591150 width=224)
+                                                            default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number","sr_return_amt","sr_net_loss"]
+


[09/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query69.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query69.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query69.q.out
new file mode 100644
index 0000000..8fe3134
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query69.q.out
@@ -0,0 +1,359 @@
+PREHOOK: query: explain
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_state in ('CO','IL','MN') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_moy between 1 and 1+2) and
+   (not exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2) and
+    not exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_state in ('CO','IL','MN') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_moy between 1 and 1+2) and
+   (not exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2) and
+    not exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 14 <- Reducer 11 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Map 24 <- Reducer 10 (BROADCAST_EDGE), Reducer 20 (BROADCAST_EDGE)
+Map 25 <- Reducer 23 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 11 <- Reducer 3 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Map 16 (SIMPLE_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 18 <- Map 16 (SIMPLE_EDGE), Map 24 (SIMPLE_EDGE)
+Reducer 19 <- Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 20 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 21 <- Map 16 (SIMPLE_EDGE), Map 25 (SIMPLE_EDGE)
+Reducer 22 <- Reducer 21 (SIMPLE_EDGE)
+Reducer 23 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 13 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 15 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 19 (ONE_TO_ONE_EDGE), Reducer 4 (ONE_TO_ONE_EDGE)
+Reducer 6 <- Reducer 22 (ONE_TO_ONE_EDGE), Reducer 5 (ONE_TO_ONE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 5 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_238]
+        Limit [LIM_237] (rows=1 width=383)
+          Number of rows:100
+          Select Operator [SEL_236] (rows=1 width=383)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+          <-Reducer 7 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_235]
+              Select Operator [SEL_234] (rows=1 width=383)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col6"]
+                Group By Operator [GBY_233] (rows=1 width=367)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["count(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                <-Reducer 6 [SIMPLE_EDGE]
+                  SHUFFLE [RS_68]
+                    PartitionCols:_col0, _col1, _col2, _col3, _col4
+                    Group By Operator [GBY_67] (rows=1 width=367)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["count()"],keys:_col6, _col7, _col8, _col9, _col10
+                      Top N Key Operator [TNK_104] (rows=1 width=363)
+                        keys:_col6, _col7, _col8, _col9, _col10,sort order:+++++,top n:100
+                        Select Operator [SEL_66] (rows=1 width=363)
+                          Output:["_col6","_col7","_col8","_col9","_col10"]
+                          Filter Operator [FIL_65] (rows=1 width=363)
+                            predicate:_col14 is null
+                            Merge Join Operator [MERGEJOIN_183] (rows=1 width=363)
+                              Conds:RS_62._col0=RS_232._col0(Left Outer),Output:["_col6","_col7","_col8","_col9","_col10","_col14"]
+                            <-Reducer 5 [ONE_TO_ONE_EDGE]
+                              PARTITION_ONLY_SHUFFLE [RS_62]
+                                PartitionCols:_col0
+                                Select Operator [SEL_47] (rows=1 width=367)
+                                  Output:["_col0","_col6","_col7","_col8","_col9","_col10"]
+                                  Filter Operator [FIL_46] (rows=1 width=367)
+                                    predicate:_col12 is null
+                                    Merge Join Operator [MERGEJOIN_182] (rows=33 width=367)
+                                      Conds:RS_43._col0=RS_222._col0(Left Outer),Output:["_col0","_col6","_col7","_col8","_col9","_col10","_col12"]
+                                    <-Reducer 4 [ONE_TO_ONE_EDGE]
+                                      FORWARD [RS_43]
+                                        PartitionCols:_col0
+                                        Merge Join Operator [MERGEJOIN_181] (rows=6841 width=363)
+                                          Conds:RS_40._col0=RS_41._col0(Left Semi),Output:["_col0","_col6","_col7","_col8","_col9","_col10"]
+                                        <-Reducer 3 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_40]
+                                            PartitionCols:_col0
+                                            Merge Join Operator [MERGEJOIN_177] (rows=4605476 width=363)
+                                              Conds:RS_35._col1=RS_191._col0(Inner),Output:["_col0","_col6","_col7","_col8","_col9","_col10"]
+                                            <-Map 13 [SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_191]
+                                                PartitionCols:_col0
+                                                Select Operator [SEL_190] (rows=1861800 width=363)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                                  TableScan [TS_6] (rows=1861800 width=363)
+                                                    default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status","cd_purchase_estimate","cd_credit_rating"]
+                                            <-Reducer 2 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_35]
+                                                PartitionCols:_col1
+                                                Merge Join Operator [MERGEJOIN_176] (rows=4541258 width=5)
+                                                  Conds:RS_186._col2=RS_189._col0(Inner),Output:["_col0","_col1"]
+                                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_186]
+                                                    PartitionCols:_col2
+                                                    Select Operator [SEL_185] (rows=77201384 width=11)
+                                                      Output:["_col0","_col1","_col2"]
+                                                      Filter Operator [FIL_184] (rows=77201384 width=11)
+                                                        predicate:(c_current_addr_sk is not null and c_current_cdemo_sk is not null)
+                                                        TableScan [TS_0] (rows=80000000 width=11)
+                                                          default@customer,c,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_cdemo_sk","c_current_addr_sk"]
+                                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_189]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_188] (rows=2352941 width=90)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_187] (rows=2352941 width=90)
+                                                        predicate:(ca_state) IN ('CO', 'IL', 'MN')
+                                                        TableScan [TS_3] (rows=40000000 width=90)
+                                                          default@customer_address,ca,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
+                                        <-Reducer 15 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_41]
+                                            PartitionCols:_col0
+                                            Group By Operator [GBY_39] (rows=116289 width=1)
+                                              Output:["_col0"],keys:_col0
+                                              Select Operator [SEL_17] (rows=43153353 width=1)
+                                                Output:["_col0"]
+                                                Merge Join Operator [MERGEJOIN_178] (rows=43153353 width=1)
+                                                  Conds:RS_212._col0=RS_194._col0(Inner),Output:["_col1"]
+                                                <-Map 16 [SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_194]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_193] (rows=150 width=4)
+                                                      Output:["_col0"]
+                                                      Filter Operator [FIL_192] (rows=150 width=12)
+                                                        predicate:((d_year = 1999) and d_moy BETWEEN 1 AND 3)
+                                                        TableScan [TS_11] (rows=73049 width=12)
+                                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                                <-Map 14 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_212]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_211] (rows=525327388 width=7)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_210] (rows=525327388 width=7)
+                                                        predicate:((ss_customer_sk BETWEEN DynamicValue(RS_40_c_c_customer_sk_min) AND DynamicValue(RS_40_c_c_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_40_c_c_customer_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_15_date_dim_d_date_sk_min) AND DynamicValue(RS_15_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_15_date_dim_d_date_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                                        TableScan [TS_8] (rows=575995635 width=7)
+                                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_customer_sk"]
+                                                        <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_209]
+                                                            Group By Operator [GBY_208] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=4291485)"]
+                                                            <-Reducer 3 [CUSTOM_SIMPLE_EDGE]
+                                                              SHUFFLE [RS_137]
+                                                                Group By Operator [GBY_136] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=4291485)"]
+                                                                  Select Operator [SEL_135] (rows=4605476 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Merge Join Operator [MERGEJOIN_177]
+                                                        <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_207]
+                                                            Group By Operator [GBY_206] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              PARTITION_ONLY_SHUFFLE [RS_203]
+                                                                Group By Operator [GBY_200] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_195] (rows=150 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_193]
+                                    <-Reducer 19 [ONE_TO_ONE_EDGE] vectorized
+                                      FORWARD [RS_222]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_221] (rows=116289 width=7)
+                                          Output:["_col0","_col1"]
+                                          Group By Operator [GBY_220] (rows=116289 width=3)
+                                            Output:["_col0"],keys:KEY._col0
+                                          <-Reducer 18 [SIMPLE_EDGE]
+                                            SHUFFLE [RS_29]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_28] (rows=116289 width=3)
+                                                Output:["_col0"],keys:_col1
+                                                Merge Join Operator [MERGEJOIN_179] (rows=11823304 width=3)
+                                                  Conds:RS_219._col0=RS_196._col0(Inner),Output:["_col1"]
+                                                <-Map 16 [SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_196]
+                                                    PartitionCols:_col0
+                                                     Please refer to the previous Select Operator [SEL_193]
+                                                <-Map 24 [SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_219]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_218] (rows=143930993 width=7)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_217] (rows=143930993 width=7)
+                                                        predicate:((ws_bill_customer_sk BETWEEN DynamicValue(RS_43_c_c_customer_sk_min) AND DynamicValue(RS_43_c_c_customer_sk_max) and in_bloom_filter(ws_bill_customer_sk, DynamicValue(RS_43_c_c_customer_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_25_date_dim_d_date_sk_min) AND DynamicValue(RS_25_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_25_date_dim_d_date_sk_bloom_filter))) and ws_bill_customer_sk is not null and ws_sold_date_sk is not null)
+                                                        TableScan [TS_18] (rows=144002668 width=7)
+                                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_bill_customer_sk"]
+                                                        <-Reducer 10 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_216]
+                                                            Group By Operator [GBY_215] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Reducer 4 [CUSTOM_SIMPLE_EDGE]
+                                                              FORWARD [RS_152]
+                                                                Group By Operator [GBY_151] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_150] (rows=6841 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Merge Join Operator [MERGEJOIN_181]
+                                                        <-Reducer 20 [BROADCAST_EDGE] vectorized
+                                                          BROADCAST [RS_214]
+                                                            Group By Operator [GBY_213] (rows=1 width=12)
+                                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                            <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                              PARTITION_ONLY_SHUFFLE [RS_204]
+                                                                Group By Operator [GBY_201] (rows=1 width=12)
+                                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                  Select Operator [SEL_197] (rows=150 width=4)
+                                                                    Output:["_col0"]
+                                                                     Please refer to the previous Select Operator [SEL_193]
+                            <-Reducer 22 [ONE_TO_ONE_EDGE] vectorized
+                              FORWARD [RS_232]
+                                PartitionCols:_col0
+                                Select Operator [SEL_231] (rows=115467 width=7)
+                                  Output:["_col0","_col1"]
+                                  Group By Operator [GBY_230] (rows=115467 width=3)
+                                    Output:["_col0"],keys:KEY._col0
+                                  <-Reducer 21 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_59]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_58] (rows=115467 width=3)
+                                        Output:["_col0"],keys:_col1
+                                        Merge Join Operator [MERGEJOIN_180] (rows=23255411 width=3)
+                                          Conds:RS_229._col0=RS_198._col0(Inner),Output:["_col1"]
+                                        <-Map 16 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_198]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_193]
+                                        <-Map 25 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_229]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_228] (rows=285115246 width=7)
+                                              Output:["_col0","_col1"]
+                                              Filter Operator [FIL_227] (rows=285115246 width=7)
+                                                predicate:((cs_ship_customer_sk BETWEEN DynamicValue(RS_62_c_c_customer_sk_min) AND DynamicValue(RS_62_c_c_customer_sk_max) and in_bloom_filter(cs_ship_customer_sk, DynamicValue(RS_62_c_c_customer_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_55_date_dim_d_date_sk_min) AND DynamicValue(RS_55_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_55_date_dim_d_date_sk_bloom_filter))) and cs_ship_customer_sk is not null and cs_sold_date_sk is not null)
+                                                TableScan [TS_48] (rows=287989836 width=7)
+                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_ship_customer_sk"]
+                                                <-Reducer 23 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_224]
+                                                    Group By Operator [GBY_223] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_205]
+                                                        Group By Operator [GBY_202] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_199] (rows=150 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_193]
+                                                <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_226]
+                                                    Group By Operator [GBY_225] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 5 [CUSTOM_SIMPLE_EDGE]
+                                                      PARTITION_ONLY_SHUFFLE [RS_167]
+                                                        Group By Operator [GBY_166] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_165] (rows=1 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_47]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query7.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query7.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query7.q.out
new file mode 100644
index 0000000..6cfaac6
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query7.q.out
@@ -0,0 +1,171 @@
+PREHOOK: query: explain
+select  i_item_id, 
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4 
+ from store_sales, customer_demographics, date_dim, item, promotion
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       ss_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
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  i_item_id, 
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4 
+ from store_sales, customer_demographics, date_dim, item, promotion
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       ss_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
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 12 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 13 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_128]
+        Limit [LIM_127] (rows=100 width=444)
+          Number of rows:100
+          Select Operator [SEL_126] (rows=310774 width=444)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_125]
+              Select Operator [SEL_124] (rows=310774 width=444)
+                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Group By Operator [GBY_123] (rows=310774 width=476)
+                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)","sum(VALUE._col2)","count(VALUE._col3)","sum(VALUE._col4)","count(VALUE._col5)","sum(VALUE._col6)","count(VALUE._col7)"],keys:KEY._col0
+                <-Reducer 5 [SIMPLE_EDGE]
+                  SHUFFLE [RS_28]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_27] (rows=462000 width=476)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(_col4)","count(_col4)","sum(_col5)","count(_col5)","sum(_col7)","count(_col7)","sum(_col6)","count(_col6)"],keys:_col12
+                      Top N Key Operator [TNK_54] (rows=1441769 width=100)
+                        keys:_col12,sort order:+,top n:100
+                        Merge Join Operator [MERGEJOIN_98] (rows=1441769 width=100)
+                          Conds:RS_23._col1=RS_122._col0(Inner),Output:["_col4","_col5","_col6","_col7","_col12"]
+                        <-Map 13 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_122]
+                            PartitionCols:_col0
+                            Select Operator [SEL_121] (rows=462000 width=104)
+                              Output:["_col0","_col1"]
+                              TableScan [TS_12] (rows=462000 width=104)
+                                default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                        <-Reducer 4 [SIMPLE_EDGE]
+                          SHUFFLE [RS_23]
+                            PartitionCols:_col1
+                            Merge Join Operator [MERGEJOIN_97] (rows=1441769 width=4)
+                              Conds:RS_20._col3=RS_120._col0(Inner),Output:["_col1","_col4","_col5","_col6","_col7"]
+                            <-Map 12 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_120]
+                                PartitionCols:_col0
+                                Select Operator [SEL_119] (rows=2300 width=4)
+                                  Output:["_col0"]
+                                  Filter Operator [FIL_118] (rows=2300 width=174)
+                                    predicate:((p_channel_email = 'N') or (p_channel_event = 'N'))
+                                    TableScan [TS_9] (rows=2300 width=174)
+                                      default@promotion,promotion,Tbl:COMPLETE,Col:COMPLETE,Output:["p_promo_sk","p_channel_email","p_channel_event"]
+                            <-Reducer 3 [SIMPLE_EDGE]
+                              SHUFFLE [RS_20]
+                                PartitionCols:_col3
+                                Merge Join Operator [MERGEJOIN_96] (rows=1441769 width=4)
+                                  Conds:RS_17._col0=RS_109._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col6","_col7"]
+                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_109]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_108] (rows=652 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_107] (rows=652 width=8)
+                                        predicate:(d_year = 1998)
+                                        TableScan [TS_6] (rows=73049 width=8)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year"]
+                                <-Reducer 2 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_17]
+                                    PartitionCols:_col0
+                                    Merge Join Operator [MERGEJOIN_95] (rows=4037893 width=4)
+                                      Conds:RS_117._col2=RS_101._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col6","_col7"]
+                                    <-Map 8 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_101]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_100] (rows=14776 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_99] (rows=14776 width=268)
+                                            predicate:((cd_education_status = 'Primary') and (cd_gender = 'F') and (cd_marital_status = 'W'))
+                                            TableScan [TS_3] (rows=1861800 width=268)
+                                              default@customer_demographics,customer_demographics,Tbl:COMPLETE,Col:COMPLETE,Output:["cd_demo_sk","cd_gender","cd_marital_status","cd_education_status"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_117]
+                                        PartitionCols:_col2
+                                        Select Operator [SEL_116] (rows=501686735 width=340)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                                          Filter Operator [FIL_115] (rows=501686735 width=340)
+                                            predicate:((ss_cdemo_sk BETWEEN DynamicValue(RS_15_customer_demographics_cd_demo_sk_min) AND DynamicValue(RS_15_customer_demographics_cd_demo_sk_max) and in_bloom_filter(ss_cdemo_sk, DynamicValue(RS_15_customer_demographics_cd_demo_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_18_date_dim_d_date_sk_min) AND DynamicValue(RS_18_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_18_date_dim_d_date_sk_bloom_filter))) and ss_cdemo_sk is not null and ss_promo_sk is not null and ss_sold_date_sk is not null)
+                                            TableScan [TS_0] (rows=575995635 width=340)
+                                              default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_cdemo_sk","ss_promo_sk","ss_quantity","ss_list_price","ss_sales_price","ss_coupon_amt"]
+                                            <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_114]
+                                                Group By Operator [GBY_113] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  SHUFFLE [RS_112]
+                                                    Group By Operator [GBY_111] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_110] (rows=652 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_108]
+                                            <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                              BROADCAST [RS_106]
+                                                Group By Operator [GBY_105] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                  PARTITION_ONLY_SHUFFLE [RS_104]
+                                                    Group By Operator [GBY_103] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                      Select Operator [SEL_102] (rows=14776 width=4)
+                                                        Output:["_col0"]
+                                                         Please refer to the previous Select Operator [SEL_100]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query70.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query70.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query70.q.out
new file mode 100644
index 0000000..184d281
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query70.q.out
@@ -0,0 +1,216 @@
+PREHOOK: query: explain
+select  
+    sum(ss_net_profit) as total_sum
+   ,s_state
+   ,s_county
+   ,grouping(s_state)+grouping(s_county) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(s_state)+grouping(s_county),
+ 	case when grouping(s_county) = 0 then s_state end 
+ 	order by sum(ss_net_profit) desc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,store
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ss_sold_date_sk
+ and s_store_sk  = ss_store_sk
+ and s_state in
+             ( select s_state
+               from  (select s_state as s_state,
+ 			    rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
+                      from   store_sales, store, date_dim
+                      where  d_month_seq between 1212 and 1212+11
+ 			    and d_date_sk = ss_sold_date_sk
+ 			    and s_store_sk  = ss_store_sk
+                      group by s_state
+                     ) tmp1 
+               where ranking <= 5
+             )
+ group by rollup(s_state,s_county)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then s_state end
+  ,rank_within_parent
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+    sum(ss_net_profit) as total_sum
+   ,s_state
+   ,s_county
+   ,grouping(s_state)+grouping(s_county) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(s_state)+grouping(s_county),
+ 	case when grouping(s_county) = 0 then s_state end 
+ 	order by sum(ss_net_profit) desc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,store
+ where
+    d1.d_month_seq between 1212 and 1212+11
+ and d1.d_date_sk = ss_sold_date_sk
+ and s_store_sk  = ss_store_sk
+ and s_state in
+             ( select s_state
+               from  (select s_state as s_state,
+ 			    rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
+                      from   store_sales, store, date_dim
+                      where  d_month_seq between 1212 and 1212+11
+ 			    and d_date_sk = ss_sold_date_sk
+ 			    and s_store_sk  = ss_store_sk
+                      group by s_state
+                     ) tmp1 
+               where ranking <= 5
+             )
+ group by rollup(s_state,s_county)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then s_state end
+  ,rank_within_parent
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 12 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 11 (SIMPLE_EDGE)
+Reducer 3 <- Map 13 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 10 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Map 14 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_168]
+        Limit [LIM_167] (rows=100 width=492)
+          Number of rows:100
+          Select Operator [SEL_166] (rows=240 width=492)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_165]
+              Select Operator [SEL_164] (rows=240 width=492)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                PTF Operator [PTF_163] (rows=240 width=304)
+                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col2 DESC NULLS LAST","partition by:":"(grouping(_col3, 1) + grouping(_col3, 0)), CASE WHEN ((grouping(_col3, 0) = 0)) THEN (_col0) ELSE (CAST( null AS STRING)) END"}]
+                  Select Operator [SEL_162] (rows=240 width=304)
+                    Output:["_col0","_col1","_col2","_col3"]
+                  <-Reducer 5 [SIMPLE_EDGE] vectorized
+                    SHUFFLE [RS_161]
+                      PartitionCols:(grouping(_col3, 1) + grouping(_col3, 0)), CASE WHEN ((grouping(_col3, 0) = 0)) THEN (_col0) ELSE (CAST( null AS STRING)) END
+                      Select Operator [SEL_160] (rows=240 width=304)
+                        Output:["_col0","_col1","_col2","_col3"]
+                        Group By Operator [GBY_159] (rows=240 width=304)
+                          Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2
+                        <-Reducer 4 [SIMPLE_EDGE]
+                          SHUFFLE [RS_49]
+                            PartitionCols:_col0, _col1, _col2
+                            Group By Operator [GBY_48] (rows=18000 width=304)
+                              Output:["_col0","_col1","_col2","_col3"],aggregations:["sum(_col2)"],keys:_col0, _col1, 0L
+                              Select Operator [SEL_46] (rows=29778893 width=207)
+                                Output:["_col0","_col1","_col2"]
+                                Merge Join Operator [MERGEJOIN_134] (rows=29778893 width=207)
+                                  Conds:RS_43._col7=RS_158._col0(Inner),Output:["_col2","_col6","_col7"]
+                                <-Reducer 10 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_158]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_157] (rows=16 width=86)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_156] (rows=16 width=198)
+                                        predicate:(rank_window_0 <= 5)
+                                        PTF Operator [PTF_155] (rows=49 width=198)
+                                          Function definitions:[{},{"name:":"windowingtablefunction","order by:":"_col1 DESC NULLS LAST","partition by:":"_col0"}]
+                                          Select Operator [SEL_154] (rows=49 width=198)
+                                            Output:["_col0","_col1"]
+                                          <-Reducer 9 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_153]
+                                              PartitionCols:_col0
+                                              Group By Operator [GBY_152] (rows=49 width=198)
+                                                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                                              <-Reducer 8 [SIMPLE_EDGE]
+                                                SHUFFLE [RS_26]
+                                                  PartitionCols:_col0
+                                                  Group By Operator [GBY_25] (rows=1704 width=198)
+                                                    Output:["_col0","_col1"],aggregations:["sum(_col2)"],keys:_col5
+                                                    Merge Join Operator [MERGEJOIN_133] (rows=91197860 width=168)
+                                                      Conds:RS_21._col1=RS_151._col0(Inner),Output:["_col2","_col5"]
+                                                    <-Reducer 2 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_21]
+                                                        PartitionCols:_col1
+                                                        Merge Join Operator [MERGEJOIN_130] (rows=91197860 width=85)
+                                                          Conds:RS_145._col0=RS_137._col0(Inner),Output:["_col1","_col2"]
+                                                        <-Map 11 [SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_137]
+                                                            PartitionCols:_col0
+                                                            Select Operator [SEL_136] (rows=317 width=8)
+                                                              Output:["_col0"]
+                                                              Filter Operator [FIL_135] (rows=317 width=8)
+                                                                predicate:d_month_seq BETWEEN 1212 AND 1223
+                                                                TableScan [TS_3] (rows=73049 width=8)
+                                                                  default@date_dim,d1,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq"]
+                                                        <-Map 1 [SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_145]
+                                                            PartitionCols:_col0
+                                                            Select Operator [SEL_144] (rows=525329897 width=114)
+                                                              Output:["_col0","_col1","_col2"]
+                                                              Filter Operator [FIL_143] (rows=525329897 width=114)
+                                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_38_d1_d_date_sk_min) AND DynamicValue(RS_38_d1_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_38_d1_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                                TableScan [TS_0] (rows=575995635 width=114)
+                                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_store_sk","ss_net_profit"]
+                                                                <-Reducer 12 [BROADCAST_EDGE] vectorized
+                                                                  BROADCAST [RS_142]
+                                                                    Group By Operator [GBY_141] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                    <-Map 11 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                      SHUFFLE [RS_140]
+                                                                        Group By Operator [GBY_139] (rows=1 width=12)
+                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                          Select Operator [SEL_138] (rows=317 width=4)
+                                                                            Output:["_col0"]
+                                                                             Please refer to the previous Select Operator [SEL_136]
+                                                    <-Map 14 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_151]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_150] (rows=1704 width=90)
+                                                          Output:["_col0","_col1"]
+                                                          Filter Operator [FIL_149] (rows=1704 width=90)
+                                                            predicate:s_state is not null
+                                                            TableScan [TS_15] (rows=1704 width=90)
+                                                              default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_state"]
+                                <-Reducer 3 [SIMPLE_EDGE]
+                                  SHUFFLE [RS_43]
+                                    PartitionCols:_col7
+                                    Merge Join Operator [MERGEJOIN_131] (rows=91197860 width=266)
+                                      Conds:RS_40._col1=RS_148._col0(Inner),Output:["_col2","_col6","_col7"]
+                                    <-Reducer 2 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_40]
+                                        PartitionCols:_col1
+                                         Please refer to the previous Merge Join Operator [MERGEJOIN_130]
+                                    <-Map 13 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_148]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_147] (rows=1704 width=188)
+                                          Output:["_col0","_col1","_col2"]
+                                          Filter Operator [FIL_146] (rows=1704 width=188)
+                                            predicate:s_state is not null
+                                            TableScan [TS_6] (rows=1704 width=188)
+                                              default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_county","s_state"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query71.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query71.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query71.q.out
new file mode 100644
index 0000000..81f7961
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query71.q.out
@@ -0,0 +1,297 @@
+PREHOOK: query: explain
+select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
+ 	sum(ext_price) ext_price
+ from item, (select ws_ext_sales_price as ext_price, 
+                        ws_sold_date_sk as sold_date_sk,
+                        ws_item_sk as sold_item_sk,
+                        ws_sold_time_sk as time_sk  
+                 from web_sales,date_dim
+                 where d_date_sk = ws_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select cs_ext_sales_price as ext_price,
+                        cs_sold_date_sk as sold_date_sk,
+                        cs_item_sk as sold_item_sk,
+                        cs_sold_time_sk as time_sk
+                 from catalog_sales,date_dim
+                 where d_date_sk = cs_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select ss_ext_sales_price as ext_price,
+                        ss_sold_date_sk as sold_date_sk,
+                        ss_item_sk as sold_item_sk,
+                        ss_sold_time_sk as time_sk
+                 from store_sales,date_dim
+                 where d_date_sk = ss_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 ) as tmp,time_dim
+ where
+   sold_item_sk = i_item_sk
+   and i_manager_id=1
+   and time_sk = t_time_sk
+   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
+ group by i_brand, i_brand_id,t_hour,t_minute
+ order by ext_price desc, i_brand_id
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
+ 	sum(ext_price) ext_price
+ from item, (select ws_ext_sales_price as ext_price, 
+                        ws_sold_date_sk as sold_date_sk,
+                        ws_item_sk as sold_item_sk,
+                        ws_sold_time_sk as time_sk  
+                 from web_sales,date_dim
+                 where d_date_sk = ws_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select cs_ext_sales_price as ext_price,
+                        cs_sold_date_sk as sold_date_sk,
+                        cs_item_sk as sold_item_sk,
+                        cs_sold_time_sk as time_sk
+                 from catalog_sales,date_dim
+                 where d_date_sk = cs_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 union all
+                 select ss_ext_sales_price as ext_price,
+                        ss_sold_date_sk as sold_date_sk,
+                        ss_item_sk as sold_item_sk,
+                        ss_sold_time_sk as time_sk
+                 from store_sales,date_dim
+                 where d_date_sk = ss_sold_date_sk
+                   and d_moy=12
+                   and d_year=2001
+                 ) as tmp,time_dim
+ where
+   sold_item_sk = i_item_sk
+   and i_manager_id=1
+   and time_sk = t_time_sk
+   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
+ group by i_brand, i_brand_id,t_hour,t_minute
+ order by ext_price desc, i_brand_id
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 19 (BROADCAST_EDGE), Reducer 21 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Map 10 <- Reducer 13 (BROADCAST_EDGE), Reducer 19 (BROADCAST_EDGE), Reducer 21 (BROADCAST_EDGE)
+Map 14 <- Reducer 17 (BROADCAST_EDGE), Reducer 19 (BROADCAST_EDGE), Reducer 21 (BROADCAST_EDGE)
+Reducer 11 <- Map 10 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE), Union 3 (CONTAINS)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Map 16 (SIMPLE_EDGE), Union 3 (CONTAINS)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 19 <- Map 18 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 8 (SIMPLE_EDGE), Union 3 (CONTAINS)
+Reducer 21 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Map 18 (SIMPLE_EDGE), Union 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 20 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 9 <- Map 8 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:-1
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_188]
+        Select Operator [SEL_187] (rows=1991967 width=223)
+          Output:["_col0","_col1","_col2","_col3","_col4"]
+        <-Reducer 6 [SIMPLE_EDGE] vectorized
+          SHUFFLE [RS_186]
+            Select Operator [SEL_185] (rows=1991967 width=227)
+              Output:["_col1","_col2","_col3","_col4","_col5"]
+              Group By Operator [GBY_184] (rows=1991967 width=223)
+                Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3
+              <-Reducer 5 [SIMPLE_EDGE]
+                SHUFFLE [RS_46]
+                  PartitionCols:_col0, _col1, _col2, _col3
+                  Group By Operator [GBY_45] (rows=1991967 width=223)
+                    Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col0)"],keys:_col4, _col7, _col8, _col5
+                    Merge Join Operator [MERGEJOIN_140] (rows=1991967 width=112)
+                      Conds:RS_41._col2=RS_173._col0(Inner),Output:["_col0","_col4","_col5","_col7","_col8"]
+                    <-Map 20 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_173]
+                        PartitionCols:_col0
+                        Select Operator [SEL_172] (rows=43200 width=12)
+                          Output:["_col0","_col1","_col2"]
+                          Filter Operator [FIL_171] (rows=43200 width=99)
+                            predicate:(t_meal_time) IN ('breakfast', 'dinner')
+                            TableScan [TS_35] (rows=86400 width=99)
+                              default@time_dim,time_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["t_time_sk","t_hour","t_minute","t_meal_time"]
+                    <-Reducer 4 [SIMPLE_EDGE]
+                      SHUFFLE [RS_41]
+                        PartitionCols:_col2
+                        Merge Join Operator [MERGEJOIN_139] (rows=3983933 width=104)
+                          Conds:Union 3._col1=RS_163._col0(Inner),Output:["_col0","_col2","_col4","_col5"]
+                        <-Map 18 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_163]
+                            PartitionCols:_col0
+                            Select Operator [SEL_162] (rows=7333 width=107)
+                              Output:["_col0","_col1","_col2"]
+                              Filter Operator [FIL_161] (rows=7333 width=111)
+                                predicate:(i_manager_id = 1)
+                                TableScan [TS_32] (rows=462000 width=111)
+                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_brand_id","i_brand","i_manager_id"]
+                        <-Union 3 [SIMPLE_EDGE]
+                          <-Reducer 11 [CONTAINS]
+                            Reduce Output Operator [RS_148]
+                              PartitionCols:_col1
+                              Select Operator [SEL_146] (rows=7751851 width=98)
+                                Output:["_col0","_col1","_col2"]
+                                Merge Join Operator [MERGEJOIN_145] (rows=7751851 width=98)
+                                  Conds:RS_199._col0=RS_191._col0(Inner),Output:["_col1","_col2","_col3"]
+                                <-Map 12 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_191]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_190] (rows=50 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_189] (rows=50 width=12)
+                                        predicate:((d_moy = 12) and (d_year = 2001))
+                                        TableScan [TS_13] (rows=73049 width=12)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_199]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_198] (rows=285116947 width=123)
+                                      Output:["_col0","_col1","_col2","_col3"]
+                                      Filter Operator [FIL_197] (rows=285116947 width=123)
+                                        predicate:((cs_item_sk BETWEEN DynamicValue(RS_39_item_i_item_sk_min) AND DynamicValue(RS_39_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_39_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_17_date_dim_d_date_sk_min) AND DynamicValue(RS_17_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_17_date_dim_d_date_sk_bloom_filter))) and (cs_sold_time_sk BETWEEN DynamicValue(RS_42_time_dim_t_time_sk_min) AND DynamicValue(RS_42_time_dim_t_time_sk_max) and in_bloom_filter(cs_sold_time_sk, DynamicValue(RS_42_time_dim_t_time_sk_bloom_filter))) and cs_sold_date_sk is not null and cs_sold_time_sk is not null)
+                                        TableScan [TS_10] (rows=287989836 width=123)
+                                          default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_sold_time_sk","cs_item_sk","cs_ext_sales_price"]
+                                        <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_169]
+                                            Group By Operator [GBY_167] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 18 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_166]
+                                                Group By Operator [GBY_165] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_164] (rows=7333 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_162]
+                                        <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_179]
+                                            Group By Operator [GBY_177] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              SHUFFLE [RS_176]
+                                                Group By Operator [GBY_175] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_174] (rows=43200 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_172]
+                                        <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_196]
+                                            Group By Operator [GBY_195] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_194]
+                                                Group By Operator [GBY_193] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_192] (rows=50 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_190]
+                          <-Reducer 15 [CONTAINS]
+                            Reduce Output Operator [RS_152]
+                              PartitionCols:_col1
+                              Select Operator [SEL_150] (rows=14384397 width=4)
+                                Output:["_col0","_col1","_col2"]
+                                Merge Join Operator [MERGEJOIN_149] (rows=14384397 width=4)
+                                  Conds:RS_210._col0=RS_202._col0(Inner),Output:["_col1","_col2","_col3"]
+                                <-Map 16 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_202]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_201] (rows=50 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_200] (rows=50 width=12)
+                                        predicate:((d_moy = 12) and (d_year = 2001))
+                                        TableScan [TS_24] (rows=73049 width=12)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                <-Map 14 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_210]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_209] (rows=525325345 width=118)
+                                      Output:["_col0","_col1","_col2","_col3"]
+                                      Filter Operator [FIL_208] (rows=525325345 width=118)
+                                        predicate:((ss_item_sk BETWEEN DynamicValue(RS_39_item_i_item_sk_min) AND DynamicValue(RS_39_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_39_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_28_date_dim_d_date_sk_min) AND DynamicValue(RS_28_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_28_date_dim_d_date_sk_bloom_filter))) and (ss_sold_time_sk BETWEEN DynamicValue(RS_42_time_dim_t_time_sk_min) AND DynamicValue(RS_42_time_dim_t_time_sk_max) and in_bloom_filter(ss_sold_time_sk, DynamicValue(RS_42_time_dim_t_time_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_sold_time_sk is not null)
+                                        TableScan [TS_21] (rows=575995635 width=118)
+                                          default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_sold_time_sk","ss_item_sk","ss_ext_sales_price"]
+                                        <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_170]
+                                             Please refer to the previous Group By Operator [GBY_167]
+                                        <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_180]
+                                             Please refer to the previous Group By Operator [GBY_177]
+                                        <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_207]
+                                            Group By Operator [GBY_206] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_205]
+                                                Group By Operator [GBY_204] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_203] (rows=50 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_201]
+                          <-Reducer 2 [CONTAINS]
+                            Reduce Output Operator [RS_144]
+                              PartitionCols:_col1
+                              Select Operator [SEL_142] (rows=3941098 width=118)
+                                Output:["_col0","_col1","_col2"]
+                                Merge Join Operator [MERGEJOIN_141] (rows=3941098 width=118)
+                                  Conds:RS_183._col0=RS_155._col0(Inner),Output:["_col1","_col2","_col3"]
+                                <-Map 8 [SIMPLE_EDGE] vectorized
+                                  PARTITION_ONLY_SHUFFLE [RS_155]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_154] (rows=50 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_153] (rows=50 width=12)
+                                        predicate:((d_moy = 12) and (d_year = 2001))
+                                        TableScan [TS_3] (rows=73049 width=12)
+                                          default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_183]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_182] (rows=143930836 width=123)
+                                      Output:["_col0","_col1","_col2","_col3"]
+                                      Filter Operator [FIL_181] (rows=143930836 width=123)
+                                        predicate:((ws_item_sk BETWEEN DynamicValue(RS_39_item_i_item_sk_min) AND DynamicValue(RS_39_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_39_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_7_date_dim_d_date_sk_min) AND DynamicValue(RS_7_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_7_date_dim_d_date_sk_bloom_filter))) and (ws_sold_time_sk BETWEEN DynamicValue(RS_42_time_dim_t_time_sk_min) AND DynamicValue(RS_42_time_dim_t_time_sk_max) and in_bloom_filter(ws_sold_time_sk, DynamicValue(RS_42_time_dim_t_time_sk_bloom_filter))) and ws_sold_date_sk is not null and ws_sold_time_sk is not null)
+                                        TableScan [TS_0] (rows=144002668 width=123)
+                                          default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_sold_time_sk","ws_item_sk","ws_ext_sales_price"]
+                                        <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_168]
+                                             Please refer to the previous Group By Operator [GBY_167]
+                                        <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_178]
+                                             Please refer to the previous Group By Operator [GBY_177]
+                                        <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                          BROADCAST [RS_160]
+                                            Group By Operator [GBY_159] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                            <-Map 8 [CUSTOM_SIMPLE_EDGE] vectorized
+                                              PARTITION_ONLY_SHUFFLE [RS_158]
+                                                Group By Operator [GBY_157] (rows=1 width=12)
+                                                  Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                  Select Operator [SEL_156] (rows=50 width=4)
+                                                    Output:["_col0"]
+                                                     Please refer to the previous Select Operator [SEL_154]
+


[49/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query30.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query30.q b/ql/src/test/queries/clientpositive/perf/cbo_query30.q
new file mode 100644
index 0000000..ece6370
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query30.q
@@ -0,0 +1,33 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query30.tpl and seed 1819994127
+explain cbo
+with customer_total_return as
+ (select wr_returning_customer_sk as ctr_customer_sk
+        ,ca_state as ctr_state, 
+ 	sum(wr_return_amt) as ctr_total_return
+ from web_returns
+     ,date_dim
+     ,customer_address
+ where wr_returned_date_sk = d_date_sk 
+   and d_year =2002
+   and wr_returning_addr_sk = ca_address_sk 
+ group by wr_returning_customer_sk
+         ,ca_state)
+  select  c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+       ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+       ,c_last_review_date,ctr_total_return
+ from customer_total_return ctr1
+     ,customer_address
+     ,customer
+ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
+ 			  from customer_total_return ctr2 
+                  	  where ctr1.ctr_state = ctr2.ctr_state)
+       and ca_address_sk = c_current_addr_sk
+       and ca_state = 'IL'
+       and ctr1.ctr_customer_sk = c_customer_sk
+ order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
+                  ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
+                  ,c_last_review_date,ctr_total_return
+limit 100;
+
+-- end query 1 in stream 0 using template query30.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query31.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query31.q b/ql/src/test/queries/clientpositive/perf/cbo_query31.q
new file mode 100644
index 0000000..a2babbf
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query31.q
@@ -0,0 +1,54 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query31.tpl and seed 1819994127
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query31.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query32.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query32.q b/ql/src/test/queries/clientpositive/perf/cbo_query32.q
new file mode 100644
index 0000000..4f3c729
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query32.q
@@ -0,0 +1,30 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query32.tpl and seed 2031708268
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query32.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query33.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query33.q b/ql/src/test/queries/clientpositive/perf/cbo_query33.q
new file mode 100644
index 0000000..fc808ae
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query33.q
@@ -0,0 +1,77 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query33.tpl and seed 1930872976
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query33.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query34.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query34.q b/ql/src/test/queries/clientpositive/perf/cbo_query34.q
new file mode 100644
index 0000000..2b93a61
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query34.q
@@ -0,0 +1,33 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query34.tpl and seed 1971067816
+explain cbo
+select c_last_name
+       ,c_first_name
+       ,c_salutation
+       ,c_preferred_cust_flag
+       ,ss_ticket_number
+       ,cnt from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,count(*) cnt
+    from store_sales,date_dim,store,household_demographics
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
+    and (household_demographics.hd_buy_potential = '>10000' or
+         household_demographics.hd_buy_potential = 'unknown')
+    and household_demographics.hd_vehicle_count > 0
+    and (case when household_demographics.hd_vehicle_count > 0 
+	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
+	else null 
+	end)  > 1.2
+    and date_dim.d_year in (2000,2000+1,2000+2)
+    and store.s_county in ('Mobile County','Maverick County','Huron County','Kittitas County',
+                           'Fairfield County','Jackson County','Barrow County','Pennington County')
+    group by ss_ticket_number,ss_customer_sk) dn,customer
+    where ss_customer_sk = c_customer_sk
+      and cnt between 15 and 20
+    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc;
+
+-- end query 1 in stream 0 using template query34.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query35.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query35.q b/ql/src/test/queries/clientpositive/perf/cbo_query35.q
new file mode 100644
index 0000000..9e87780
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query35.q
@@ -0,0 +1,59 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query35.tpl and seed 1930872976
+explain cbo
+select   
+  ca_state,
+  cd_gender,
+  cd_marital_status,
+  count(*) cnt1,
+  avg(cd_dep_count),
+  max(cd_dep_count),
+  sum(cd_dep_count),
+  cd_dep_employed_count,
+  count(*) cnt2,
+  avg(cd_dep_employed_count),
+  max(cd_dep_employed_count),
+  sum(cd_dep_employed_count),
+  cd_dep_college_count,
+  count(*) cnt3,
+  avg(cd_dep_college_count),
+  max(cd_dep_college_count),
+  sum(cd_dep_college_count)
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_qoy < 4) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_qoy < 4))
+ group by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by ca_state,
+          cd_gender,
+          cd_marital_status,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ limit 100;
+
+-- end query 1 in stream 0 using template query35.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query36.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query36.q b/ql/src/test/queries/clientpositive/perf/cbo_query36.q
new file mode 100644
index 0000000..cab89de
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query36.q
@@ -0,0 +1,32 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query36.tpl and seed 1544728811
+explain cbo
+select  
+    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
+   ,i_category
+   ,i_class
+   ,grouping(i_category)+grouping(i_class) as lochierarchy
+   ,rank() over (
+ 	partition by grouping(i_category)+grouping(i_class),
+ 	case when grouping(i_class) = 0 then i_category end 
+ 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
+ from
+    store_sales
+   ,date_dim       d1
+   ,item
+   ,store
+ where
+    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 s_state in ('SD','FL','MI','LA',
+                 'MO','SC','AL','GA')
+ group by rollup(i_category,i_class)
+ order by
+   lochierarchy desc
+  ,case when lochierarchy = 0 then i_category end
+  ,rank_within_parent
+  limit 100;
+
+-- end query 1 in stream 0 using template query36.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query37.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query37.q b/ql/src/test/queries/clientpositive/perf/cbo_query37.q
new file mode 100644
index 0000000..f258dc0
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query37.q
@@ -0,0 +1,19 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query37.tpl and seed 301843662
+explain cbo
+select  i_item_id
+       ,i_item_desc
+       ,i_current_price
+ from item, inventory, date_dim, catalog_sales
+ where i_current_price between 22 and 22 + 30
+ and inv_item_sk = i_item_sk
+ and d_date_sk=inv_date_sk
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
+ and i_manufact_id in (678,964,918,849)
+ and inv_quantity_on_hand between 100 and 500
+ and cs_item_sk = i_item_sk
+ group by i_item_id,i_item_desc,i_current_price
+ order by i_item_id
+ limit 100;
+
+-- end query 1 in stream 0 using template query37.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query38.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query38.q b/ql/src/test/queries/clientpositive/perf/cbo_query38.q
new file mode 100644
index 0000000..55beed2
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query38.q
@@ -0,0 +1,25 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query38.tpl and seed 1819994127
+explain cbo
+select  count(*) from (
+    select distinct c_last_name, c_first_name, d_date
+    from store_sales, date_dim, customer
+          where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+      and store_sales.ss_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from catalog_sales, date_dim, customer
+          where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
+      and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+  intersect
+    select distinct c_last_name, c_first_name, d_date
+    from web_sales, date_dim, customer
+          where web_sales.ws_sold_date_sk = date_dim.d_date_sk
+      and web_sales.ws_bill_customer_sk = customer.c_customer_sk
+      and d_month_seq between 1212 and 1212 + 11
+) hot_cust
+limit 100;
+
+-- end query 1 in stream 0 using template query38.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query39.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query39.q b/ql/src/test/queries/clientpositive/perf/cbo_query39.q
new file mode 100644
index 0000000..1970c05
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query39.q
@@ -0,0 +1,56 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query39.tpl and seed 1327317894
+explain cbo
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+;
+with inv as
+(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+       ,stdev,mean, case mean when 0 then null else stdev/mean end cov
+ from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
+            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
+      from inventory
+          ,item
+          ,warehouse
+          ,date_dim
+      where inv_item_sk = i_item_sk
+        and inv_warehouse_sk = w_warehouse_sk
+        and inv_date_sk = d_date_sk
+        and d_year =1999
+      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
+ where case mean when 0 then 0 else stdev/mean end > 1)
+select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
+        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
+from inv inv1,inv inv2
+where inv1.i_item_sk = inv2.i_item_sk
+  and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
+  and inv1.d_moy=4
+  and inv2.d_moy=4+1
+  and inv1.cov > 1.5
+order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
+        ,inv2.d_moy,inv2.mean, inv2.cov
+;
+
+-- end query 1 in stream 0 using template query39.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query4.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query4.q b/ql/src/test/queries/clientpositive/perf/cbo_query4.q
new file mode 100644
index 0000000..b47d174
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query4.q
@@ -0,0 +1,111 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query4.tpl and seed 1819994127
+explain cbo
+with year_total as (
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
+       ,'s' sale_type
+ from customer
+     ,store_sales
+     ,date_dim
+ where c_customer_sk = ss_customer_sk
+   and ss_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+ union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
+       ,'c' sale_type
+ from customer
+     ,catalog_sales
+     ,date_dim
+ where c_customer_sk = cs_bill_customer_sk
+   and cs_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+union all
+ select c_customer_id customer_id
+       ,c_first_name customer_first_name
+       ,c_last_name customer_last_name
+       ,c_preferred_cust_flag customer_preferred_cust_flag
+       ,c_birth_country customer_birth_country
+       ,c_login customer_login
+       ,c_email_address customer_email_address
+       ,d_year dyear
+       ,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
+       ,'w' sale_type
+ from customer
+     ,web_sales
+     ,date_dim
+ where c_customer_sk = ws_bill_customer_sk
+   and ws_sold_date_sk = d_date_sk
+ group by c_customer_id
+         ,c_first_name
+         ,c_last_name
+         ,c_preferred_cust_flag
+         ,c_birth_country
+         ,c_login
+         ,c_email_address
+         ,d_year
+         )
+  select  t_s_secyear.customer_preferred_cust_flag
+ from year_total t_s_firstyear
+     ,year_total t_s_secyear
+     ,year_total t_c_firstyear
+     ,year_total t_c_secyear
+     ,year_total t_w_firstyear
+     ,year_total t_w_secyear
+ where t_s_secyear.customer_id = t_s_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_c_secyear.customer_id
+   and t_s_firstyear.customer_id = t_c_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_firstyear.customer_id
+   and t_s_firstyear.customer_id = t_w_secyear.customer_id
+   and t_s_firstyear.sale_type = 's'
+   and t_c_firstyear.sale_type = 'c'
+   and t_w_firstyear.sale_type = 'w'
+   and t_s_secyear.sale_type = 's'
+   and t_c_secyear.sale_type = 'c'
+   and t_w_secyear.sale_type = 'w'
+   and t_s_firstyear.dyear =  2001
+   and t_s_secyear.dyear = 2001+1
+   and t_c_firstyear.dyear =  2001
+   and t_c_secyear.dyear =  2001+1
+   and t_w_firstyear.dyear = 2001
+   and t_w_secyear.dyear = 2001+1
+   and t_s_firstyear.year_total > 0
+   and t_c_firstyear.year_total > 0
+   and t_w_firstyear.year_total > 0
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
+   and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
+           > case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
+ order by t_s_secyear.customer_preferred_cust_flag
+limit 100;
+
+-- end query 1 in stream 0 using template query4.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query40.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query40.q b/ql/src/test/queries/clientpositive/perf/cbo_query40.q
new file mode 100644
index 0000000..b54ae4b
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query40.q
@@ -0,0 +1,30 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query40.tpl and seed 1819994127
+explain cbo
+select  
+   w_state
+  ,i_item_id
+  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
+  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
+ 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
+ from
+   catalog_sales left outer join catalog_returns on
+       (cs_order_number = cr_order_number 
+        and cs_item_sk = cr_item_sk)
+  ,warehouse 
+  ,item
+  ,date_dim
+ where
+     i_current_price between 0.99 and 1.49
+ and i_item_sk          = cs_item_sk
+ and cs_warehouse_sk    = w_warehouse_sk 
+ and cs_sold_date_sk    = d_date_sk
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
+ group by
+    w_state,i_item_id
+ order by w_state,i_item_id
+limit 100;
+
+-- end query 1 in stream 0 using template query40.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query42.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query42.q b/ql/src/test/queries/clientpositive/perf/cbo_query42.q
new file mode 100644
index 0000000..43fb4ee
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query42.q
@@ -0,0 +1,24 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query42.tpl and seed 1819994127
+explain cbo
+select  dt.d_year
+ 	,item.i_category_id
+ 	,item.i_category
+ 	,sum(ss_ext_sales_price)
+ 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_manager_id = 1  	
+ 	and dt.d_moy=12
+ 	and dt.d_year=1998
+ group by 	dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
+ 		,item.i_category_id
+ 		,item.i_category
+limit 100 ;
+
+-- end query 1 in stream 0 using template query42.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query43.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query43.q b/ql/src/test/queries/clientpositive/perf/cbo_query43.q
new file mode 100644
index 0000000..e4aff11
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query43.q
@@ -0,0 +1,21 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query43.tpl and seed 1819994127
+explain cbo
+select  s_store_name, s_store_id,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from date_dim, store_sales, store
+ where d_date_sk = ss_sold_date_sk and
+       s_store_sk = ss_store_sk and
+       s_gmt_offset = -6 and
+       d_year = 1998 
+ group by s_store_name, s_store_id
+ order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
+ limit 100;
+
+-- end query 1 in stream 0 using template query43.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query44.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query44.q b/ql/src/test/queries/clientpositive/perf/cbo_query44.q
new file mode 100644
index 0000000..814a721
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query44.q
@@ -0,0 +1,37 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query44.tpl and seed 1819994127
+explain cbo
+select  asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
+from(select *
+     from (select item_sk,rank() over (order by rank_col asc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col 
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V1)V11
+     where rnk  < 11) asceding,
+    (select *
+     from (select item_sk,rank() over (order by rank_col desc) rnk
+           from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
+                 from store_sales ss1
+                 where ss_store_sk = 410
+                 group by ss_item_sk
+                 having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
+                                                  from store_sales
+                                                  where ss_store_sk = 410
+                                                    and ss_hdemo_sk is null
+                                                  group by ss_store_sk))V2)V21
+     where rnk  < 11) descending,
+item i1,
+item i2
+where asceding.rnk = descending.rnk 
+  and i1.i_item_sk=asceding.item_sk
+  and i2.i_item_sk=descending.item_sk
+order by asceding.rnk
+limit 100;
+
+-- end query 1 in stream 0 using template query44.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query45.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query45.q b/ql/src/test/queries/clientpositive/perf/cbo_query45.q
new file mode 100644
index 0000000..e1b4348
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query45.q
@@ -0,0 +1,22 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query45.tpl and seed 2031708268
+explain cbo
+select  ca_zip, ca_county, sum(ws_sales_price)
+ from web_sales, customer, customer_address, date_dim, item
+ where ws_bill_customer_sk = c_customer_sk
+ 	and c_current_addr_sk = ca_address_sk 
+ 	and ws_item_sk = i_item_sk 
+ 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
+ 	      or 
+ 	      i_item_id in (select i_item_id
+                             from item
+                             where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
+                             )
+ 	    )
+ 	and ws_sold_date_sk = d_date_sk
+ 	and d_qoy = 2 and d_year = 2000
+ group by ca_zip, ca_county
+ order by ca_zip, ca_county
+ limit 100;
+
+-- end query 1 in stream 0 using template query45.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query46.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query46.q b/ql/src/test/queries/clientpositive/perf/cbo_query46.q
new file mode 100644
index 0000000..6a7a94e
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query46.q
@@ -0,0 +1,37 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query46.tpl and seed 803547492
+explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,amt,profit 
+ from
+   (select ss_ticket_number
+          ,ss_customer_sk
+          ,ca_city bought_city
+          ,sum(ss_coupon_amt) amt
+          ,sum(ss_net_profit) profit
+    from store_sales,date_dim,store,household_demographics,customer_address 
+    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    and store_sales.ss_store_sk = store.s_store_sk  
+    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    and store_sales.ss_addr_sk = customer_address.ca_address_sk
+    and (household_demographics.hd_dep_count = 2 or
+         household_demographics.hd_vehicle_count= 1)
+    and date_dim.d_dow in (6,0)
+    and date_dim.d_year in (1998,1998+1,1998+2) 
+    and store.s_city in ('Cedar Grove','Wildwood','Union','Salem','Highland Park') 
+    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
+    where ss_customer_sk = c_customer_sk
+      and customer.c_current_addr_sk = current_addr.ca_address_sk
+      and current_addr.ca_city <> bought_city
+  order by c_last_name
+          ,c_first_name
+          ,ca_city
+          ,bought_city
+          ,ss_ticket_number
+  limit 100;
+
+-- end query 1 in stream 0 using template query46.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query47.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query47.q b/ql/src/test/queries/clientpositive/perf/cbo_query47.q
new file mode 100644
index 0000000..7348e4b
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query47.q
@@ -0,0 +1,53 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query47.tpl and seed 2031708268
+explain cbo
+with v1 as(
+ select i_category, i_brand,
+        s_store_name, s_company_name,
+        d_year, d_moy,
+        sum(ss_sales_price) sum_sales,
+        avg(sum(ss_sales_price)) over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     s_store_name, s_company_name
+           order by d_year, d_moy) rn
+ from item, store_sales, date_dim, store
+ where ss_item_sk = i_item_sk and
+       ss_sold_date_sk = d_date_sk and
+       ss_store_sk = s_store_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          s_store_name, s_company_name,
+          d_year, d_moy),
+ v2 as(
+ select v1.i_category
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1.s_store_name = v1_lag.s_store_name and
+       v1.s_store_name = v1_lead.s_store_name and
+       v1.s_company_name = v1_lag.s_company_name and
+       v1.s_company_name = v1_lead.s_company_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and    
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100;
+
+-- end query 1 in stream 0 using template query47.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query48.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query48.q b/ql/src/test/queries/clientpositive/perf/cbo_query48.q
new file mode 100644
index 0000000..21db45f
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query48.q
@@ -0,0 +1,69 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query48.tpl and seed 622697896
+explain cbo
+select sum (ss_quantity)
+ from store_sales, store, customer_demographics, customer_address, date_dim
+ where s_store_sk = ss_store_sk
+ and  ss_sold_date_sk = d_date_sk and d_year = 1998
+ and  
+ (
+  (
+   cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 100.00 and 150.00  
+   )
+ or
+  (
+  cd_demo_sk = ss_cdemo_sk
+   and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 50.00 and 100.00   
+  )
+ or 
+ (
+  cd_demo_sk = ss_cdemo_sk
+  and 
+   cd_marital_status = 'M'
+   and 
+   cd_education_status = '4 yr Degree'
+   and 
+   ss_sales_price between 150.00 and 200.00  
+ )
+ )
+ and
+ (
+  (
+  ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('KY', 'GA', 'NM')
+  and ss_net_profit between 0 and 2000  
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('MT', 'OR', 'IN')
+  and ss_net_profit between 150 and 3000 
+  )
+ or
+  (ss_addr_sk = ca_address_sk
+  and
+  ca_country = 'United States'
+  and
+  ca_state in ('WI', 'MO', 'WV')
+  and ss_net_profit between 50 and 25000 
+  )
+ )
+;
+
+-- end query 1 in stream 0 using template query48.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query49.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query49.q b/ql/src/test/queries/clientpositive/perf/cbo_query49.q
new file mode 100644
index 0000000..fccf25d
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query49.q
@@ -0,0 +1,129 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query49.tpl and seed 1819994127
+explain cbo
+select  
+ 'web' as channel
+ ,web.item
+ ,web.return_ratio
+ ,web.return_rank
+ ,web.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select ws.ws_item_sk as item
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		 web_sales ws left outer join web_returns wr 
+ 			on (ws.ws_order_number = wr.wr_order_number and 
+ 			ws.ws_item_sk = wr.wr_item_sk)
+                 ,date_dim
+ 		where 
+ 			wr.wr_return_amt > 10000 
+ 			and ws.ws_net_profit > 1
+                         and ws.ws_net_paid > 0
+                         and ws.ws_quantity > 0
+                         and ws_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by ws.ws_item_sk
+ 	) in_web
+ ) web
+ where 
+ (
+ web.return_rank <= 10
+ or
+ web.currency_rank <= 10
+ )
+ union
+ select 
+ 'catalog' as channel
+ ,catalog.item
+ ,catalog.return_ratio
+ ,catalog.return_rank
+ ,catalog.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select 
+ 		cs.cs_item_sk as item
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		catalog_sales cs left outer join catalog_returns cr
+ 			on (cs.cs_order_number = cr.cr_order_number and 
+ 			cs.cs_item_sk = cr.cr_item_sk)
+                ,date_dim
+ 		where 
+ 			cr.cr_return_amount > 10000 
+ 			and cs.cs_net_profit > 1
+                         and cs.cs_net_paid > 0
+                         and cs.cs_quantity > 0
+                         and cs_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+                 group by cs.cs_item_sk
+ 	) in_cat
+ ) catalog
+ where 
+ (
+ catalog.return_rank <= 10
+ or
+ catalog.currency_rank <=10
+ )
+ union
+ select 
+ 'store' as channel
+ ,store.item
+ ,store.return_ratio
+ ,store.return_rank
+ ,store.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select sts.ss_item_sk as item
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		store_sales sts left outer join store_returns sr
+ 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
+                ,date_dim
+ 		where 
+ 			sr.sr_return_amt > 10000 
+ 			and sts.ss_net_profit > 1
+                         and sts.ss_net_paid > 0 
+                         and sts.ss_quantity > 0
+                         and ss_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by sts.ss_item_sk
+ 	) in_store
+ ) store
+ where  (
+ store.return_rank <= 10
+ or 
+ store.currency_rank <= 10
+ )
+ order by 1,4,5
+ limit 100;
+
+-- end query 1 in stream 0 using template query49.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query5.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query5.q b/ql/src/test/queries/clientpositive/perf/cbo_query5.q
new file mode 100644
index 0000000..405b2da
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query5.q
@@ -0,0 +1,130 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query5.tpl and seed 1819994127
+explain cbo
+with ssr as
+ (select s_store_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ss_store_sk as store_sk,
+            ss_sold_date_sk  as date_sk,
+            ss_ext_sales_price as sales_price,
+            ss_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from store_sales
+    union all
+    select sr_store_sk as store_sk,
+           sr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           sr_return_amt as return_amt,
+           sr_net_loss as net_loss
+    from store_returns
+   ) salesreturns,
+     date_dim,
+     store
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  14 days)
+       and store_sk = s_store_sk
+ group by s_store_id)
+ ,
+ csr as
+ (select cp_catalog_page_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  cs_catalog_page_sk as page_sk,
+            cs_sold_date_sk  as date_sk,
+            cs_ext_sales_price as sales_price,
+            cs_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from catalog_sales
+    union all
+    select cr_catalog_page_sk as page_sk,
+           cr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           cr_return_amount as return_amt,
+           cr_net_loss as net_loss
+    from catalog_returns
+   ) salesreturns,
+     date_dim,
+     catalog_page
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and page_sk = cp_catalog_page_sk
+ group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select web_site_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ws_web_site_sk as wsr_web_site_sk,
+            ws_sold_date_sk  as date_sk,
+            ws_ext_sales_price as sales_price,
+            ws_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from web_sales
+    union all
+    select ws_web_site_sk as wsr_web_site_sk,
+           wr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           wr_return_amt as return_amt,
+           wr_net_loss as net_loss
+    from web_returns left outer join web_sales on
+         ( wr_item_sk = ws_item_sk
+           and wr_order_number = ws_order_number)
+   ) salesreturns,
+     date_dim,
+     web_site
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and wsr_web_site_sk = web_site_sk
+ group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || s_store_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || cp_catalog_page_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100;
+
+-- end query 1 in stream 0 using template query5.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query50.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query50.q b/ql/src/test/queries/clientpositive/perf/cbo_query50.q
new file mode 100644
index 0000000..1fb8051
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query50.q
@@ -0,0 +1,61 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query50.tpl and seed 1819994127
+explain cbo
+select  
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   store_sales
+  ,store_returns
+  ,store
+  ,date_dim d1
+  ,date_dim d2
+where
+    d2.d_year = 2000
+and d2.d_moy  = 9
+and ss_ticket_number = sr_ticket_number
+and ss_item_sk = sr_item_sk
+and ss_sold_date_sk   = d1.d_date_sk
+and sr_returned_date_sk   = d2.d_date_sk
+and ss_customer_sk = sr_customer_sk
+and ss_store_sk = s_store_sk
+group by
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+order by s_store_name
+        ,s_company_id
+        ,s_street_number
+        ,s_street_name
+        ,s_street_type
+        ,s_suite_number
+        ,s_city
+        ,s_county
+        ,s_state
+        ,s_zip
+limit 100;
+
+-- end query 1 in stream 0 using template query50.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query51.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query51.q b/ql/src/test/queries/clientpositive/perf/cbo_query51.q
new file mode 100644
index 0000000..16ba023
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query51.q
@@ -0,0 +1,47 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query51.tpl and seed 1819994127
+explain cbo
+WITH web_v1 as (
+select
+  ws_item_sk item_sk, d_date,
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from web_sales
+    ,date_dim
+where ws_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ws_item_sk is not NULL
+group by ws_item_sk, d_date),
+store_v1 as (
+select
+  ss_item_sk item_sk, d_date,
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
+from store_sales
+    ,date_dim
+where ss_sold_date_sk=d_date_sk
+  and d_month_seq between 1212 and 1212+11
+  and ss_item_sk is not NULL
+group by ss_item_sk, d_date)
+ select  *
+from (select item_sk
+     ,d_date
+     ,web_sales
+     ,store_sales
+     ,max(web_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
+     ,max(store_sales)
+         over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
+     from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
+                 ,case when web.d_date is not null then web.d_date else store.d_date end d_date
+                 ,web.cume_sales web_sales
+                 ,store.cume_sales store_sales
+           from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
+                                                          and web.d_date = store.d_date)
+          )x )y
+where web_cumulative > store_cumulative
+order by item_sk
+        ,d_date
+limit 100;
+
+-- end query 1 in stream 0 using template query51.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query52.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query52.q b/ql/src/test/queries/clientpositive/perf/cbo_query52.q
new file mode 100644
index 0000000..2225502
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query52.q
@@ -0,0 +1,24 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query52.tpl and seed 1819994127
+explain cbo
+select  dt.d_year
+ 	,item.i_brand_id brand_id
+ 	,item.i_brand brand
+ 	,sum(ss_ext_sales_price) ext_price
+ 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_manager_id = 1
+    and dt.d_moy=12
+    and dt.d_year=1998
+ group by dt.d_year
+ 	,item.i_brand
+ 	,item.i_brand_id
+ order by dt.d_year
+ 	,ext_price desc
+ 	,brand_id
+limit 100 ;
+
+-- end query 1 in stream 0 using template query52.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query53.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query53.q b/ql/src/test/queries/clientpositive/perf/cbo_query53.q
new file mode 100644
index 0000000..c0edd67
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query53.q
@@ -0,0 +1,30 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query53.tpl and seed 1819994127
+explain cbo
+select  * from 
+(select i_manufact_id,
+sum(ss_sales_price) sum_sales,
+avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
+from item, store_sales, date_dim, store
+where ss_item_sk = i_item_sk and
+ss_sold_date_sk = d_date_sk and
+ss_store_sk = s_store_sk and
+d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
+((i_category in ('Books','Children','Electronics') and
+i_class in ('personal','portable','reference','self-help') and
+i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		'exportiunivamalg #9','scholaramalgamalg #9'))
+or(i_category in ('Women','Music','Men') and
+i_class in ('accessories','classical','fragrances','pants') and
+i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		'importoamalg #1')))
+group by i_manufact_id, d_qoy ) tmp1
+where case when avg_quarterly_sales > 0 
+	then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales 
+	else null end > 0.1
+order by avg_quarterly_sales,
+	 sum_sales,
+	 i_manufact_id
+limit 100;
+
+-- end query 1 in stream 0 using template query53.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query54.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query54.q b/ql/src/test/queries/clientpositive/perf/cbo_query54.q
new file mode 100644
index 0000000..1e626c1
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query54.q
@@ -0,0 +1,58 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query54.tpl and seed 1930872976
+explain cbo
+with my_customers as (
+ select distinct c_customer_sk
+        , c_current_addr_sk
+ from   
+        ( select cs_sold_date_sk sold_date_sk,
+                 cs_bill_customer_sk customer_sk,
+                 cs_item_sk item_sk
+          from   catalog_sales
+          union all
+          select ws_sold_date_sk sold_date_sk,
+                 ws_bill_customer_sk customer_sk,
+                 ws_item_sk item_sk
+          from   web_sales
+         ) cs_or_ws_sales,
+         item,
+         date_dim,
+         customer
+ where   sold_date_sk = d_date_sk
+         and item_sk = i_item_sk
+         and i_category = 'Jewelry'
+         and i_class = 'consignment'
+         and c_customer_sk = cs_or_ws_sales.customer_sk
+         and d_moy = 3
+         and d_year = 1999
+ )
+ , my_revenue as (
+ select c_customer_sk,
+        sum(ss_ext_sales_price) as revenue
+ from   my_customers,
+        store_sales,
+        customer_address,
+        store,
+        date_dim
+ where  c_current_addr_sk = ca_address_sk
+        and ca_county = s_county
+        and ca_state = s_state
+        and ss_sold_date_sk = d_date_sk
+        and c_customer_sk = ss_customer_sk
+        and d_month_seq between (select distinct d_month_seq+1
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+                           and  (select distinct d_month_seq+3
+                                 from   date_dim where d_year = 1999 and d_moy = 3)
+ group by c_customer_sk
+ )
+ , segments as
+ (select cast((revenue/50) as int) as segment
+  from   my_revenue
+ )
+  select  segment, count(*) as num_customers, segment*50 as segment_base
+ from segments
+ group by segment
+ order by segment, num_customers
+ limit 100;
+
+-- end query 1 in stream 0 using template query54.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query55.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query55.q b/ql/src/test/queries/clientpositive/perf/cbo_query55.q
new file mode 100644
index 0000000..55176b2
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query55.q
@@ -0,0 +1,16 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query55.tpl and seed 2031708268
+explain cbo
+select  i_brand_id brand_id, i_brand brand,
+ 	sum(ss_ext_sales_price) ext_price
+ from date_dim, store_sales, item
+ where d_date_sk = ss_sold_date_sk
+ 	and ss_item_sk = i_item_sk
+ 	and i_manager_id=36
+ 	and d_moy=12
+ 	and d_year=2001
+ group by i_brand, i_brand_id
+ order by ext_price desc, i_brand_id
+limit 100 ;
+
+-- end query 1 in stream 0 using template query55.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query56.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query56.q b/ql/src/test/queries/clientpositive/perf/cbo_query56.q
new file mode 100644
index 0000000..15dbc10
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query56.q
@@ -0,0 +1,70 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query56.tpl and seed 1951559352
+explain cbo
+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;
+
+-- end query 1 in stream 0 using template query56.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query57.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query57.q b/ql/src/test/queries/clientpositive/perf/cbo_query57.q
new file mode 100644
index 0000000..da23fd2
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query57.q
@@ -0,0 +1,50 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query57.tpl and seed 2031708268
+explain cbo
+with v1 as(
+ select i_category, i_brand,
+        cc_name,
+        d_year, d_moy,
+        sum(cs_sales_price) sum_sales,
+        avg(sum(cs_sales_price)) over
+          (partition by i_category, i_brand,
+                     cc_name, d_year)
+          avg_monthly_sales,
+        rank() over
+          (partition by i_category, i_brand,
+                     cc_name
+           order by d_year, d_moy) rn
+ from item, catalog_sales, date_dim, call_center
+ where cs_item_sk = i_item_sk and
+       cs_sold_date_sk = d_date_sk and
+       cc_call_center_sk= cs_call_center_sk and
+       (
+         d_year = 2000 or
+         ( d_year = 2000-1 and d_moy =12) or
+         ( d_year = 2000+1 and d_moy =1)
+       )
+ group by i_category, i_brand,
+          cc_name , d_year, d_moy),
+ v2 as(
+ select v1.i_category, v1.i_brand
+        ,v1.d_year, v1.d_moy
+        ,v1.avg_monthly_sales
+        ,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
+ from v1, v1 v1_lag, v1 v1_lead
+ where v1.i_category = v1_lag.i_category and
+       v1.i_category = v1_lead.i_category and
+       v1.i_brand = v1_lag.i_brand and
+       v1.i_brand = v1_lead.i_brand and
+       v1. cc_name = v1_lag. cc_name and
+       v1. cc_name = v1_lead. cc_name and
+       v1.rn = v1_lag.rn + 1 and
+       v1.rn = v1_lead.rn - 1)
+  select  *
+ from v2
+ where  d_year = 2000 and
+        avg_monthly_sales > 0 and
+        case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+ order by sum_sales - avg_monthly_sales, 3
+ limit 100;
+
+-- end query 1 in stream 0 using template query57.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query58.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query58.q b/ql/src/test/queries/clientpositive/perf/cbo_query58.q
new file mode 100644
index 0000000..bbc1b96
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query58.q
@@ -0,0 +1,67 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query58.tpl and seed 1819994127
+explain cbo
+with ss_items as
+ (select i_item_id item_id
+        ,sum(ss_ext_sales_price) ss_item_rev 
+ from store_sales
+     ,item
+     ,date_dim
+ where ss_item_sk = i_item_sk
+   and d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+   and ss_sold_date_sk   = d_date_sk
+ group by i_item_id),
+ cs_items as
+ (select i_item_id item_id
+        ,sum(cs_ext_sales_price) cs_item_rev
+  from catalog_sales
+      ,item
+      ,date_dim
+ where cs_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq = (select d_week_seq 
+                                      from date_dim
+                                      where d_date = '1998-02-19'))
+  and  cs_sold_date_sk = d_date_sk
+ group by i_item_id),
+ ws_items as
+ (select i_item_id item_id
+        ,sum(ws_ext_sales_price) ws_item_rev
+  from web_sales
+      ,item
+      ,date_dim
+ where ws_item_sk = i_item_sk
+  and  d_date in (select d_date
+                  from date_dim
+                  where d_week_seq =(select d_week_seq 
+                                     from date_dim
+                                     where d_date = '1998-02-19'))
+  and ws_sold_date_sk   = d_date_sk
+ group by i_item_id)
+  select  ss_items.item_id
+       ,ss_item_rev
+       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
+       ,cs_item_rev
+       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
+       ,ws_item_rev
+       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
+       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
+ from ss_items,cs_items,ws_items
+ where ss_items.item_id=cs_items.item_id
+   and ss_items.item_id=ws_items.item_id 
+   and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
+   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
+   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
+ order by item_id
+         ,ss_item_rev
+ limit 100;
+
+-- end query 1 in stream 0 using template query58.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query59.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query59.q b/ql/src/test/queries/clientpositive/perf/cbo_query59.q
new file mode 100644
index 0000000..9517f71
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query59.q
@@ -0,0 +1,46 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query59.tpl and seed 1819994127
+explain cbo
+with wss as 
+ (select d_week_seq,
+        ss_store_sk,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from store_sales,date_dim
+ where d_date_sk = ss_sold_date_sk
+ group by d_week_seq,ss_store_sk
+ )
+  select  s_store_name1,s_store_id1,d_week_seq1
+       ,sun_sales1/sun_sales2,mon_sales1/mon_sales2
+       ,tue_sales1/tue_sales1,wed_sales1/wed_sales2,thu_sales1/thu_sales2
+       ,fri_sales1/fri_sales2,sat_sales1/sat_sales2
+ from
+ (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
+        ,s_store_id s_store_id1,sun_sales sun_sales1
+        ,mon_sales mon_sales1,tue_sales tue_sales1
+        ,wed_sales wed_sales1,thu_sales thu_sales1
+        ,fri_sales fri_sales1,sat_sales sat_sales1
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185 and 1185 + 11) y,
+ (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
+        ,s_store_id s_store_id2,sun_sales sun_sales2
+        ,mon_sales mon_sales2,tue_sales tue_sales2
+        ,wed_sales wed_sales2,thu_sales thu_sales2
+        ,fri_sales fri_sales2,sat_sales sat_sales2
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185+ 12 and 1185 + 23) x
+ where s_store_id1=s_store_id2
+   and d_week_seq1=d_week_seq2-52
+ order by s_store_name1,s_store_id1,d_week_seq1
+limit 100;
+
+-- end query 1 in stream 0 using template query59.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query6.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query6.q b/ql/src/test/queries/clientpositive/perf/cbo_query6.q
new file mode 100644
index 0000000..d9ed084
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query6.q
@@ -0,0 +1,30 @@
+set hive.auto.convert.join=true;
+set hive.tez.cartesian-product.enabled=true;
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query6.tpl and seed 1819994127
+explain cbo
+select  a.ca_state state, count(*) cnt
+ from customer_address a
+     ,customer c
+     ,store_sales s
+     ,date_dim d
+     ,item i
+ where       a.ca_address_sk = c.c_current_addr_sk
+ 	and c.c_customer_sk = s.ss_customer_sk
+ 	and s.ss_sold_date_sk = d.d_date_sk
+ 	and s.ss_item_sk = i.i_item_sk
+ 	and d.d_month_seq = 
+ 	     (select distinct (d_month_seq)
+ 	      from date_dim
+               where d_year = 2000
+ 	        and d_moy = 2 )
+ 	and i.i_current_price > 1.2 * 
+             (select avg(j.i_current_price) 
+ 	     from item j 
+ 	     where j.i_category = i.i_category)
+ group by a.ca_state
+ having count(*) >= 10
+ order by cnt 
+ limit 100;
+
+-- end query 1 in stream 0 using template query6.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query60.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query60.q b/ql/src/test/queries/clientpositive/perf/cbo_query60.q
new file mode 100644
index 0000000..71c3349
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query60.q
@@ -0,0 +1,80 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query60.tpl and seed 1930872976
+explain cbo
+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_category in ('Children'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ 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 i_item_id
+      ,total_sales
+ limit 100;
+
+-- end query 1 in stream 0 using template query60.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query61.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query61.q b/ql/src/test/queries/clientpositive/perf/cbo_query61.q
new file mode 100644
index 0000000..83c95bf
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query61.q
@@ -0,0 +1,46 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query61.tpl and seed 1930872976
+explain cbo
+select  promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
+from
+  (select sum(ss_ext_sales_price) promotions
+   from  store_sales
+        ,store
+        ,promotion
+        ,date_dim
+        ,customer
+        ,customer_address 
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_promo_sk = p_promo_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk 
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) promotional_sales,
+  (select sum(ss_ext_sales_price) total
+   from  store_sales
+        ,store
+        ,date_dim
+        ,customer
+        ,customer_address
+        ,item
+   where ss_sold_date_sk = d_date_sk
+   and   ss_store_sk = s_store_sk
+   and   ss_customer_sk= c_customer_sk
+   and   ca_address_sk = c_current_addr_sk
+   and   ss_item_sk = i_item_sk
+   and   ca_gmt_offset = -7
+   and   i_category = 'Electronics'
+   and   s_gmt_offset = -7
+   and   d_year = 1999
+   and   d_moy  = 11) all_sales
+order by promotions, total
+limit 100;
+
+-- end query 1 in stream 0 using template query61.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query63.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query63.q b/ql/src/test/queries/clientpositive/perf/cbo_query63.q
new file mode 100644
index 0000000..0553f4c
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query63.q
@@ -0,0 +1,31 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query63.tpl and seed 1819994127
+explain cbo
+select  * 
+from (select i_manager_id
+             ,sum(ss_sales_price) sum_sales
+             ,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
+      from item
+          ,store_sales
+          ,date_dim
+          ,store
+      where ss_item_sk = i_item_sk
+        and ss_sold_date_sk = d_date_sk
+        and ss_store_sk = s_store_sk
+        and d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11)
+        and ((    i_category in ('Books','Children','Electronics')
+              and i_class in ('personal','portable','refernece','self-help')
+              and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
+		                  'exportiunivamalg #9','scholaramalgamalg #9'))
+           or(    i_category in ('Women','Music','Men')
+              and i_class in ('accessories','classical','fragrances','pants')
+              and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
+		                 'importoamalg #1')))
+group by i_manager_id, d_moy) tmp1
+where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
+order by i_manager_id
+        ,avg_monthly_sales
+        ,sum_sales
+limit 100;
+
+-- end query 1 in stream 0 using template query63.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query64.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query64.q b/ql/src/test/queries/clientpositive/perf/cbo_query64.q
new file mode 100644
index 0000000..24f3d85
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query64.q
@@ -0,0 +1,121 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query64.tpl and seed 1220860970
+explain cbo
+with cs_ui as
+ (select cs_item_sk
+        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
+  from catalog_sales
+      ,catalog_returns
+  where cs_item_sk = cr_item_sk
+    and cs_order_number = cr_order_number
+  group by cs_item_sk
+  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
+cross_sales as
+ (select i_product_name product_name
+     ,i_item_sk item_sk
+     ,s_store_name store_name
+     ,s_zip store_zip
+     ,ad1.ca_street_number b_street_number
+     ,ad1.ca_street_name b_streen_name
+     ,ad1.ca_city b_city
+     ,ad1.ca_zip b_zip
+     ,ad2.ca_street_number c_street_number
+     ,ad2.ca_street_name c_street_name
+     ,ad2.ca_city c_city
+     ,ad2.ca_zip c_zip
+     ,d1.d_year as syear
+     ,d2.d_year as fsyear
+     ,d3.d_year s2year
+     ,count(*) cnt
+     ,sum(ss_wholesale_cost) s1
+     ,sum(ss_list_price) s2
+     ,sum(ss_coupon_amt) s3
+  FROM   store_sales
+        ,store_returns
+        ,cs_ui
+        ,date_dim d1
+        ,date_dim d2
+        ,date_dim d3
+        ,store
+        ,customer
+        ,customer_demographics cd1
+        ,customer_demographics cd2
+        ,promotion
+        ,household_demographics hd1
+        ,household_demographics hd2
+        ,customer_address ad1
+        ,customer_address ad2
+        ,income_band ib1
+        ,income_band ib2
+        ,item
+  WHERE  ss_store_sk = s_store_sk AND
+         ss_sold_date_sk = d1.d_date_sk AND
+         ss_customer_sk = c_customer_sk AND
+         ss_cdemo_sk= cd1.cd_demo_sk AND
+         ss_hdemo_sk = hd1.hd_demo_sk AND
+         ss_addr_sk = ad1.ca_address_sk and
+         ss_item_sk = i_item_sk and
+         ss_item_sk = sr_item_sk and
+         ss_ticket_number = sr_ticket_number and
+         ss_item_sk = cs_ui.cs_item_sk and
+         c_current_cdemo_sk = cd2.cd_demo_sk AND
+         c_current_hdemo_sk = hd2.hd_demo_sk AND
+         c_current_addr_sk = ad2.ca_address_sk and
+         c_first_sales_date_sk = d2.d_date_sk and
+         c_first_shipto_date_sk = d3.d_date_sk and
+         ss_promo_sk = p_promo_sk and
+         hd1.hd_income_band_sk = ib1.ib_income_band_sk and
+         hd2.hd_income_band_sk = ib2.ib_income_band_sk and
+         cd1.cd_marital_status <> cd2.cd_marital_status and
+         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
+         i_current_price between 35 and 35 + 10 and
+         i_current_price between 35 + 1 and 35 + 15
+group by i_product_name
+       ,i_item_sk
+       ,s_store_name
+       ,s_zip
+       ,ad1.ca_street_number
+       ,ad1.ca_street_name
+       ,ad1.ca_city
+       ,ad1.ca_zip
+       ,ad2.ca_street_number
+       ,ad2.ca_street_name
+       ,ad2.ca_city
+       ,ad2.ca_zip
+       ,d1.d_year
+       ,d2.d_year
+       ,d3.d_year
+)
+select cs1.product_name
+     ,cs1.store_name
+     ,cs1.store_zip
+     ,cs1.b_street_number
+     ,cs1.b_streen_name
+     ,cs1.b_city
+     ,cs1.b_zip
+     ,cs1.c_street_number
+     ,cs1.c_street_name
+     ,cs1.c_city
+     ,cs1.c_zip
+     ,cs1.syear
+     ,cs1.cnt
+     ,cs1.s1
+     ,cs1.s2
+     ,cs1.s3
+     ,cs2.s1
+     ,cs2.s2
+     ,cs2.s3
+     ,cs2.syear
+     ,cs2.cnt
+from cross_sales cs1,cross_sales cs2
+where cs1.item_sk=cs2.item_sk and
+     cs1.syear = 2000 and
+     cs2.syear = 2000 + 1 and
+     cs2.cnt <= cs1.cnt and
+     cs1.store_name = cs2.store_name and
+     cs1.store_zip = cs2.store_zip
+order by cs1.product_name
+       ,cs1.store_name
+       ,cs2.cnt;
+
+-- end query 1 in stream 0 using template query64.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query65.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query65.q b/ql/src/test/queries/clientpositive/perf/cbo_query65.q
new file mode 100644
index 0000000..e8b752d
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query65.q
@@ -0,0 +1,31 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query65.tpl and seed 1819994127
+explain cbo
+select 
+	s_store_name,
+	i_item_desc,
+	sc.revenue,
+	i_current_price,
+	i_wholesale_cost,
+	i_brand
+ from store, item,
+     (select ss_store_sk, avg(revenue) as ave
+ 	from
+ 	    (select  ss_store_sk, ss_item_sk, 
+ 		     sum(ss_sales_price) as revenue
+ 		from store_sales, date_dim
+ 		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 		group by ss_store_sk, ss_item_sk) sa
+ 	group by ss_store_sk) sb,
+     (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
+ 	from store_sales, date_dim
+ 	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 	group by ss_store_sk, ss_item_sk) sc
+ where sb.ss_store_sk = sc.ss_store_sk and 
+       sc.revenue <= 0.1 * sb.ave and
+       s_store_sk = sc.ss_store_sk and
+       i_item_sk = sc.ss_item_sk
+ order by s_store_name, i_item_desc
+limit 100;
+
+-- end query 1 in stream 0 using template query65.tpl

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/queries/clientpositive/perf/cbo_query66.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/perf/cbo_query66.q b/ql/src/test/queries/clientpositive/perf/cbo_query66.q
new file mode 100644
index 0000000..5182935
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/perf/cbo_query66.q
@@ -0,0 +1,224 @@
+set hive.mapred.mode=nonstrict;
+-- start query 1 in stream 0 using template query66.tpl and seed 2042478054
+explain cbo
+select   
+         w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+        ,ship_carriers
+        ,year
+ 	,sum(jan_sales) as jan_sales
+ 	,sum(feb_sales) as feb_sales
+ 	,sum(mar_sales) as mar_sales
+ 	,sum(apr_sales) as apr_sales
+ 	,sum(may_sales) as may_sales
+ 	,sum(jun_sales) as jun_sales
+ 	,sum(jul_sales) as jul_sales
+ 	,sum(aug_sales) as aug_sales
+ 	,sum(sep_sales) as sep_sales
+ 	,sum(oct_sales) as oct_sales
+ 	,sum(nov_sales) as nov_sales
+ 	,sum(dec_sales) as dec_sales
+ 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
+ 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
+ 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
+ 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
+ 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
+ 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
+ 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
+ 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
+ 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
+ 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
+ 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
+ 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
+ 	,sum(jan_net) as jan_net
+ 	,sum(feb_net) as feb_net
+ 	,sum(mar_net) as mar_net
+ 	,sum(apr_net) as apr_net
+ 	,sum(may_net) as may_net
+ 	,sum(jun_net) as jun_net
+ 	,sum(jul_net) as jul_net
+ 	,sum(aug_net) as aug_net
+ 	,sum(sep_net) as sep_net
+ 	,sum(oct_net) as oct_net
+ 	,sum(nov_net) as nov_net
+ 	,sum(dec_net) as dec_net
+ from (
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then ws_sales_price* ws_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
+     from
+          web_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	  ,ship_mode
+     where
+            ws_warehouse_sk =  w_warehouse_sk
+        and ws_sold_date_sk = d_date_sk
+        and ws_sold_time_sk = t_time_sk
+ 	and ws_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 and 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+ 	)
+ union all
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
+     from
+          catalog_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	 ,ship_mode
+     where
+            cs_warehouse_sk =  w_warehouse_sk
+        and cs_sold_date_sk = d_date_sk
+        and cs_sold_time_sk = t_time_sk
+ 	and cs_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 AND 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+     ) 
+ ) x
+ group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,ship_carriers
+       ,year
+ order by w_warehouse_name
+ limit 100;
+
+-- end query 1 in stream 0 using template query66.tpl


[41/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out
new file mode 100644
index 0000000..3b59bd8
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query64.q.out
@@ -0,0 +1,438 @@
+PREHOOK: query: explain cbo
+with cs_ui as
+ (select cs_item_sk
+        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
+  from catalog_sales
+      ,catalog_returns
+  where cs_item_sk = cr_item_sk
+    and cs_order_number = cr_order_number
+  group by cs_item_sk
+  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
+cross_sales as
+ (select i_product_name product_name
+     ,i_item_sk item_sk
+     ,s_store_name store_name
+     ,s_zip store_zip
+     ,ad1.ca_street_number b_street_number
+     ,ad1.ca_street_name b_streen_name
+     ,ad1.ca_city b_city
+     ,ad1.ca_zip b_zip
+     ,ad2.ca_street_number c_street_number
+     ,ad2.ca_street_name c_street_name
+     ,ad2.ca_city c_city
+     ,ad2.ca_zip c_zip
+     ,d1.d_year as syear
+     ,d2.d_year as fsyear
+     ,d3.d_year s2year
+     ,count(*) cnt
+     ,sum(ss_wholesale_cost) s1
+     ,sum(ss_list_price) s2
+     ,sum(ss_coupon_amt) s3
+  FROM   store_sales
+        ,store_returns
+        ,cs_ui
+        ,date_dim d1
+        ,date_dim d2
+        ,date_dim d3
+        ,store
+        ,customer
+        ,customer_demographics cd1
+        ,customer_demographics cd2
+        ,promotion
+        ,household_demographics hd1
+        ,household_demographics hd2
+        ,customer_address ad1
+        ,customer_address ad2
+        ,income_band ib1
+        ,income_band ib2
+        ,item
+  WHERE  ss_store_sk = s_store_sk AND
+         ss_sold_date_sk = d1.d_date_sk AND
+         ss_customer_sk = c_customer_sk AND
+         ss_cdemo_sk= cd1.cd_demo_sk AND
+         ss_hdemo_sk = hd1.hd_demo_sk AND
+         ss_addr_sk = ad1.ca_address_sk and
+         ss_item_sk = i_item_sk and
+         ss_item_sk = sr_item_sk and
+         ss_ticket_number = sr_ticket_number and
+         ss_item_sk = cs_ui.cs_item_sk and
+         c_current_cdemo_sk = cd2.cd_demo_sk AND
+         c_current_hdemo_sk = hd2.hd_demo_sk AND
+         c_current_addr_sk = ad2.ca_address_sk and
+         c_first_sales_date_sk = d2.d_date_sk and
+         c_first_shipto_date_sk = d3.d_date_sk and
+         ss_promo_sk = p_promo_sk and
+         hd1.hd_income_band_sk = ib1.ib_income_band_sk and
+         hd2.hd_income_band_sk = ib2.ib_income_band_sk and
+         cd1.cd_marital_status <> cd2.cd_marital_status and
+         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
+         i_current_price between 35 and 35 + 10 and
+         i_current_price between 35 + 1 and 35 + 15
+group by i_product_name
+       ,i_item_sk
+       ,s_store_name
+       ,s_zip
+       ,ad1.ca_street_number
+       ,ad1.ca_street_name
+       ,ad1.ca_city
+       ,ad1.ca_zip
+       ,ad2.ca_street_number
+       ,ad2.ca_street_name
+       ,ad2.ca_city
+       ,ad2.ca_zip
+       ,d1.d_year
+       ,d2.d_year
+       ,d3.d_year
+)
+select cs1.product_name
+     ,cs1.store_name
+     ,cs1.store_zip
+     ,cs1.b_street_number
+     ,cs1.b_streen_name
+     ,cs1.b_city
+     ,cs1.b_zip
+     ,cs1.c_street_number
+     ,cs1.c_street_name
+     ,cs1.c_city
+     ,cs1.c_zip
+     ,cs1.syear
+     ,cs1.cnt
+     ,cs1.s1
+     ,cs1.s2
+     ,cs1.s3
+     ,cs2.s1
+     ,cs2.s2
+     ,cs2.s3
+     ,cs2.syear
+     ,cs2.cnt
+from cross_sales cs1,cross_sales cs2
+where cs1.item_sk=cs2.item_sk and
+     cs1.syear = 2000 and
+     cs2.syear = 2000 + 1 and
+     cs2.cnt <= cs1.cnt and
+     cs1.store_name = cs2.store_name and
+     cs1.store_zip = cs2.store_zip
+order by cs1.product_name
+       ,cs1.store_name
+       ,cs2.cnt
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@income_band
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+with cs_ui as
+ (select cs_item_sk
+        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
+  from catalog_sales
+      ,catalog_returns
+  where cs_item_sk = cr_item_sk
+    and cs_order_number = cr_order_number
+  group by cs_item_sk
+  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
+cross_sales as
+ (select i_product_name product_name
+     ,i_item_sk item_sk
+     ,s_store_name store_name
+     ,s_zip store_zip
+     ,ad1.ca_street_number b_street_number
+     ,ad1.ca_street_name b_streen_name
+     ,ad1.ca_city b_city
+     ,ad1.ca_zip b_zip
+     ,ad2.ca_street_number c_street_number
+     ,ad2.ca_street_name c_street_name
+     ,ad2.ca_city c_city
+     ,ad2.ca_zip c_zip
+     ,d1.d_year as syear
+     ,d2.d_year as fsyear
+     ,d3.d_year s2year
+     ,count(*) cnt
+     ,sum(ss_wholesale_cost) s1
+     ,sum(ss_list_price) s2
+     ,sum(ss_coupon_amt) s3
+  FROM   store_sales
+        ,store_returns
+        ,cs_ui
+        ,date_dim d1
+        ,date_dim d2
+        ,date_dim d3
+        ,store
+        ,customer
+        ,customer_demographics cd1
+        ,customer_demographics cd2
+        ,promotion
+        ,household_demographics hd1
+        ,household_demographics hd2
+        ,customer_address ad1
+        ,customer_address ad2
+        ,income_band ib1
+        ,income_band ib2
+        ,item
+  WHERE  ss_store_sk = s_store_sk AND
+         ss_sold_date_sk = d1.d_date_sk AND
+         ss_customer_sk = c_customer_sk AND
+         ss_cdemo_sk= cd1.cd_demo_sk AND
+         ss_hdemo_sk = hd1.hd_demo_sk AND
+         ss_addr_sk = ad1.ca_address_sk and
+         ss_item_sk = i_item_sk and
+         ss_item_sk = sr_item_sk and
+         ss_ticket_number = sr_ticket_number and
+         ss_item_sk = cs_ui.cs_item_sk and
+         c_current_cdemo_sk = cd2.cd_demo_sk AND
+         c_current_hdemo_sk = hd2.hd_demo_sk AND
+         c_current_addr_sk = ad2.ca_address_sk and
+         c_first_sales_date_sk = d2.d_date_sk and
+         c_first_shipto_date_sk = d3.d_date_sk and
+         ss_promo_sk = p_promo_sk and
+         hd1.hd_income_band_sk = ib1.ib_income_band_sk and
+         hd2.hd_income_band_sk = ib2.ib_income_band_sk and
+         cd1.cd_marital_status <> cd2.cd_marital_status and
+         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
+         i_current_price between 35 and 35 + 10 and
+         i_current_price between 35 + 1 and 35 + 15
+group by i_product_name
+       ,i_item_sk
+       ,s_store_name
+       ,s_zip
+       ,ad1.ca_street_number
+       ,ad1.ca_street_name
+       ,ad1.ca_city
+       ,ad1.ca_zip
+       ,ad2.ca_street_number
+       ,ad2.ca_street_name
+       ,ad2.ca_city
+       ,ad2.ca_zip
+       ,d1.d_year
+       ,d2.d_year
+       ,d3.d_year
+)
+select cs1.product_name
+     ,cs1.store_name
+     ,cs1.store_zip
+     ,cs1.b_street_number
+     ,cs1.b_streen_name
+     ,cs1.b_city
+     ,cs1.b_zip
+     ,cs1.c_street_number
+     ,cs1.c_street_name
+     ,cs1.c_city
+     ,cs1.c_zip
+     ,cs1.syear
+     ,cs1.cnt
+     ,cs1.s1
+     ,cs1.s2
+     ,cs1.s3
+     ,cs2.s1
+     ,cs2.s2
+     ,cs2.s3
+     ,cs2.syear
+     ,cs2.cnt
+from cross_sales cs1,cross_sales cs2
+where cs1.item_sk=cs2.item_sk and
+     cs1.syear = 2000 and
+     cs2.syear = 2000 + 1 and
+     cs2.cnt <= cs1.cnt and
+     cs1.store_name = cs2.store_name and
+     cs1.store_zip = cs2.store_zip
+order by cs1.product_name
+       ,cs1.store_name
+       ,cs2.cnt
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@income_band
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(product_name=[$0], store_name=[$1], store_zip=[$2], b_street_number=[$3], b_streen_name=[$4], b_city=[$5], b_zip=[$6], c_street_number=[$7], c_street_name=[$8], c_city=[$9], c_zip=[$10], syear=[CAST(2000):INTEGER], cnt=[$11], s1=[$12], s2=[$13], s3=[$14], s11=[$15], s21=[$16], s31=[$17], syear1=[CAST(2001):INTEGER], cnt1=[$18])
+  HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$18], dir0=[ASC], dir1=[ASC], dir2=[ASC])
+    HiveProject(product_name=[$0], store_name=[$2], store_zip=[$3], b_street_number=[$4], b_streen_name=[$5], b_city=[$6], b_zip=[$7], c_street_number=[$8], c_street_name=[$9], c_city=[$10], c_zip=[$11], cnt=[$12], s1=[$13], s2=[$14], s3=[$15], s11=[$20], s21=[$21], s31=[$22], cnt1=[$19])
+      HiveJoin(condition=[AND(AND(AND(=($1, $16), <=($19, $12)), =($2, $17)), =($3, $18))], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject($f0=[$13], $f1=[$12], $f2=[$10], $f3=[$11], $f4=[$6], $f5=[$7], $f6=[$8], $f7=[$9], $f8=[$2], $f9=[$3], $f10=[$4], $f11=[$5], $f15=[$14], $f16=[$15], $f17=[$16], $f18=[$17])
+          HiveAggregate(group=[{9, 11, 16, 17, 18, 19, 25, 26, 27, 28, 30, 31, 48, 51}], agg#0=[count()], agg#1=[sum($45)], agg#2=[sum($46)], agg#3=[sum($47)])
+            HiveJoin(condition=[AND(<>($1, $21), =($39, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+              HiveJoin(condition=[=($36, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $18)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($3, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($4, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($5, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4], c_first_shipto_date_sk=[$5], c_first_sales_date_sk=[$6])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($5), IS NOT NULL($2), IS NOT NULL($3), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveProject(d_date_sk=[$0], d_year=[$6])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                        HiveProject(d_date_sk=[$0], d_year=[$6])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                      HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1], ib_income_band_sk=[$2])
+                        HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[hd2])
+                          HiveProject(ib_income_band_sk=[$0])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, income_band]], table:alias=[ib2])
+                    HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[ad2])
+                  HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+                HiveProject(sr_item_sk=[$0], sr_ticket_number=[$1], ca_address_sk=[$2], ca_street_number=[$3], ca_street_name=[$4], ca_city=[$5], ca_zip=[$6], s_store_sk=[$7], s_store_name=[$8], s_zip=[$9], hd_demo_sk=[$10], hd_income_band_sk=[$11], ib_income_band_sk=[$12], p_promo_sk=[$13], ss_sold_date_sk=[$14], ss_item_sk=[$15], ss_customer_sk=[$16], ss_cdemo_sk=[$17], ss_hdemo_sk=[$18], ss_addr_sk=[$19], ss_store_sk=[$20], ss_promo_sk=[$21], ss_ticket_number=[$22], ss_wholesale_cost=[$23], ss_list_price=[$24], ss_coupon_amt=[$25], i_item_sk=[$26], i_current_price=[$27], i_color=[$28], i_product_name=[$29], d_date_sk=[$30], d_year=[$31], $f0=[$32], $f1=[$33], $f2=[$34])
+                  HiveJoin(condition=[AND(=($15, $0), =($22, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($9))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveJoin(condition=[=($17, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[ad1])
+                      HiveJoin(condition=[=($13, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(s_store_sk=[$0], s_store_name=[$5], s_zip=[$25])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($5), IS NOT NULL($25))])
+                            HiveTableScan(table=[[default, store]], table:alias=[store])
+                        HiveJoin(condition=[=($5, $22)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1])
+                                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                                  HiveTableScan(table=[[default, household_demographics]], table:alias=[hd1])
+                              HiveProject(ib_income_band_sk=[$0])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, income_band]], table:alias=[ib1])
+                            HiveProject(p_promo_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_customer_sk=[$3], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ticket_number=[$9], ss_wholesale_cost=[$10], ss_list_price=[$11], ss_coupon_amt=[$12], i_item_sk=[$13], i_current_price=[$14], i_color=[$15], i_product_name=[$16], d_date_sk=[$17], d_year=[$18])
+                              HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(p_promo_sk=[$0])
+                                  HiveFilter(condition=[IS NOT NULL($0)])
+                                    HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+                                HiveJoin(condition=[=($0, $16)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($1, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ticket_number=[$9], ss_wholesale_cost=[$11], ss_list_price=[$12], ss_coupon_amt=[$19])
+                                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3), IS NOT NULL($4), IS NOT NULL($8), IS NOT NULL($5), IS NOT NULL($6))])
+                                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                    HiveProject(i_item_sk=[$0], i_current_price=[$5], i_color=[$17], i_product_name=[$21])
+                                      HiveFilter(condition=[AND(IN($17, _UTF-16LE'maroon', _UTF-16LE'burnished', _UTF-16LE'dim', _UTF-16LE'steel', _UTF-16LE'navajo', _UTF-16LE'chocolate'), BETWEEN(false, $5, 35, 45), BETWEEN(false, $5, 36, 50), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                                  HiveProject(d_date_sk=[$0], d_year=[CAST(2000):INTEGER])
+                                    HiveFilter(condition=[AND(=($6, 2000), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                          HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                            HiveFilter(condition=[>($1, *(2, $2))])
+                              HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
+                                HiveProject($f0=[$0], $f1=[$2], $f2=[+(+($5, $6), $7)])
+                                  HiveJoin(condition=[AND(=($0, $3), =($1, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_item_sk=[$15], cs_order_number=[$17], cs_ext_list_price=[$25])
+                                      HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($17))])
+                                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_refunded_cash=[$23], cr_reversed_charge=[$24], cr_store_credit=[$25])
+                                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($16))])
+                                        HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+        HiveProject($f1=[$12], $f2=[$10], $f3=[$11], $f15=[$14], $f16=[$15], $f17=[$16], $f18=[$17])
+          HiveAggregate(group=[{9, 11, 16, 17, 18, 19, 25, 26, 27, 28, 30, 31, 48, 51}], agg#0=[count()], agg#1=[sum($45)], agg#2=[sum($46)], agg#3=[sum($47)])
+            HiveJoin(condition=[AND(<>($1, $21), =($39, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                HiveFilter(condition=[IS NOT NULL($0)])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd1])
+              HiveJoin(condition=[=($36, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($1, $18)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($3, $13)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($4, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($5, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_hdemo_sk=[$3], c_current_addr_sk=[$4], c_first_shipto_date_sk=[$5], c_first_sales_date_sk=[$6])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($6), IS NOT NULL($5), IS NOT NULL($2), IS NOT NULL($3), IS NOT NULL($4))])
+                              HiveTableScan(table=[[default, customer]], table:alias=[customer])
+                          HiveProject(d_date_sk=[$0], d_year=[$6])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, date_dim]], table:alias=[d2])
+                        HiveProject(d_date_sk=[$0], d_year=[$6])
+                          HiveFilter(condition=[IS NOT NULL($0)])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[d3])
+                      HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1], ib_income_band_sk=[$2])
+                        HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1])
+                            HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                              HiveTableScan(table=[[default, household_demographics]], table:alias=[hd2])
+                          HiveProject(ib_income_band_sk=[$0])
+                            HiveFilter(condition=[IS NOT NULL($0)])
+                              HiveTableScan(table=[[default, income_band]], table:alias=[ib2])
+                    HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, customer_address]], table:alias=[ad2])
+                  HiveProject(cd_demo_sk=[$0], cd_marital_status=[$2])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, customer_demographics]], table:alias=[cd2])
+                HiveProject(sr_item_sk=[$0], sr_ticket_number=[$1], ca_address_sk=[$2], ca_street_number=[$3], ca_street_name=[$4], ca_city=[$5], ca_zip=[$6], s_store_sk=[$7], s_store_name=[$8], s_zip=[$9], hd_demo_sk=[$10], hd_income_band_sk=[$11], ib_income_band_sk=[$12], p_promo_sk=[$13], ss_sold_date_sk=[$14], ss_item_sk=[$15], ss_customer_sk=[$16], ss_cdemo_sk=[$17], ss_hdemo_sk=[$18], ss_addr_sk=[$19], ss_store_sk=[$20], ss_promo_sk=[$21], ss_ticket_number=[$22], ss_wholesale_cost=[$23], ss_list_price=[$24], ss_coupon_amt=[$25], i_item_sk=[$26], i_current_price=[$27], i_color=[$28], i_product_name=[$29], d_date_sk=[$30], d_year=[$31], $f0=[$32], $f1=[$33], $f2=[$34])
+                  HiveJoin(condition=[AND(=($15, $0), =($22, $1))], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(sr_item_sk=[$2], sr_ticket_number=[$9])
+                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($9))])
+                        HiveTableScan(table=[[default, store_returns]], table:alias=[store_returns])
+                    HiveJoin(condition=[=($17, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ca_address_sk=[$0], ca_street_number=[$2], ca_street_name=[$3], ca_city=[$6], ca_zip=[$9])
+                        HiveFilter(condition=[IS NOT NULL($0)])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[ad1])
+                      HiveJoin(condition=[=($13, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveProject(s_store_sk=[$0], s_store_name=[$5], s_zip=[$25])
+                          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($5), IS NOT NULL($25))])
+                            HiveTableScan(table=[[default, store]], table:alias=[store])
+                        HiveJoin(condition=[=($5, $22)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                            HiveJoin(condition=[=($1, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                              HiveProject(hd_demo_sk=[$0], hd_income_band_sk=[$1])
+                                HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
+                                  HiveTableScan(table=[[default, household_demographics]], table:alias=[hd1])
+                              HiveProject(ib_income_band_sk=[$0])
+                                HiveFilter(condition=[IS NOT NULL($0)])
+                                  HiveTableScan(table=[[default, income_band]], table:alias=[ib1])
+                            HiveProject(p_promo_sk=[$0], ss_sold_date_sk=[$1], ss_item_sk=[$2], ss_customer_sk=[$3], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ticket_number=[$9], ss_wholesale_cost=[$10], ss_list_price=[$11], ss_coupon_amt=[$12], i_item_sk=[$13], i_current_price=[$14], i_color=[$15], i_product_name=[$16], d_date_sk=[$17], d_year=[$18])
+                              HiveJoin(condition=[=($8, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                                HiveProject(p_promo_sk=[$0])
+                                  HiveFilter(condition=[IS NOT NULL($0)])
+                                    HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+                                HiveJoin(condition=[=($0, $16)], joinType=[inner], algorithm=[none], cost=[not available])
+                                  HiveJoin(condition=[=($1, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_customer_sk=[$3], ss_cdemo_sk=[$4], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_promo_sk=[$8], ss_ticket_number=[$9], ss_wholesale_cost=[$11], ss_list_price=[$12], ss_coupon_amt=[$19])
+                                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($9), IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($3), IS NOT NULL($4), IS NOT NULL($8), IS NOT NULL($5), IS NOT NULL($6))])
+                                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                                    HiveProject(i_item_sk=[$0], i_current_price=[$5], i_color=[$17], i_product_name=[$21])
+                                      HiveFilter(condition=[AND(IN($17, _UTF-16LE'maroon', _UTF-16LE'burnished', _UTF-16LE'dim', _UTF-16LE'steel', _UTF-16LE'navajo', _UTF-16LE'chocolate'), BETWEEN(false, $5, 35, 45), BETWEEN(false, $5, 36, 50), IS NOT NULL($0))])
+                                        HiveTableScan(table=[[default, item]], table:alias=[item])
+                                  HiveProject(d_date_sk=[$0], d_year=[CAST(2001):INTEGER])
+                                    HiveFilter(condition=[AND(=($6, 2001), IS NOT NULL($0))])
+                                      HiveTableScan(table=[[default, date_dim]], table:alias=[d1])
+                          HiveProject($f0=[$0], $f1=[$1], $f2=[$2])
+                            HiveFilter(condition=[>($1, *(2, $2))])
+                              HiveAggregate(group=[{0}], agg#0=[sum($1)], agg#1=[sum($2)])
+                                HiveProject($f0=[$0], $f1=[$2], $f2=[+(+($5, $6), $7)])
+                                  HiveJoin(condition=[AND(=($0, $3), =($1, $4))], joinType=[inner], algorithm=[none], cost=[not available])
+                                    HiveProject(cs_item_sk=[$15], cs_order_number=[$17], cs_ext_list_price=[$25])
+                                      HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($17))])
+                                        HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                                    HiveProject(cr_item_sk=[$2], cr_order_number=[$16], cr_refunded_cash=[$23], cr_reversed_charge=[$24], cr_store_credit=[$25])
+                                      HiveFilter(condition=[AND(IS NOT NULL($2), IS NOT NULL($16))])
+                                        HiveTableScan(table=[[default, catalog_returns]], table:alias=[catalog_returns])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out
new file mode 100644
index 0000000..1b154a4
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query65.q.out
@@ -0,0 +1,99 @@
+PREHOOK: query: explain cbo
+select 
+	s_store_name,
+	i_item_desc,
+	sc.revenue,
+	i_current_price,
+	i_wholesale_cost,
+	i_brand
+ from store, item,
+     (select ss_store_sk, avg(revenue) as ave
+ 	from
+ 	    (select  ss_store_sk, ss_item_sk, 
+ 		     sum(ss_sales_price) as revenue
+ 		from store_sales, date_dim
+ 		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 		group by ss_store_sk, ss_item_sk) sa
+ 	group by ss_store_sk) sb,
+     (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
+ 	from store_sales, date_dim
+ 	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 	group by ss_store_sk, ss_item_sk) sc
+ where sb.ss_store_sk = sc.ss_store_sk and 
+       sc.revenue <= 0.1 * sb.ave and
+       s_store_sk = sc.ss_store_sk and
+       i_item_sk = sc.ss_item_sk
+ order by s_store_name, i_item_desc
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select 
+	s_store_name,
+	i_item_desc,
+	sc.revenue,
+	i_current_price,
+	i_wholesale_cost,
+	i_brand
+ from store, item,
+     (select ss_store_sk, avg(revenue) as ave
+ 	from
+ 	    (select  ss_store_sk, ss_item_sk, 
+ 		     sum(ss_sales_price) as revenue
+ 		from store_sales, date_dim
+ 		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 		group by ss_store_sk, ss_item_sk) sa
+ 	group by ss_store_sk) sb,
+     (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
+ 	from store_sales, date_dim
+ 	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
+ 	group by ss_store_sk, ss_item_sk) sc
+ where sb.ss_store_sk = sc.ss_store_sk and 
+       sc.revenue <= 0.1 * sb.ave and
+       s_store_sk = sc.ss_store_sk and
+       i_item_sk = sc.ss_item_sk
+ order by s_store_name, i_item_desc
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(s_store_name=[$11], i_item_desc=[$1], revenue=[$7], i_current_price=[$2], i_wholesale_cost=[$3], i_brand=[$4])
+    HiveJoin(condition=[=($0, $6)], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveProject(i_item_sk=[$0], i_item_desc=[$4], i_current_price=[$5], i_wholesale_cost=[$6], i_brand=[$8])
+        HiveFilter(condition=[IS NOT NULL($0)])
+          HiveTableScan(table=[[default, item]], table:alias=[item])
+      HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveJoin(condition=[AND(=($3, $0), <=($2, *(0.1, $4)))], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveProject(ss_store_sk=[$1], ss_item_sk=[$0], $f2=[$2])
+            HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+              HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                  HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($2))])
+                    HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                  HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject($f0=[$0], $f1=[/($1, $2)])
+            HiveAggregate(group=[{1}], agg#0=[sum($2)], agg#1=[count($2)])
+              HiveProject(ss_item_sk=[$0], ss_store_sk=[$1], $f2=[$2])
+                HiveAggregate(group=[{1, 2}], agg#0=[sum($3)])
+                  HiveJoin(condition=[=($0, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_month_seq=[$3])
+                      HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+        HiveProject(s_store_sk=[$0], s_store_name=[$5])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
new file mode 100644
index 0000000..d97f351
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query66.q.out
@@ -0,0 +1,508 @@
+PREHOOK: query: explain cbo
+select   
+         w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+        ,ship_carriers
+        ,year
+ 	,sum(jan_sales) as jan_sales
+ 	,sum(feb_sales) as feb_sales
+ 	,sum(mar_sales) as mar_sales
+ 	,sum(apr_sales) as apr_sales
+ 	,sum(may_sales) as may_sales
+ 	,sum(jun_sales) as jun_sales
+ 	,sum(jul_sales) as jul_sales
+ 	,sum(aug_sales) as aug_sales
+ 	,sum(sep_sales) as sep_sales
+ 	,sum(oct_sales) as oct_sales
+ 	,sum(nov_sales) as nov_sales
+ 	,sum(dec_sales) as dec_sales
+ 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
+ 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
+ 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
+ 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
+ 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
+ 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
+ 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
+ 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
+ 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
+ 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
+ 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
+ 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
+ 	,sum(jan_net) as jan_net
+ 	,sum(feb_net) as feb_net
+ 	,sum(mar_net) as mar_net
+ 	,sum(apr_net) as apr_net
+ 	,sum(may_net) as may_net
+ 	,sum(jun_net) as jun_net
+ 	,sum(jul_net) as jul_net
+ 	,sum(aug_net) as aug_net
+ 	,sum(sep_net) as sep_net
+ 	,sum(oct_net) as oct_net
+ 	,sum(nov_net) as nov_net
+ 	,sum(dec_net) as dec_net
+ from (
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then ws_sales_price* ws_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
+     from
+          web_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	  ,ship_mode
+     where
+            ws_warehouse_sk =  w_warehouse_sk
+        and ws_sold_date_sk = d_date_sk
+        and ws_sold_time_sk = t_time_sk
+ 	and ws_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 and 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+ 	)
+ union all
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
+     from
+          catalog_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	 ,ship_mode
+     where
+            cs_warehouse_sk =  w_warehouse_sk
+        and cs_sold_date_sk = d_date_sk
+        and cs_sold_time_sk = t_time_sk
+ 	and cs_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 AND 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+     ) 
+ ) x
+ group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,ship_carriers
+       ,year
+ order by w_warehouse_name
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@ship_mode
+PREHOOK: Input: default@time_dim
+PREHOOK: Input: default@warehouse
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select   
+         w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+        ,ship_carriers
+        ,year
+ 	,sum(jan_sales) as jan_sales
+ 	,sum(feb_sales) as feb_sales
+ 	,sum(mar_sales) as mar_sales
+ 	,sum(apr_sales) as apr_sales
+ 	,sum(may_sales) as may_sales
+ 	,sum(jun_sales) as jun_sales
+ 	,sum(jul_sales) as jul_sales
+ 	,sum(aug_sales) as aug_sales
+ 	,sum(sep_sales) as sep_sales
+ 	,sum(oct_sales) as oct_sales
+ 	,sum(nov_sales) as nov_sales
+ 	,sum(dec_sales) as dec_sales
+ 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
+ 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
+ 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
+ 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
+ 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
+ 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
+ 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
+ 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
+ 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
+ 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
+ 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
+ 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
+ 	,sum(jan_net) as jan_net
+ 	,sum(feb_net) as feb_net
+ 	,sum(mar_net) as mar_net
+ 	,sum(apr_net) as apr_net
+ 	,sum(may_net) as may_net
+ 	,sum(jun_net) as jun_net
+ 	,sum(jul_net) as jul_net
+ 	,sum(aug_net) as aug_net
+ 	,sum(sep_net) as sep_net
+ 	,sum(oct_net) as oct_net
+ 	,sum(nov_net) as nov_net
+ 	,sum(dec_net) as dec_net
+ from (
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then ws_sales_price* ws_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
+     from
+          web_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	  ,ship_mode
+     where
+            ws_warehouse_sk =  w_warehouse_sk
+        and ws_sold_date_sk = d_date_sk
+        and ws_sold_time_sk = t_time_sk
+ 	and ws_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 and 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+ 	)
+ union all
+    (select 
+ 	w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers
+       ,d_year as year
+ 	,sum(case when d_moy = 1 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
+ 	,sum(case when d_moy = 2 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
+ 	,sum(case when d_moy = 3 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
+ 	,sum(case when d_moy = 4 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
+ 	,sum(case when d_moy = 5 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
+ 	,sum(case when d_moy = 6 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
+ 	,sum(case when d_moy = 7 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
+ 	,sum(case when d_moy = 8 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
+ 	,sum(case when d_moy = 9 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
+ 	,sum(case when d_moy = 10 
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
+ 	,sum(case when d_moy = 11
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
+ 	,sum(case when d_moy = 12
+ 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
+ 	,sum(case when d_moy = 1 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
+ 	,sum(case when d_moy = 2 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
+ 	,sum(case when d_moy = 3 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
+ 	,sum(case when d_moy = 4 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
+ 	,sum(case when d_moy = 5 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
+ 	,sum(case when d_moy = 6 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
+ 	,sum(case when d_moy = 7 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
+ 	,sum(case when d_moy = 8 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
+ 	,sum(case when d_moy = 9 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
+ 	,sum(case when d_moy = 10 
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
+ 	,sum(case when d_moy = 11
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
+ 	,sum(case when d_moy = 12
+ 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
+     from
+          catalog_sales
+         ,warehouse
+         ,date_dim
+         ,time_dim
+ 	 ,ship_mode
+     where
+            cs_warehouse_sk =  w_warehouse_sk
+        and cs_sold_date_sk = d_date_sk
+        and cs_sold_time_sk = t_time_sk
+ 	and cs_ship_mode_sk = sm_ship_mode_sk
+        and d_year = 2002
+ 	and t_time between 49530 AND 49530+28800 
+ 	and sm_carrier in ('DIAMOND','AIRBORNE')
+     group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+       ,d_year
+     ) 
+ ) x
+ group by 
+        w_warehouse_name
+ 	,w_warehouse_sq_ft
+ 	,w_city
+ 	,w_county
+ 	,w_state
+ 	,w_country
+ 	,ship_carriers
+       ,year
+ order by w_warehouse_name
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@ship_mode
+POSTHOOK: Input: default@time_dim
+POSTHOOK: Input: default@warehouse
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveProject(w_warehouse_name=[$0], w_warehouse_sq_ft=[$1], w_city=[$2], w_county=[$3], w_state=[$4], w_country=[$5], ship_carriers=[CAST(_UTF-16LE'DIAMOND,AIRBORNE'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], year=[CAST(2002):INTEGER], jan_sales=[$6], feb_sales=[$7], mar_sales=[$8], apr_sales=[$9], may_sales=[$10], jun_sales=[$11], jul_sales=[$12], aug_sales=[$13], sep_sales=[$14], oct_sales=[$15], nov_sales=[$16], dec_sales=[$17], jan_sales_per_sq_foot=[$18], feb_sales_per_sq_foot=[$19], mar_sales_per_sq_foot=[$20], apr_sales_per_sq_foot=[$21], may_sales_per_sq_foot=[$22], jun_sales_per_sq_foot=[$23], jul_sales_per_sq_foot=[$24], aug_sales_per_sq_foot=[$25], sep_sales_per_sq_foot=[$26], oct_sales_per_sq_foot=[$27], nov_sales_per_sq_foot=[$28], dec_sales_per_sq_foot=[$29], jan_net=[$30], feb_net=[$31], mar_net=[$32], apr_net=[$33], may_net=[$34], jun_net=[$35], jul_net=[$36], aug_net=[$37], sep_net=[$38], oct_net=[$39], nov_net=[$40], dec_net=[
 $41])
+  HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+    HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29], $f30=[$30], $f31=[$31], $f32=[$32], $f33=[$33], $f34=[$34], $f35=[$35], $f36=[$36], $f37=[$37], $f38=[$38], $f39=[$39], $f40=[$40], $f41=[$41])
+      HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)], agg#24=[sum($30)], agg#25=[sum($31)], agg#26=[sum($32)], agg#27=[sum($33)], agg#28=[sum($34)], agg#29=[sum($35)], agg#30=[sum($36)], agg#31=[sum($37)], agg#32=[sum($38)], agg#33=[sum($39)], agg#34=[sum($40)], agg#35=[sum($41)])
+        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f8=[$6], $f9=[$7], $f10=[$8], $f11=[$9], $f12=[$10], $f13=[$11], $f14=[$12], $f15=[$13], $f16=[$14], $f17=[$15], $f18=[$16], $f19=[$17], $f20=[/($6, CAST($1):DECIMAL(10, 0))], $f21=[/($7, CAST($1):DECIMAL(10, 0))], $f22=[/($8, CAST($1):DECIMAL(10, 0))], $f23=[/($9, CAST($1):DECIMAL(10, 0))], $f24=[/($10, CAST($1):DECIMAL(10, 0))], $f25=[/($11, CAST($1):DECIMAL(10, 0))], $f26=[/($12, CAST($1):DECIMAL(10, 0))], $f27=[/($13, CAST($1):DECIMAL(10, 0))], $f28=[/($14, CAST($1):DECIMAL(10, 0))], $f29=[/($15, CAST($1):DECIMAL(10, 0))], $f30=[/($16, CAST($1):DECIMAL(10, 0))], $f31=[/($17, CAST($1):DECIMAL(10, 0))], $f32=[$18], $f33=[$19], $f34=[$20], $f35=[$21], $f36=[$22], $f37=[$23], $f38=[$24], $f39=[$25], $f40=[$26], $f41=[$27], $f42=[$28], $f43=[$29])
+          HiveUnion(all=[true])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
+                HiveProject($f0=[$1], $f1=[$2], $f2=[$3], $f3=[$4], $f4=[$5], $f5=[$6], $f7=[CASE(=($18, 1), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f8=[CASE(=($18, 2), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f9=[CASE(=($18, 3), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f10=[CASE(=($18, 4), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f11=[CASE(=($18, 5), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f12=[CASE(=($18, 6), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f13=[CASE(=($18, 7), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f14=[CASE(=($18, 8), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f15=[CASE(=($18, 9), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f16=[CASE(=($18, 10), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f17=[CASE(=($18, 11), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f18=[CASE(=($18, 12), *($12, CAST($11):DECIMAL(10, 0)), 0)], $f19=[CASE(=($18, 1), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f20=[CASE(=($18, 2), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f21=[CASE(=($18, 3), *($13, CAST($11):DECIMAL(10, 0)),
  0)], $f22=[CASE(=($18, 4), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f23=[CASE(=($18, 5), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f24=[CASE(=($18, 6), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f25=[CASE(=($18, 7), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f26=[CASE(=($18, 8), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f27=[CASE(=($18, 9), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f28=[CASE(=($18, 10), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f29=[CASE(=($18, 11), *($13, CAST($11):DECIMAL(10, 0)), 0)], $f30=[CASE(=($18, 12), *($13, CAST($11):DECIMAL(10, 0)), 0)])
+                  HiveJoin(condition=[=($10, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2], w_warehouse_sq_ft=[$3], w_city=[$8], w_county=[$9], w_state=[$10], w_country=[$12])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+                    HiveJoin(condition=[=($2, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(ws_sold_date_sk=[$0], ws_sold_time_sk=[$1], ws_ship_mode_sk=[$14], ws_warehouse_sk=[$15], ws_quantity=[$18], ws_sales_price=[$21], ws_net_paid_inc_tax=[$30])
+                            HiveFilter(condition=[AND(IS NOT NULL($15), IS NOT NULL($0), IS NOT NULL($1), IS NOT NULL($14))])
+                              HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                          HiveProject(t_time_sk=[$0], t_time=[$2])
+                            HiveFilter(condition=[AND(BETWEEN(false, $2, 49530, 78330), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                        HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER], d_moy=[$8])
+                          HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(sm_ship_mode_sk=[$0], sm_carrier=[$4])
+                        HiveFilter(condition=[AND(IN($4, _UTF-16LE'DIAMOND', _UTF-16LE'AIRBORNE'), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
+            HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8], $f9=[$9], $f10=[$10], $f11=[$11], $f12=[$12], $f13=[$13], $f14=[$14], $f15=[$15], $f16=[$16], $f17=[$17], $f18=[$18], $f19=[$19], $f20=[$20], $f21=[$21], $f22=[$22], $f23=[$23], $f24=[$24], $f25=[$25], $f26=[$26], $f27=[$27], $f28=[$28], $f29=[$29])
+              HiveAggregate(group=[{0, 1, 2, 3, 4, 5}], agg#0=[sum($6)], agg#1=[sum($7)], agg#2=[sum($8)], agg#3=[sum($9)], agg#4=[sum($10)], agg#5=[sum($11)], agg#6=[sum($12)], agg#7=[sum($13)], agg#8=[sum($14)], agg#9=[sum($15)], agg#10=[sum($16)], agg#11=[sum($17)], agg#12=[sum($18)], agg#13=[sum($19)], agg#14=[sum($20)], agg#15=[sum($21)], agg#16=[sum($22)], agg#17=[sum($23)], agg#18=[sum($24)], agg#19=[sum($25)], agg#20=[sum($26)], agg#21=[sum($27)], agg#22=[sum($28)], agg#23=[sum($29)])
+                HiveProject($f0=[$15], $f1=[$16], $f2=[$17], $f3=[$18], $f4=[$19], $f5=[$20], $f7=[CASE(=($11, 1), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f8=[CASE(=($11, 2), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f9=[CASE(=($11, 3), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f10=[CASE(=($11, 4), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f11=[CASE(=($11, 5), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f12=[CASE(=($11, 6), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f13=[CASE(=($11, 7), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f14=[CASE(=($11, 8), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f15=[CASE(=($11, 9), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f16=[CASE(=($11, 10), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f17=[CASE(=($11, 11), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f18=[CASE(=($11, 12), *($5, CAST($4):DECIMAL(10, 0)), 0)], $f19=[CASE(=($11, 1), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f20=[CASE(=($11, 2), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f21=[CASE(=($11, 3), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f22=[CASE(=($11, 
 4), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f23=[CASE(=($11, 5), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f24=[CASE(=($11, 6), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f25=[CASE(=($11, 7), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f26=[CASE(=($11, 8), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f27=[CASE(=($11, 9), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f28=[CASE(=($11, 10), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f29=[CASE(=($11, 11), *($6, CAST($4):DECIMAL(10, 0)), 0)], $f30=[CASE(=($11, 12), *($6, CAST($4):DECIMAL(10, 0)), 0)])
+                  HiveJoin(condition=[=($3, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($2, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                        HiveJoin(condition=[=($1, $7)], joinType=[inner], algorithm=[none], cost=[not available])
+                          HiveProject(cs_sold_date_sk=[$0], cs_sold_time_sk=[$1], cs_ship_mode_sk=[$13], cs_warehouse_sk=[$14], cs_quantity=[$18], cs_ext_sales_price=[$23], cs_net_paid_inc_ship_tax=[$32])
+                            HiveFilter(condition=[AND(IS NOT NULL($14), IS NOT NULL($0), IS NOT NULL($1), IS NOT NULL($13))])
+                              HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                          HiveProject(t_time_sk=[$0], t_time=[$2])
+                            HiveFilter(condition=[AND(BETWEEN(false, $2, 49530, 78330), IS NOT NULL($0))])
+                              HiveTableScan(table=[[default, time_dim]], table:alias=[time_dim])
+                        HiveProject(d_date_sk=[$0], d_year=[CAST(2002):INTEGER], d_moy=[$8])
+                          HiveFilter(condition=[AND(=($6, 2002), IS NOT NULL($0))])
+                            HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                      HiveProject(sm_ship_mode_sk=[$0], sm_carrier=[$4])
+                        HiveFilter(condition=[AND(IN($4, _UTF-16LE'DIAMOND', _UTF-16LE'AIRBORNE'), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, ship_mode]], table:alias=[ship_mode])
+                    HiveProject(w_warehouse_sk=[$0], w_warehouse_name=[$2], w_warehouse_sq_ft=[$3], w_city=[$8], w_county=[$9], w_state=[$10], w_country=[$12])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, warehouse]], table:alias=[warehouse])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query67.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query67.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query67.q.out
new file mode 100644
index 0000000..fbe6779
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query67.q.out
@@ -0,0 +1,120 @@
+PREHOOK: query: explain cbo
+select  *
+from (select i_category
+            ,i_class
+            ,i_brand
+            ,i_product_name
+            ,d_year
+            ,d_qoy
+            ,d_moy
+            ,s_store_id
+            ,sumsales
+            ,rank() over (partition by i_category order by sumsales desc) rk
+      from (select i_category
+                  ,i_class
+                  ,i_brand
+                  ,i_product_name
+                  ,d_year
+                  ,d_qoy
+                  ,d_moy
+                  ,s_store_id
+                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
+            from store_sales
+                ,date_dim
+                ,store
+                ,item
+       where  ss_sold_date_sk=d_date_sk
+          and ss_item_sk=i_item_sk
+          and ss_store_sk = s_store_sk
+          and d_month_seq between 1212 and 1212+11
+       group by  rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
+where rk <= 100
+order by i_category
+        ,i_class
+        ,i_brand
+        ,i_product_name
+        ,d_year
+        ,d_qoy
+        ,d_moy
+        ,s_store_id
+        ,sumsales
+        ,rk
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  *
+from (select i_category
+            ,i_class
+            ,i_brand
+            ,i_product_name
+            ,d_year
+            ,d_qoy
+            ,d_moy
+            ,s_store_id
+            ,sumsales
+            ,rank() over (partition by i_category order by sumsales desc) rk
+      from (select i_category
+                  ,i_class
+                  ,i_brand
+                  ,i_product_name
+                  ,d_year
+                  ,d_qoy
+                  ,d_moy
+                  ,s_store_id
+                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
+            from store_sales
+                ,date_dim
+                ,store
+                ,item
+       where  ss_sold_date_sk=d_date_sk
+          and ss_item_sk=i_item_sk
+          and ss_store_sk = s_store_sk
+          and d_month_seq between 1212 and 1212+11
+       group by  rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
+where rk <= 100
+order by i_category
+        ,i_class
+        ,i_brand
+        ,i_product_name
+        ,d_year
+        ,d_qoy
+        ,d_moy
+        ,s_store_id
+        ,sumsales
+        ,rk
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$3], sort4=[$4], sort5=[$5], sort6=[$6], sort7=[$7], sort8=[$8], sort9=[$9], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], dir5=[ASC], dir6=[ASC], dir7=[ASC], dir8=[ASC], dir9=[ASC], fetch=[100])
+  HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], i_product_name=[$3], d_year=[$4], d_qoy=[$5], d_moy=[$6], s_store_id=[$7], sumsales=[$8], rank_window_0=[$9])
+    HiveFilter(condition=[<=($9, 100)])
+      HiveProject(i_category=[$0], i_class=[$1], i_brand=[$2], i_product_name=[$3], d_year=[$4], d_qoy=[$5], d_moy=[$6], s_store_id=[$7], sumsales=[$8], rank_window_0=[rank() OVER (PARTITION BY $0 ORDER BY $8 DESC NULLS LAST ROWS BETWEEN 2147483647 FOLLOWING AND 2147483647 PRECEDING)])
+        HiveProject($f0=[$0], $f1=[$1], $f2=[$2], $f3=[$3], $f4=[$4], $f5=[$5], $f6=[$6], $f7=[$7], $f8=[$8])
+          HiveAggregate(group=[{0, 1, 2, 3, 4, 5, 6, 7}], groups=[[{0, 1, 2, 3, 4, 5, 6, 7}, {0, 1, 2, 3, 4, 5, 6}, {0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4}, {0, 1, 2, 3}, {0, 1, 2}, {0, 1}, {0}, {}]], agg#0=[sum($8)])
+            HiveProject($f0=[$3], $f1=[$2], $f2=[$1], $f3=[$4], $f4=[$12], $f5=[$14], $f6=[$13], $f7=[$16], $f8=[CASE(AND(IS NOT NULL($9), IS NOT NULL($8)), *($9, CAST($8):DECIMAL(10, 0)), 0)])
+              HiveJoin(condition=[=($6, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(i_item_sk=[$0], i_brand=[$8], i_class=[$10], i_category=[$12], i_product_name=[$21])
+                  HiveFilter(condition=[IS NOT NULL($0)])
+                    HiveTableScan(table=[[default, item]], table:alias=[item])
+                HiveJoin(condition=[=($2, $10)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveJoin(condition=[=($0, $5)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_store_sk=[$7], ss_quantity=[$10], ss_sales_price=[$13])
+                      HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($2))])
+                        HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                    HiveProject(d_date_sk=[$0], d_month_seq=[$3], d_year=[$6], d_moy=[$8], d_qoy=[$10])
+                      HiveFilter(condition=[AND(BETWEEN(false, $3, 1212, 1223), IS NOT NULL($0))])
+                        HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                  HiveProject(s_store_sk=[$0], s_store_id=[$1])
+                    HiveFilter(condition=[IS NOT NULL($0)])
+                      HiveTableScan(table=[[default, store]], table:alias=[store])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out
new file mode 100644
index 0000000..cd71cda
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query68.q.out
@@ -0,0 +1,129 @@
+PREHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,extended_price
+       ,extended_tax
+       ,list_price
+ from (select ss_ticket_number
+             ,ss_customer_sk
+             ,ca_city bought_city
+             ,sum(ss_ext_sales_price) extended_price 
+             ,sum(ss_ext_list_price) list_price
+             ,sum(ss_ext_tax) extended_tax 
+       from store_sales
+           ,date_dim
+           ,store
+           ,household_demographics
+           ,customer_address 
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_store_sk = store.s_store_sk  
+        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+        and store_sales.ss_addr_sk = customer_address.ca_address_sk
+        and date_dim.d_dom between 1 and 2 
+        and (household_demographics.hd_dep_count = 2 or
+             household_demographics.hd_vehicle_count= 1)
+        and date_dim.d_year in (1998,1998+1,1998+2)
+        and store.s_city in ('Cedar Grove','Wildwood')
+       group by ss_ticket_number
+               ,ss_customer_sk
+               ,ss_addr_sk,ca_city) dn
+      ,customer
+      ,customer_address current_addr
+ where ss_customer_sk = c_customer_sk
+   and customer.c_current_addr_sk = current_addr.ca_address_sk
+   and current_addr.ca_city <> bought_city
+ order by c_last_name
+         ,ss_ticket_number
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@household_demographics
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  c_last_name
+       ,c_first_name
+       ,ca_city
+       ,bought_city
+       ,ss_ticket_number
+       ,extended_price
+       ,extended_tax
+       ,list_price
+ from (select ss_ticket_number
+             ,ss_customer_sk
+             ,ca_city bought_city
+             ,sum(ss_ext_sales_price) extended_price 
+             ,sum(ss_ext_list_price) list_price
+             ,sum(ss_ext_tax) extended_tax 
+       from store_sales
+           ,date_dim
+           ,store
+           ,household_demographics
+           ,customer_address 
+       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
+         and store_sales.ss_store_sk = store.s_store_sk  
+        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+        and store_sales.ss_addr_sk = customer_address.ca_address_sk
+        and date_dim.d_dom between 1 and 2 
+        and (household_demographics.hd_dep_count = 2 or
+             household_demographics.hd_vehicle_count= 1)
+        and date_dim.d_year in (1998,1998+1,1998+2)
+        and store.s_city in ('Cedar Grove','Wildwood')
+       group by ss_ticket_number
+               ,ss_customer_sk
+               ,ss_addr_sk,ca_city) dn
+      ,customer
+      ,customer_address current_addr
+ where ss_customer_sk = c_customer_sk
+   and customer.c_current_addr_sk = current_addr.ca_address_sk
+   and current_addr.ca_city <> bought_city
+ order by c_last_name
+         ,ss_ticket_number
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@household_demographics
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$4], dir0=[ASC], dir1=[ASC], fetch=[100])
+  HiveProject(c_last_name=[$3], c_first_name=[$2], ca_city=[$5], bought_city=[$8], ss_ticket_number=[$6], extended_price=[$9], extended_tax=[$11], list_price=[$10])
+    HiveJoin(condition=[AND(<>($5, $8), =($7, $0))], joinType=[inner], algorithm=[none], cost=[not available])
+      HiveJoin(condition=[=($1, $4)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_current_addr_sk=[$4], c_first_name=[$8], c_last_name=[$9])
+          HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($4))])
+            HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ca_address_sk=[$0], ca_city=[$6])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, customer_address]], table:alias=[current_addr])
+      HiveProject(ss_ticket_number=[$3], ss_customer_sk=[$1], bought_city=[$0], extended_price=[$4], list_price=[$5], extended_tax=[$6])
+        HiveAggregate(group=[{1, 3, 5, 7}], agg#0=[sum($8)], agg#1=[sum($9)], agg#2=[sum($10)])
+          HiveJoin(condition=[=($5, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveProject(ca_address_sk=[$0], ca_city=[$6])
+              HiveFilter(condition=[IS NOT NULL($0)])
+                HiveTableScan(table=[[default, customer_address]], table:alias=[customer_address])
+            HiveJoin(condition=[=($2, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveJoin(condition=[=($4, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveJoin(condition=[=($0, $9)], joinType=[inner], algorithm=[none], cost=[not available])
+                  HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_hdemo_sk=[$5], ss_addr_sk=[$6], ss_store_sk=[$7], ss_ticket_number=[$9], ss_ext_sales_price=[$15], ss_ext_list_price=[$17], ss_ext_tax=[$18])
+                    HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($7), IS NOT NULL($5), IS NOT NULL($6), IS NOT NULL($3))])
+                      HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                  HiveProject(d_date_sk=[$0], d_year=[$6], d_dom=[$9])
+                    HiveFilter(condition=[AND(IN($6, 1998, 1999, 2000), BETWEEN(false, $9, 1, 2), IS NOT NULL($0))])
+                      HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(s_store_sk=[$0], s_city=[$22])
+                  HiveFilter(condition=[AND(IN($22, _UTF-16LE'Cedar Grove', _UTF-16LE'Wildwood'), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, store]], table:alias=[store])
+              HiveProject(hd_demo_sk=[$0], hd_dep_count=[$3], hd_vehicle_count=[$4])
+                HiveFilter(condition=[AND(OR(=($3, 2), =($4, 1)), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, household_demographics]], table:alias=[household_demographics])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out
new file mode 100644
index 0000000..9089fc8
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query69.q.out
@@ -0,0 +1,156 @@
+PREHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_state in ('CO','IL','MN') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_moy between 1 and 1+2) and
+   (not exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2) and
+    not exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_state in ('CO','IL','MN') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 1999 and
+                d_moy between 1 and 1+2) and
+   (not exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2) and
+    not exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 1999 and
+                  d_moy between 1 and 1+2))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], sort1=[$1], sort2=[$2], sort3=[$4], sort4=[$6], dir0=[ASC], dir1=[ASC], dir2=[ASC], dir3=[ASC], dir4=[ASC], fetch=[100])
+  HiveProject(cd_gender=[$0], cd_marital_status=[$1], cd_education_status=[$2], cnt1=[$5], cd_purchase_estimate=[$3], cnt2=[$5], cd_credit_rating=[$4], cnt3=[$5])
+    HiveAggregate(group=[{6, 7, 8, 9, 10}], agg#0=[count()])
+      HiveFilter(condition=[IS NULL($14)])
+        HiveJoin(condition=[=($0, $13)], joinType=[left], algorithm=[none], cost=[not available])
+          HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$1], c_current_addr_sk=[$2], ca_address_sk=[$3], ca_state=[$4], cd_demo_sk=[$5], cd_gender=[$6], cd_marital_status=[$7], cd_education_status=[$8], cd_purchase_estimate=[$9], cd_credit_rating=[$10], ws_bill_customer_sk0=[$11], $f1=[$12])
+            HiveFilter(condition=[IS NULL($12)])
+              HiveJoin(condition=[=($0, $11)], joinType=[left], algorithm=[none], cost=[not available])
+                HiveSemiJoin(condition=[=($0, $11)], joinType=[inner])
+                  HiveJoin(condition=[=($5, $1)], joinType=[inner], algorithm=[none], cost=[not available])
+                    HiveJoin(condition=[=($2, $3)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(c_customer_sk=[$0], c_current_cdemo_sk=[$2], c_current_addr_sk=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($2), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, customer]], table:alias=[c])
+                      HiveProject(ca_address_sk=[$0], ca_state=[$8])
+                        HiveFilter(condition=[AND(IN($8, _UTF-16LE'CO', _UTF-16LE'IL', _UTF-16LE'MN'), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, customer_address]], table:alias=[ca])
+                    HiveProject(cd_demo_sk=[$0], cd_gender=[$1], cd_marital_status=[$2], cd_education_status=[$3], cd_purchase_estimate=[$4], cd_credit_rating=[$5])
+                      HiveFilter(condition=[IS NOT NULL($0)])
+                        HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+                  HiveProject(ss_customer_sk0=[$1])
+                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3])
+                        HiveFilter(condition=[AND(IS NOT NULL($3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[$8])
+                        HiveFilter(condition=[AND(=($6, 1999), BETWEEN(false, $8, 1, 3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+                HiveProject(ws_bill_customer_sk0=[$0], $f1=[true])
+                  HiveAggregate(group=[{1}])
+                    HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                      HiveProject(ws_sold_date_sk=[$0], ws_bill_customer_sk=[$4])
+                        HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, web_sales]], table:alias=[web_sales])
+                      HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[$8])
+                        HiveFilter(condition=[AND(=($6, 1999), BETWEEN(false, $8, 1, 3), IS NOT NULL($0))])
+                          HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(cs_ship_customer_sk0=[$0], $f1=[true])
+            HiveAggregate(group=[{1}])
+              HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[none], cost=[not available])
+                HiveProject(cs_sold_date_sk=[$0], cs_ship_customer_sk=[$7])
+                  HiveFilter(condition=[AND(IS NOT NULL($7), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, catalog_sales]], table:alias=[catalog_sales])
+                HiveProject(d_date_sk=[$0], d_year=[CAST(1999):INTEGER], d_moy=[$8])
+                  HiveFilter(condition=[AND(=($6, 1999), BETWEEN(false, $8, 1, 3), IS NOT NULL($0))])
+                    HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/cbo_query7.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/cbo_query7.q.out b/ql/src/test/results/clientpositive/perf/tez/cbo_query7.q.out
new file mode 100644
index 0000000..29415ca
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/cbo_query7.q.out
@@ -0,0 +1,76 @@
+PREHOOK: query: explain cbo
+select  i_item_id, 
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4 
+ from store_sales, customer_demographics, date_dim, item, promotion
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       ss_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
+PREHOOK: Input: default@customer_demographics
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@promotion
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain cbo
+select  i_item_id, 
+        avg(ss_quantity) agg1,
+        avg(ss_list_price) agg2,
+        avg(ss_coupon_amt) agg3,
+        avg(ss_sales_price) agg4 
+ from store_sales, customer_demographics, date_dim, item, promotion
+ where ss_sold_date_sk = d_date_sk and
+       ss_item_sk = i_item_sk and
+       ss_cdemo_sk = cd_demo_sk and
+       ss_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
+POSTHOOK: Input: default@customer_demographics
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@promotion
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+CBO PLAN:
+HiveSortLimit(sort0=[$0], dir0=[ASC], fetch=[100])
+  HiveProject($f0=[$0], $f1=[/(CAST($1):DOUBLE, $2)], $f2=[/($3, $4)], $f3=[/($5, $6)], $f4=[/($7, $8)])
+    HiveAggregate(group=[{1}], agg#0=[sum($6)], agg#1=[count($6)], agg#2=[sum($7)], agg#3=[count($7)], agg#4=[sum($9)], agg#5=[count($9)], agg#6=[sum($8)], agg#7=[count($8)])
+      HiveJoin(condition=[=($3, $0)], joinType=[inner], algorithm=[none], cost=[not available])
+        HiveProject(i_item_sk=[$0], i_item_id=[$1])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveTableScan(table=[[default, item]], table:alias=[item])
+        HiveJoin(condition=[=($3, $14)], joinType=[inner], algorithm=[none], cost=[not available])
+          HiveJoin(condition=[=($0, $12)], joinType=[inner], algorithm=[none], cost=[not available])
+            HiveJoin(condition=[=($2, $8)], joinType=[inner], algorithm=[none], cost=[not available])
+              HiveProject(ss_sold_date_sk=[$0], ss_item_sk=[$2], ss_cdemo_sk=[$4], ss_promo_sk=[$8], ss_quantity=[$10], ss_list_price=[$12], ss_sales_price=[$13], ss_coupon_amt=[$19])
+                HiveFilter(condition=[AND(IS NOT NULL($4), IS NOT NULL($0), IS NOT NULL($2), IS NOT NULL($8))])
+                  HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+              HiveProject(cd_demo_sk=[$0], cd_gender=[CAST(_UTF-16LE'F'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_marital_status=[CAST(_UTF-16LE'W'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"], cd_education_status=[CAST(_UTF-16LE'Primary'):VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary"])
+                HiveFilter(condition=[AND(=($1, _UTF-16LE'F'), =($2, _UTF-16LE'W'), =($3, _UTF-16LE'Primary'), IS NOT NULL($0))])
+                  HiveTableScan(table=[[default, customer_demographics]], table:alias=[customer_demographics])
+            HiveProject(d_date_sk=[$0], d_year=[CAST(1998):INTEGER])
+              HiveFilter(condition=[AND(=($6, 1998), IS NOT NULL($0))])
+                HiveTableScan(table=[[default, date_dim]], table:alias=[date_dim])
+          HiveProject(p_promo_sk=[$0], p_channel_email=[$9], p_channel_event=[$14])
+            HiveFilter(condition=[AND(OR(=($9, _UTF-16LE'N'), =($14, _UTF-16LE'N')), IS NOT NULL($0))])
+              HiveTableScan(table=[[default, promotion]], table:alias=[promotion])
+


[16/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query49.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query49.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query49.q.out
new file mode 100644
index 0000000..324eef2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query49.q.out
@@ -0,0 +1,555 @@
+PREHOOK: query: explain
+select  
+ 'web' as channel
+ ,web.item
+ ,web.return_ratio
+ ,web.return_rank
+ ,web.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select ws.ws_item_sk as item
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		 web_sales ws left outer join web_returns wr 
+ 			on (ws.ws_order_number = wr.wr_order_number and 
+ 			ws.ws_item_sk = wr.wr_item_sk)
+                 ,date_dim
+ 		where 
+ 			wr.wr_return_amt > 10000 
+ 			and ws.ws_net_profit > 1
+                         and ws.ws_net_paid > 0
+                         and ws.ws_quantity > 0
+                         and ws_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by ws.ws_item_sk
+ 	) in_web
+ ) web
+ where 
+ (
+ web.return_rank <= 10
+ or
+ web.currency_rank <= 10
+ )
+ union
+ select 
+ 'catalog' as channel
+ ,catalog.item
+ ,catalog.return_ratio
+ ,catalog.return_rank
+ ,catalog.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select 
+ 		cs.cs_item_sk as item
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		catalog_sales cs left outer join catalog_returns cr
+ 			on (cs.cs_order_number = cr.cr_order_number and 
+ 			cs.cs_item_sk = cr.cr_item_sk)
+                ,date_dim
+ 		where 
+ 			cr.cr_return_amount > 10000 
+ 			and cs.cs_net_profit > 1
+                         and cs.cs_net_paid > 0
+                         and cs.cs_quantity > 0
+                         and cs_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+                 group by cs.cs_item_sk
+ 	) in_cat
+ ) catalog
+ where 
+ (
+ catalog.return_rank <= 10
+ or
+ catalog.currency_rank <=10
+ )
+ union
+ select 
+ 'store' as channel
+ ,store.item
+ ,store.return_ratio
+ ,store.return_rank
+ ,store.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select sts.ss_item_sk as item
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		store_sales sts left outer join store_returns sr
+ 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
+                ,date_dim
+ 		where 
+ 			sr.sr_return_amt > 10000 
+ 			and sts.ss_net_profit > 1
+                         and sts.ss_net_paid > 0 
+                         and sts.ss_quantity > 0
+                         and ss_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by sts.ss_item_sk
+ 	) in_store
+ ) store
+ where  (
+ store.return_rank <= 10
+ or 
+ store.currency_rank <= 10
+ )
+ order by 1,4,5
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+ 'web' as channel
+ ,web.item
+ ,web.return_ratio
+ ,web.return_rank
+ ,web.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select ws.ws_item_sk as item
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		 web_sales ws left outer join web_returns wr 
+ 			on (ws.ws_order_number = wr.wr_order_number and 
+ 			ws.ws_item_sk = wr.wr_item_sk)
+                 ,date_dim
+ 		where 
+ 			wr.wr_return_amt > 10000 
+ 			and ws.ws_net_profit > 1
+                         and ws.ws_net_paid > 0
+                         and ws.ws_quantity > 0
+                         and ws_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by ws.ws_item_sk
+ 	) in_web
+ ) web
+ where 
+ (
+ web.return_rank <= 10
+ or
+ web.currency_rank <= 10
+ )
+ union
+ select 
+ 'catalog' as channel
+ ,catalog.item
+ ,catalog.return_ratio
+ ,catalog.return_rank
+ ,catalog.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select 
+ 		cs.cs_item_sk as item
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		catalog_sales cs left outer join catalog_returns cr
+ 			on (cs.cs_order_number = cr.cr_order_number and 
+ 			cs.cs_item_sk = cr.cr_item_sk)
+                ,date_dim
+ 		where 
+ 			cr.cr_return_amount > 10000 
+ 			and cs.cs_net_profit > 1
+                         and cs.cs_net_paid > 0
+                         and cs.cs_quantity > 0
+                         and cs_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+                 group by cs.cs_item_sk
+ 	) in_cat
+ ) catalog
+ where 
+ (
+ catalog.return_rank <= 10
+ or
+ catalog.currency_rank <=10
+ )
+ union
+ select 
+ 'store' as channel
+ ,store.item
+ ,store.return_ratio
+ ,store.return_rank
+ ,store.currency_rank
+ from (
+ 	select 
+ 	 item
+ 	,return_ratio
+ 	,currency_ratio
+ 	,rank() over (order by return_ratio) as return_rank
+ 	,rank() over (order by currency_ratio) as currency_rank
+ 	from
+ 	(	select sts.ss_item_sk as item
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(15,4) )) as currency_ratio
+ 		from 
+ 		store_sales sts left outer join store_returns sr
+ 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
+                ,date_dim
+ 		where 
+ 			sr.sr_return_amt > 10000 
+ 			and sts.ss_net_profit > 1
+                         and sts.ss_net_paid > 0 
+                         and sts.ss_quantity > 0
+                         and ss_sold_date_sk = d_date_sk
+                         and d_year = 2000
+                         and d_moy = 12
+ 		group by sts.ss_item_sk
+ 	) in_store
+ ) store
+ where  (
+ store.return_rank <= 10
+ or 
+ store.currency_rank <= 10
+ )
+ order by 1,4,5
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 13 (BROADCAST_EDGE)
+Map 27 <- Reducer 19 (BROADCAST_EDGE)
+Map 29 <- Reducer 25 (BROADCAST_EDGE)
+Reducer 10 <- Union 9 (SIMPLE_EDGE)
+Reducer 11 <- Reducer 10 (SIMPLE_EDGE)
+Reducer 13 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 14 <- Map 12 (SIMPLE_EDGE), Map 27 (SIMPLE_EDGE)
+Reducer 15 <- Map 28 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 19 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 20 <- Map 12 (SIMPLE_EDGE), Map 29 (SIMPLE_EDGE)
+Reducer 21 <- Map 30 (SIMPLE_EDGE), Reducer 20 (SIMPLE_EDGE)
+Reducer 22 <- Reducer 21 (SIMPLE_EDGE)
+Reducer 23 <- Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Reducer 23 (SIMPLE_EDGE), Union 9 (CONTAINS)
+Reducer 25 <- Map 12 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 26 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE), Union 7 (CONTAINS)
+Reducer 8 <- Union 7 (SIMPLE_EDGE), Union 9 (CONTAINS)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 11 vectorized
+      File Output Operator [FS_310]
+        Limit [LIM_309] (rows=100 width=215)
+          Number of rows:100
+          Select Operator [SEL_308] (rows=3418 width=215)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 10 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_307]
+              Select Operator [SEL_306] (rows=3418 width=215)
+                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Group By Operator [GBY_305] (rows=3418 width=215)
+                  Output:["_col0","_col1","_col2","_col3","_col4"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                <-Union 9 [SIMPLE_EDGE]
+                  <-Reducer 24 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_351]
+                      PartitionCols:_col0, _col1, _col2, _col3, _col4
+                      Group By Operator [GBY_350] (rows=3418 width=215)
+                        Output:["_col0","_col1","_col2","_col3","_col4"],keys:_col0, _col3, _col4, _col1, _col2
+                        Top N Key Operator [TNK_349] (rows=3418 width=214)
+                          keys:_col0, _col3, _col4, _col1, _col2,sort order:+++++,top n:100
+                          Select Operator [SEL_348] (rows=1142 width=213)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Filter Operator [FIL_347] (rows=1142 width=248)
+                              predicate:((_col0 <= 10) or (rank_window_1 <= 10))
+                              PTF Operator [PTF_346] (rows=1714 width=248)
+                                Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(CAST( _col4 AS decimal(15,4)) / CAST( _col5 AS decimal(15,4))) ASC NULLS LAST","partition by:":"0"}]
+                                Select Operator [SEL_345] (rows=1714 width=248)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                <-Reducer 23 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_344]
+                                    PartitionCols:0
+                                    Select Operator [SEL_343] (rows=1714 width=244)
+                                      Output:["rank_window_0","_col0","_col1","_col2","_col3","_col4"]
+                                      PTF Operator [PTF_342] (rows=1714 width=244)
+                                        Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(CAST( _col1 AS decimal(15,4)) / CAST( _col2 AS decimal(15,4))) ASC NULLS LAST","partition by:":"0"}]
+                                        Select Operator [SEL_341] (rows=1714 width=244)
+                                          Output:["_col0","_col1","_col2","_col3","_col4"]
+                                        <-Reducer 22 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_340]
+                                            PartitionCols:0
+                                            Group By Operator [GBY_339] (rows=1714 width=244)
+                                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0
+                                            <-Reducer 21 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_89]
+                                                PartitionCols:_col0
+                                                Group By Operator [GBY_88] (rows=1714 width=244)
+                                                  Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col1)","sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0
+                                                  Select Operator [SEL_86] (rows=1673571 width=73)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                    Merge Join Operator [MERGEJOIN_237] (rows=1673571 width=73)
+                                                      Conds:RS_83._col1, _col2=RS_338._col0, _col1(Inner),Output:["_col1","_col3","_col4","_col9","_col10"]
+                                                    <-Map 30 [SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_338]
+                                                        PartitionCols:_col0, _col1
+                                                        Select Operator [SEL_337] (rows=19197050 width=119)
+                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                          Filter Operator [FIL_336] (rows=19197050 width=119)
+                                                            predicate:(sr_return_amt > 10000)
+                                                            TableScan [TS_77] (rows=57591150 width=119)
+                                                              default@store_returns,sr,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_item_sk","sr_ticket_number","sr_return_quantity","sr_return_amt"]
+                                                    <-Reducer 20 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_83]
+                                                        PartitionCols:_col1, _col2
+                                                        Merge Join Operator [MERGEJOIN_236] (rows=1673571 width=8)
+                                                          Conds:RS_335._col0=RS_272._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                        <-Map 12 [SIMPLE_EDGE] vectorized
+                                                          PARTITION_ONLY_SHUFFLE [RS_272]
+                                                            PartitionCols:_col0
+                                                            Select Operator [SEL_267] (rows=50 width=4)
+                                                              Output:["_col0"]
+                                                              Filter Operator [FIL_266] (rows=50 width=12)
+                                                                predicate:((d_moy = 12) and (d_year = 2000))
+                                                                TableScan [TS_3] (rows=73049 width=12)
+                                                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                                        <-Map 29 [SIMPLE_EDGE] vectorized
+                                                          SHUFFLE [RS_335]
+                                                            PartitionCols:_col0
+                                                            Select Operator [SEL_334] (rows=61119617 width=229)
+                                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                              Filter Operator [FIL_333] (rows=61119617 width=229)
+                                                                predicate:((ss_net_paid > 0) and (ss_net_profit > 1) and (ss_quantity > 0) and (ss_sold_date_sk BETWEEN DynamicValue(RS_81_date_dim_d_date_sk_min) AND DynamicValue(RS_81_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_81_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null)
+                                                                TableScan [TS_71] (rows=575995635 width=229)
+                                                                  default@store_sales,sts,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_ticket_number","ss_quantity","ss_net_paid","ss_net_profit"]
+                                                                <-Reducer 25 [BROADCAST_EDGE] vectorized
+                                                                  BROADCAST [RS_332]
+                                                                    Group By Operator [GBY_331] (rows=1 width=12)
+                                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                    <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                      PARTITION_ONLY_SHUFFLE [RS_279]
+                                                                        Group By Operator [GBY_276] (rows=1 width=12)
+                                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                          Select Operator [SEL_273] (rows=50 width=4)
+                                                                            Output:["_col0"]
+                                                                             Please refer to the previous Select Operator [SEL_267]
+                  <-Reducer 8 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_304]
+                      PartitionCols:_col0, _col1, _col2, _col3, _col4
+                      Group By Operator [GBY_303] (rows=3418 width=215)
+                        Output:["_col0","_col1","_col2","_col3","_col4"],keys:_col0, _col3, _col4, _col1, _col2
+                        Top N Key Operator [TNK_302] (rows=3418 width=214)
+                          keys:_col0, _col3, _col4, _col1, _col2,sort order:+++++,top n:100
+                          Select Operator [SEL_301] (rows=2276 width=215)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Group By Operator [GBY_300] (rows=2276 width=215)
+                              Output:["_col0","_col1","_col2","_col3","_col4"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4
+                            <-Union 7 [SIMPLE_EDGE]
+                              <-Reducer 18 [CONTAINS] vectorized
+                                Reduce Output Operator [RS_330]
+                                  PartitionCols:_col0, _col1, _col2, _col3, _col4
+                                  Group By Operator [GBY_329] (rows=2276 width=215)
+                                    Output:["_col0","_col1","_col2","_col3","_col4"],keys:_col0, _col3, _col4, _col1, _col2
+                                    Select Operator [SEL_328] (rows=1134 width=215)
+                                      Output:["_col0","_col1","_col2","_col3","_col4"]
+                                      Filter Operator [FIL_327] (rows=1134 width=248)
+                                        predicate:((_col0 <= 10) or (rank_window_1 <= 10))
+                                        PTF Operator [PTF_326] (rows=1701 width=248)
+                                          Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(CAST( _col4 AS decimal(15,4)) / CAST( _col5 AS decimal(15,4))) ASC NULLS LAST","partition by:":"0"}]
+                                          Select Operator [SEL_325] (rows=1701 width=248)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                          <-Reducer 17 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_324]
+                                              PartitionCols:0
+                                              Select Operator [SEL_323] (rows=1701 width=244)
+                                                Output:["rank_window_0","_col0","_col1","_col2","_col3","_col4"]
+                                                PTF Operator [PTF_322] (rows=1701 width=244)
+                                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(CAST( _col1 AS decimal(15,4)) / CAST( _col2 AS decimal(15,4))) ASC NULLS LAST","partition by:":"0"}]
+                                                  Select Operator [SEL_321] (rows=1701 width=244)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                  <-Reducer 16 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_320]
+                                                      PartitionCols:0
+                                                      Group By Operator [GBY_319] (rows=1701 width=244)
+                                                        Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0
+                                                      <-Reducer 15 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_50]
+                                                          PartitionCols:_col0
+                                                          Group By Operator [GBY_49] (rows=1701 width=244)
+                                                            Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col1)","sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0
+                                                            Select Operator [SEL_47] (rows=865646 width=188)
+                                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                              Merge Join Operator [MERGEJOIN_235] (rows=865646 width=188)
+                                                                Conds:RS_44._col1, _col2=RS_318._col0, _col1(Inner),Output:["_col1","_col3","_col4","_col9","_col10"]
+                                                              <-Map 28 [SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_318]
+                                                                  PartitionCols:_col0, _col1
+                                                                  Select Operator [SEL_317] (rows=9599627 width=121)
+                                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                                    Filter Operator [FIL_316] (rows=9599627 width=121)
+                                                                      predicate:(cr_return_amount > 10000)
+                                                                      TableScan [TS_38] (rows=28798881 width=121)
+                                                                        default@catalog_returns,cr,Tbl:COMPLETE,Col:COMPLETE,Output:["cr_item_sk","cr_order_number","cr_return_quantity","cr_return_amount"]
+                                                              <-Reducer 14 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_44]
+                                                                  PartitionCols:_col1, _col2
+                                                                  Merge Join Operator [MERGEJOIN_234] (rows=865646 width=102)
+                                                                    Conds:RS_315._col0=RS_270._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                                  <-Map 12 [SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_270]
+                                                                      PartitionCols:_col0
+                                                                       Please refer to the previous Select Operator [SEL_267]
+                                                                  <-Map 27 [SIMPLE_EDGE] vectorized
+                                                                    SHUFFLE [RS_315]
+                                                                      PartitionCols:_col0
+                                                                      Select Operator [SEL_314] (rows=31838858 width=239)
+                                                                        Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                                        Filter Operator [FIL_313] (rows=31838858 width=239)
+                                                                          predicate:((cs_net_paid > 0) and (cs_net_profit > 1) and (cs_quantity > 0) and (cs_sold_date_sk BETWEEN DynamicValue(RS_42_date_dim_d_date_sk_min) AND DynamicValue(RS_42_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_42_date_dim_d_date_sk_bloom_filter))) and cs_sold_date_sk is not null)
+                                                                          TableScan [TS_32] (rows=287989836 width=239)
+                                                                            default@catalog_sales,cs,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_item_sk","cs_order_number","cs_quantity","cs_net_paid","cs_net_profit"]
+                                                                          <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_312]
+                                                                              Group By Operator [GBY_311] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                              <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                PARTITION_ONLY_SHUFFLE [RS_278]
+                                                                                  Group By Operator [GBY_275] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                    Select Operator [SEL_271] (rows=50 width=4)
+                                                                                      Output:["_col0"]
+                                                                                       Please refer to the previous Select Operator [SEL_267]
+                              <-Reducer 6 [CONTAINS] vectorized
+                                Reduce Output Operator [RS_299]
+                                  PartitionCols:_col0, _col1, _col2, _col3, _col4
+                                  Group By Operator [GBY_298] (rows=2276 width=215)
+                                    Output:["_col0","_col1","_col2","_col3","_col4"],keys:_col0, _col3, _col4, _col1, _col2
+                                    Select Operator [SEL_297] (rows=1142 width=211)
+                                      Output:["_col0","_col1","_col2","_col3","_col4"]
+                                      Filter Operator [FIL_296] (rows=1142 width=248)
+                                        predicate:((_col0 <= 10) or (rank_window_1 <= 10))
+                                        PTF Operator [PTF_295] (rows=1714 width=248)
+                                          Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(CAST( _col4 AS decimal(15,4)) / CAST( _col5 AS decimal(15,4))) ASC NULLS LAST","partition by:":"0"}]
+                                          Select Operator [SEL_294] (rows=1714 width=248)
+                                            Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                          <-Reducer 5 [SIMPLE_EDGE] vectorized
+                                            SHUFFLE [RS_293]
+                                              PartitionCols:0
+                                              Select Operator [SEL_292] (rows=1714 width=244)
+                                                Output:["rank_window_0","_col0","_col1","_col2","_col3","_col4"]
+                                                PTF Operator [PTF_291] (rows=1714 width=244)
+                                                  Function definitions:[{},{"name:":"windowingtablefunction","order by:":"(CAST( _col1 AS decimal(15,4)) / CAST( _col2 AS decimal(15,4))) ASC NULLS LAST","partition by:":"0"}]
+                                                  Select Operator [SEL_290] (rows=1714 width=244)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                  <-Reducer 4 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_289]
+                                                      PartitionCols:0
+                                                      Group By Operator [GBY_288] (rows=1714 width=244)
+                                                        Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0
+                                                      <-Reducer 3 [SIMPLE_EDGE]
+                                                        SHUFFLE [RS_18]
+                                                          PartitionCols:_col0
+                                                          Group By Operator [GBY_17] (rows=1714 width=244)
+                                                            Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col1)","sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0
+                                                            Select Operator [SEL_15] (rows=438010 width=177)
+                                                              Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                              Merge Join Operator [MERGEJOIN_233] (rows=438010 width=177)
+                                                                Conds:RS_12._col1, _col2=RS_287._col0, _col1(Inner),Output:["_col1","_col3","_col4","_col9","_col10"]
+                                                              <-Map 26 [SIMPLE_EDGE] vectorized
+                                                                SHUFFLE [RS_287]
+                                                                  PartitionCols:_col0, _col1
+                                                                  Select Operator [SEL_286] (rows=4799489 width=118)
+                                                                    Output:["_col0","_col1","_col2","_col3"]
+                                                                    Filter Operator [FIL_285] (rows=4799489 width=118)
+                                                                      predicate:(wr_return_amt > 10000)
+                                                                      TableScan [TS_6] (rows=14398467 width=118)
+                                                                        default@web_returns,wr,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_item_sk","wr_order_number","wr_return_quantity","wr_return_amt"]
+                                                              <-Reducer 2 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_12]
+                                                                  PartitionCols:_col1, _col2
+                                                                  Merge Join Operator [MERGEJOIN_232] (rows=438010 width=122)
+                                                                    Conds:RS_284._col0=RS_268._col0(Inner),Output:["_col1","_col2","_col3","_col4"]
+                                                                  <-Map 12 [SIMPLE_EDGE] vectorized
+                                                                    PARTITION_ONLY_SHUFFLE [RS_268]
+                                                                      PartitionCols:_col0
+                                                                       Please refer to the previous Select Operator [SEL_267]
+                                                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                                                    SHUFFLE [RS_284]
+                                                                      PartitionCols:_col0
+                                                                      Select Operator [SEL_283] (rows=15996318 width=239)
+                                                                        Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                                        Filter Operator [FIL_282] (rows=15996318 width=239)
+                                                                          predicate:((ws_net_paid > 0) and (ws_net_profit > 1) and (ws_quantity > 0) and (ws_sold_date_sk BETWEEN DynamicValue(RS_10_date_dim_d_date_sk_min) AND DynamicValue(RS_10_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_10_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null)
+                                                                          TableScan [TS_0] (rows=144002668 width=239)
+                                                                            default@web_sales,ws,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_order_number","ws_quantity","ws_net_paid","ws_net_profit"]
+                                                                          <-Reducer 13 [BROADCAST_EDGE] vectorized
+                                                                            BROADCAST [RS_281]
+                                                                              Group By Operator [GBY_280] (rows=1 width=12)
+                                                                                Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                                              <-Map 12 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                                                PARTITION_ONLY_SHUFFLE [RS_277]
+                                                                                  Group By Operator [GBY_274] (rows=1 width=12)
+                                                                                    Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                                                    Select Operator [SEL_269] (rows=50 width=4)
+                                                                                      Output:["_col0"]
+                                                                                       Please refer to the previous Select Operator [SEL_267]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out
new file mode 100644
index 0000000..32b0e3e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query5.q.out
@@ -0,0 +1,531 @@
+PREHOOK: query: explain
+with ssr as
+ (select s_store_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ss_store_sk as store_sk,
+            ss_sold_date_sk  as date_sk,
+            ss_ext_sales_price as sales_price,
+            ss_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from store_sales
+    union all
+    select sr_store_sk as store_sk,
+           sr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           sr_return_amt as return_amt,
+           sr_net_loss as net_loss
+    from store_returns
+   ) salesreturns,
+     date_dim,
+     store
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  14 days)
+       and store_sk = s_store_sk
+ group by s_store_id)
+ ,
+ csr as
+ (select cp_catalog_page_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  cs_catalog_page_sk as page_sk,
+            cs_sold_date_sk  as date_sk,
+            cs_ext_sales_price as sales_price,
+            cs_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from catalog_sales
+    union all
+    select cr_catalog_page_sk as page_sk,
+           cr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           cr_return_amount as return_amt,
+           cr_net_loss as net_loss
+    from catalog_returns
+   ) salesreturns,
+     date_dim,
+     catalog_page
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and page_sk = cp_catalog_page_sk
+ group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select web_site_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ws_web_site_sk as wsr_web_site_sk,
+            ws_sold_date_sk  as date_sk,
+            ws_ext_sales_price as sales_price,
+            ws_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from web_sales
+    union all
+    select ws_web_site_sk as wsr_web_site_sk,
+           wr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           wr_return_amt as return_amt,
+           wr_net_loss as net_loss
+    from web_returns left outer join web_sales on
+         ( wr_item_sk = ws_item_sk
+           and wr_order_number = ws_order_number)
+   ) salesreturns,
+     date_dim,
+     web_site
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and wsr_web_site_sk = web_site_sk
+ group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || s_store_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || cp_catalog_page_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_page
+PREHOOK: Input: default@catalog_returns
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_returns
+PREHOOK: Input: default@web_sales
+PREHOOK: Input: default@web_site
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with ssr as
+ (select s_store_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ss_store_sk as store_sk,
+            ss_sold_date_sk  as date_sk,
+            ss_ext_sales_price as sales_price,
+            ss_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from store_sales
+    union all
+    select sr_store_sk as store_sk,
+           sr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           sr_return_amt as return_amt,
+           sr_net_loss as net_loss
+    from store_returns
+   ) salesreturns,
+     date_dim,
+     store
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date) 
+                  and (cast('1998-08-04' as date) +  14 days)
+       and store_sk = s_store_sk
+ group by s_store_id)
+ ,
+ csr as
+ (select cp_catalog_page_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  cs_catalog_page_sk as page_sk,
+            cs_sold_date_sk  as date_sk,
+            cs_ext_sales_price as sales_price,
+            cs_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from catalog_sales
+    union all
+    select cr_catalog_page_sk as page_sk,
+           cr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           cr_return_amount as return_amt,
+           cr_net_loss as net_loss
+    from catalog_returns
+   ) salesreturns,
+     date_dim,
+     catalog_page
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and page_sk = cp_catalog_page_sk
+ group by cp_catalog_page_id)
+ ,
+ wsr as
+ (select web_site_id,
+        sum(sales_price) as sales,
+        sum(profit) as profit,
+        sum(return_amt) as returns,
+        sum(net_loss) as profit_loss
+ from
+  ( select  ws_web_site_sk as wsr_web_site_sk,
+            ws_sold_date_sk  as date_sk,
+            ws_ext_sales_price as sales_price,
+            ws_net_profit as profit,
+            cast(0 as decimal(7,2)) as return_amt,
+            cast(0 as decimal(7,2)) as net_loss
+    from web_sales
+    union all
+    select ws_web_site_sk as wsr_web_site_sk,
+           wr_returned_date_sk as date_sk,
+           cast(0 as decimal(7,2)) as sales_price,
+           cast(0 as decimal(7,2)) as profit,
+           wr_return_amt as return_amt,
+           wr_net_loss as net_loss
+    from web_returns left outer join web_sales on
+         ( wr_item_sk = ws_item_sk
+           and wr_order_number = ws_order_number)
+   ) salesreturns,
+     date_dim,
+     web_site
+ where date_sk = d_date_sk
+       and d_date between cast('1998-08-04' as date)
+                  and (cast('1998-08-04' as date) +  14 days)
+       and wsr_web_site_sk = web_site_sk
+ group by web_site_id)
+  select  channel
+        , id
+        , sum(sales) as sales
+        , sum(returns) as returns
+        , sum(profit) as profit
+ from 
+ (select 'store channel' as channel
+        , 'store' || s_store_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   ssr
+ union all
+ select 'catalog channel' as channel
+        , 'catalog_page' || cp_catalog_page_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from  csr
+ union all
+ select 'web channel' as channel
+        , 'web_site' || web_site_id as id
+        , sales
+        , returns
+        , (profit - profit_loss) as profit
+ from   wsr
+ ) x
+ group by rollup (channel, id)
+ order by channel
+         ,id
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_page
+POSTHOOK: Input: default@catalog_returns
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_returns
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Input: default@web_site
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 11 (BROADCAST_EDGE), Union 2 (CONTAINS)
+Map 21 <- Reducer 15 (BROADCAST_EDGE), Union 22 (CONTAINS)
+Map 23 <- Union 22 (CONTAINS)
+Map 25 <- Reducer 19 (BROADCAST_EDGE), Union 26 (CONTAINS)
+Map 9 <- Union 2 (CONTAINS)
+Reducer 11 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Map 10 (SIMPLE_EDGE), Union 22 (SIMPLE_EDGE)
+Reducer 13 <- Map 24 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 14 <- Reducer 13 (SIMPLE_EDGE), Union 6 (CONTAINS)
+Reducer 15 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Map 10 (SIMPLE_EDGE), Union 26 (SIMPLE_EDGE)
+Reducer 17 <- Map 30 (SIMPLE_EDGE), Reducer 16 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE), Union 6 (CONTAINS)
+Reducer 19 <- Map 10 (CUSTOM_SIMPLE_EDGE)
+Reducer 28 <- Map 27 (SIMPLE_EDGE), Map 29 (SIMPLE_EDGE), Union 26 (CONTAINS)
+Reducer 3 <- Map 10 (SIMPLE_EDGE), Union 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 20 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE), Union 6 (CONTAINS)
+Reducer 7 <- Union 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 7 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 8 vectorized
+      File Output Operator [FS_300]
+        Limit [LIM_299] (rows=100 width=619)
+          Number of rows:100
+          Select Operator [SEL_298] (rows=38846 width=619)
+            Output:["_col0","_col1","_col2","_col3","_col4"]
+          <-Reducer 7 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_297]
+              Select Operator [SEL_296] (rows=38846 width=619)
+                Output:["_col0","_col1","_col2","_col3","_col4"]
+                Group By Operator [GBY_295] (rows=38846 width=627)
+                  Output:["_col0","_col1","_col3","_col4","_col5"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)"],keys:KEY._col0, KEY._col1, KEY._col2
+                <-Union 6 [SIMPLE_EDGE]
+                  <-Reducer 14 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_310]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_309] (rows=59581 width=627)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_308] (rows=39721 width=618)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_307] (rows=38846 width=619)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Group By Operator [GBY_306] (rows=38846 width=548)
+                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0
+                            <-Reducer 13 [SIMPLE_EDGE]
+                              SHUFFLE [RS_45]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_44] (rows=46000 width=548)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col2)","sum(_col4)","sum(_col3)","sum(_col5)"],keys:_col8
+                                  Merge Join Operator [MERGEJOIN_219] (rows=34813117 width=535)
+                                    Conds:RS_40._col0=RS_305._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col8"]
+                                  <-Map 24 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_305]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_304] (rows=46000 width=104)
+                                        Output:["_col0","_col1"]
+                                        TableScan [TS_35] (rows=46000 width=104)
+                                          default@catalog_page,catalog_page,Tbl:COMPLETE,Col:COMPLETE,Output:["cp_catalog_page_sk","cp_catalog_page_id"]
+                                  <-Reducer 12 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_40]
+                                      PartitionCols:_col0
+                                      Merge Join Operator [MERGEJOIN_218] (rows=34813117 width=438)
+                                        Conds:Union 22._col1=RS_273._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5"]
+                                      <-Map 10 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_273]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_270] (rows=8116 width=4)
+                                            Output:["_col0"]
+                                            Filter Operator [FIL_269] (rows=8116 width=98)
+                                              predicate:CAST( d_date AS TIMESTAMP) BETWEEN TIMESTAMP'1998-08-04 00:00:00' AND TIMESTAMP'1998-08-18 00:00:00'
+                                              TableScan [TS_8] (rows=73049 width=98)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_date"]
+                                      <-Union 22 [SIMPLE_EDGE]
+                                        <-Map 21 [CONTAINS] vectorized
+                                          Reduce Output Operator [RS_322]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_321] (rows=285117694 width=455)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_320] (rows=285117694 width=231)
+                                                predicate:((cs_sold_date_sk BETWEEN DynamicValue(RS_38_date_dim_d_date_sk_min) AND DynamicValue(RS_38_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_38_date_dim_d_date_sk_bloom_filter))) and cs_catalog_page_sk is not null and cs_sold_date_sk is not null)
+                                                TableScan [TS_250] (rows=287989836 width=231)
+                                                  Output:["cs_sold_date_sk","cs_catalog_page_sk","cs_ext_sales_price","cs_net_profit"]
+                                                <-Reducer 15 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_319]
+                                                    Group By Operator [GBY_318] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_281]
+                                                        Group By Operator [GBY_278] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_274] (rows=8116 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_270]
+                                        <-Map 23 [CONTAINS] vectorized
+                                          Reduce Output Operator [RS_325]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_324] (rows=28221805 width=451)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_323] (rows=28221805 width=227)
+                                                predicate:(cr_catalog_page_sk is not null and cr_returned_date_sk is not null)
+                                                TableScan [TS_255] (rows=28798881 width=227)
+                                                  Output:["cr_returned_date_sk","cr_catalog_page_sk","cr_return_amount","cr_net_loss"]
+                  <-Reducer 18 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_317]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_316] (rows=59581 width=627)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_315] (rows=39721 width=618)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_314] (rows=53 width=615)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Group By Operator [GBY_313] (rows=53 width=548)
+                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0
+                            <-Reducer 17 [SIMPLE_EDGE]
+                              SHUFFLE [RS_77]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_76] (rows=84 width=548)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col2)","sum(_col4)","sum(_col3)","sum(_col5)"],keys:_col8
+                                  Merge Join Operator [MERGEJOIN_221] (rows=30966059 width=543)
+                                    Conds:RS_72._col0=RS_312._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col8"]
+                                  <-Map 30 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_312]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_311] (rows=84 width=104)
+                                        Output:["_col0","_col1"]
+                                        TableScan [TS_67] (rows=84 width=104)
+                                          default@web_site,web_site,Tbl:COMPLETE,Col:COMPLETE,Output:["web_site_sk","web_site_id"]
+                                  <-Reducer 16 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_72]
+                                      PartitionCols:_col0
+                                      Merge Join Operator [MERGEJOIN_220] (rows=30966059 width=447)
+                                        Conds:Union 26._col1=RS_275._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5"]
+                                      <-Map 10 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_275]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_270]
+                                      <-Union 26 [SIMPLE_EDGE]
+                                        <-Map 25 [CONTAINS] vectorized
+                                          Reduce Output Operator [RS_330]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_329] (rows=143930874 width=455)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_328] (rows=143930874 width=231)
+                                                predicate:((ws_sold_date_sk BETWEEN DynamicValue(RS_70_date_dim_d_date_sk_min) AND DynamicValue(RS_70_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_70_date_dim_d_date_sk_bloom_filter))) and ws_sold_date_sk is not null and ws_web_site_sk is not null)
+                                                TableScan [TS_260] (rows=144002668 width=231)
+                                                  Output:["ws_sold_date_sk","ws_web_site_sk","ws_ext_sales_price","ws_net_profit"]
+                                                <-Reducer 19 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_327]
+                                                    Group By Operator [GBY_326] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_282]
+                                                        Group By Operator [GBY_279] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_276] (rows=8116 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_270]
+                                        <-Reducer 28 [CONTAINS]
+                                          Reduce Output Operator [RS_268]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_266] (rows=134782734 width=454)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Merge Join Operator [MERGEJOIN_265] (rows=134782734 width=230)
+                                                Conds:RS_333._col0, _col2=RS_336._col1, _col2(Inner),Output:["_col1","_col3","_col6","_col7"]
+                                              <-Map 27 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_333]
+                                                  PartitionCols:_col0, _col2
+                                                  Select Operator [SEL_332] (rows=143966669 width=11)
+                                                    Output:["_col0","_col1","_col2"]
+                                                    Filter Operator [FIL_331] (rows=143966669 width=11)
+                                                      predicate:ws_web_site_sk is not null
+                                                      TableScan [TS_52] (rows=144002668 width=11)
+                                                        default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_item_sk","ws_web_site_sk","ws_order_number"]
+                                              <-Map 29 [SIMPLE_EDGE] vectorized
+                                                SHUFFLE [RS_336]
+                                                  PartitionCols:_col1, _col2
+                                                  Select Operator [SEL_335] (rows=13749816 width=225)
+                                                    Output:["_col0","_col1","_col2","_col3","_col4"]
+                                                    Filter Operator [FIL_334] (rows=13749816 width=225)
+                                                      predicate:wr_returned_date_sk is not null
+                                                      TableScan [TS_55] (rows=14398467 width=225)
+                                                        default@web_returns,web_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["wr_returned_date_sk","wr_item_sk","wr_order_number","wr_return_amt","wr_net_loss"]
+                  <-Reducer 5 [CONTAINS] vectorized
+                    Reduce Output Operator [RS_294]
+                      PartitionCols:_col0, _col1, _col2
+                      Group By Operator [GBY_293] (rows=59581 width=627)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)"],keys:_col0, _col1, 0L
+                        Top N Key Operator [TNK_292] (rows=39721 width=618)
+                          keys:_col0, _col1, 0L,sort order:+++,top n:100
+                          Select Operator [SEL_291] (rows=822 width=617)
+                            Output:["_col0","_col1","_col2","_col3","_col4"]
+                            Group By Operator [GBY_290] (rows=822 width=548)
+                              Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)"],keys:KEY._col0
+                            <-Reducer 4 [SIMPLE_EDGE]
+                              SHUFFLE [RS_21]
+                                PartitionCols:_col0
+                                Group By Operator [GBY_20] (rows=1704 width=548)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"],aggregations:["sum(_col2)","sum(_col4)","sum(_col3)","sum(_col5)"],keys:_col8
+                                  Merge Join Operator [MERGEJOIN_217] (rows=64325014 width=376)
+                                    Conds:RS_16._col0=RS_289._col0(Inner),Output:["_col2","_col3","_col4","_col5","_col8"]
+                                  <-Map 20 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_289]
+                                      PartitionCols:_col0
+                                      Select Operator [SEL_288] (rows=1704 width=104)
+                                        Output:["_col0","_col1"]
+                                        TableScan [TS_11] (rows=1704 width=104)
+                                          default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id"]
+                                  <-Reducer 3 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_16]
+                                      PartitionCols:_col0
+                                      Merge Join Operator [MERGEJOIN_216] (rows=64325014 width=277)
+                                        Conds:Union 2._col1=RS_271._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5"]
+                                      <-Map 10 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_271]
+                                          PartitionCols:_col0
+                                           Please refer to the previous Select Operator [SEL_270]
+                                      <-Union 2 [SIMPLE_EDGE]
+                                        <-Map 1 [CONTAINS] vectorized
+                                          Reduce Output Operator [RS_287]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_286] (rows=525329897 width=445)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_285] (rows=525329897 width=221)
+                                                predicate:((ss_sold_date_sk BETWEEN DynamicValue(RS_14_date_dim_d_date_sk_min) AND DynamicValue(RS_14_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_14_date_dim_d_date_sk_bloom_filter))) and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                                TableScan [TS_222] (rows=575995635 width=221)
+                                                  Output:["ss_sold_date_sk","ss_store_sk","ss_ext_sales_price","ss_net_profit"]
+                                                <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_284]
+                                                    Group By Operator [GBY_283] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 10 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      SHUFFLE [RS_280]
+                                                        Group By Operator [GBY_277] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_272] (rows=8116 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_270]
+                                        <-Map 9 [CONTAINS] vectorized
+                                          Reduce Output Operator [RS_303]
+                                            PartitionCols:_col1
+                                            Select Operator [SEL_302] (rows=53634860 width=447)
+                                              Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                              Filter Operator [FIL_301] (rows=53634860 width=223)
+                                                predicate:(sr_returned_date_sk is not null and sr_store_sk is not null)
+                                                TableScan [TS_233] (rows=57591150 width=223)
+                                                  Output:["sr_returned_date_sk","sr_store_sk","sr_return_amt","sr_net_loss"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query50.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query50.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query50.q.out
new file mode 100644
index 0000000..05d84d8
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query50.q.out
@@ -0,0 +1,242 @@
+PREHOOK: query: explain
+select  
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   store_sales
+  ,store_returns
+  ,store
+  ,date_dim d1
+  ,date_dim d2
+where
+    d2.d_year = 2000
+and d2.d_moy  = 9
+and ss_ticket_number = sr_ticket_number
+and ss_item_sk = sr_item_sk
+and ss_sold_date_sk   = d1.d_date_sk
+and sr_returned_date_sk   = d2.d_date_sk
+and ss_customer_sk = sr_customer_sk
+and ss_store_sk = s_store_sk
+group by
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+order by s_store_name
+        ,s_company_id
+        ,s_street_number
+        ,s_street_name
+        ,s_street_type
+        ,s_suite_number
+        ,s_city
+        ,s_county
+        ,s_state
+        ,s_zip
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_returns
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+from
+   store_sales
+  ,store_returns
+  ,store
+  ,date_dim d1
+  ,date_dim d2
+where
+    d2.d_year = 2000
+and d2.d_moy  = 9
+and ss_ticket_number = sr_ticket_number
+and ss_item_sk = sr_item_sk
+and ss_sold_date_sk   = d1.d_date_sk
+and sr_returned_date_sk   = d2.d_date_sk
+and ss_customer_sk = sr_customer_sk
+and ss_store_sk = s_store_sk
+group by
+   s_store_name
+  ,s_company_id
+  ,s_street_number
+  ,s_street_name
+  ,s_street_type
+  ,s_suite_number
+  ,s_city
+  ,s_county
+  ,s_state
+  ,s_zip
+order by s_store_name
+        ,s_company_id
+        ,s_street_number
+        ,s_street_name
+        ,s_street_type
+        ,s_suite_number
+        ,s_city
+        ,s_county
+        ,s_state
+        ,s_zip
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_returns
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 11 <- Reducer 7 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE), Reducer 9 (BROADCAST_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 10 (SIMPLE_EDGE)
+Reducer 3 <- Map 11 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 12 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 8 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 6 vectorized
+      File Output Operator [FS_118]
+        Limit [LIM_117] (rows=100 width=858)
+          Number of rows:100
+          Select Operator [SEL_116] (rows=11945216 width=857)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+          <-Reducer 5 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_115]
+              Group By Operator [GBY_114] (rows=11945216 width=857)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)"],keys:KEY._col0, KEY._col1, KEY._col2, KEY._col3, KEY._col4, KEY._col5, KEY._col6, KEY._col7, KEY._col8, KEY._col9
+              <-Reducer 4 [SIMPLE_EDGE]
+                SHUFFLE [RS_23]
+                  PartitionCols:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9
+                  Group By Operator [GBY_22] (rows=11945216 width=857)
+                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"],aggregations:["sum(_col10)","sum(_col11)","sum(_col12)","sum(_col13)","sum(_col14)"],keys:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9
+                    Top N Key Operator [TNK_43] (rows=11945216 width=821)
+                      keys:_col0, _col1, _col2, _col3, _col4, _col5, _col6, _col7, _col8, _col9,sort order:++++++++++,top n:100
+                      Select Operator [SEL_20] (rows=11945216 width=821)
+                        Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14"]
+                        Merge Join Operator [MERGEJOIN_96] (rows=11945216 width=821)
+                          Conds:RS_17._col8=RS_113._col0(Inner),Output:["_col0","_col5","_col11","_col12","_col13","_col14","_col15","_col16","_col17","_col18","_col19","_col20"]
+                        <-Map 12 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_113]
+                            PartitionCols:_col0
+                            Select Operator [SEL_112] (rows=1704 width=821)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10"]
+                              TableScan [TS_9] (rows=1704 width=821)
+                                default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_name","s_company_id","s_street_number","s_street_name","s_street_type","s_suite_number","s_city","s_county","s_state","s_zip"]
+                        <-Reducer 3 [SIMPLE_EDGE]
+                          SHUFFLE [RS_17]
+                            PartitionCols:_col8
+                            Merge Join Operator [MERGEJOIN_95] (rows=11945216 width=3)
+                              Conds:RS_14._col1, _col2, _col3=RS_111._col1, _col2, _col4(Inner),Output:["_col0","_col5","_col8"]
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              PARTITION_ONLY_SHUFFLE [RS_14]
+                                PartitionCols:_col1, _col2, _col3
+                                Merge Join Operator [MERGEJOIN_94] (rows=1339446 width=8)
+                                  Conds:RS_99._col0=RS_102._col0(Inner),Output:["_col0","_col1","_col2","_col3"]
+                                <-Map 1 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_99]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_98] (rows=53632139 width=15)
+                                      Output:["_col0","_col1","_col2","_col3"]
+                                      Filter Operator [FIL_97] (rows=53632139 width=15)
+                                        predicate:(sr_customer_sk is not null and sr_returned_date_sk is not null)
+                                        TableScan [TS_0] (rows=57591150 width=15)
+                                          default@store_returns,store_returns,Tbl:COMPLETE,Col:COMPLETE,Output:["sr_returned_date_sk","sr_item_sk","sr_customer_sk","sr_ticket_number"]
+                                <-Map 10 [SIMPLE_EDGE] vectorized
+                                  SHUFFLE [RS_102]
+                                    PartitionCols:_col0
+                                    Select Operator [SEL_101] (rows=50 width=4)
+                                      Output:["_col0"]
+                                      Filter Operator [FIL_100] (rows=50 width=12)
+                                        predicate:((d_moy = 9) and (d_year = 2000))
+                                        TableScan [TS_3] (rows=73049 width=12)
+                                          default@date_dim,d2,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                            <-Map 11 [SIMPLE_EDGE] vectorized
+                              SHUFFLE [RS_111]
+                                PartitionCols:_col1, _col2, _col4
+                                Select Operator [SEL_110] (rows=501694138 width=19)
+                                  Output:["_col0","_col1","_col2","_col3","_col4"]
+                                  Filter Operator [FIL_109] (rows=501694138 width=19)
+                                    predicate:((ss_customer_sk BETWEEN DynamicValue(RS_14_store_returns_sr_customer_sk_min) AND DynamicValue(RS_14_store_returns_sr_customer_sk_max) and in_bloom_filter(ss_customer_sk, DynamicValue(RS_14_store_returns_sr_customer_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_14_store_returns_sr_item_sk_min) AND DynamicValue(RS_14_store_returns_sr_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_14_store_returns_sr_item_sk_bloom_filter))) and (ss_ticket_number BETWEEN DynamicValue(RS_14_store_returns_sr_ticket_number_min) AND DynamicValue(RS_14_store_returns_sr_ticket_number_max) and in_bloom_filter(ss_ticket_number, DynamicValue(RS_14_store_returns_sr_ticket_number_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null and ss_store_sk is not null)
+                                    TableScan [TS_6] (rows=575995635 width=19)
+                                      default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk","ss_store_sk","ss_ticket_number"]
+                                    <-Reducer 7 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_104]
+                                        Group By Operator [GBY_103] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                          PARTITION_ONLY_SHUFFLE [RS_71]
+                                            Group By Operator [GBY_70] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_69] (rows=1339446 width=8)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_94]
+                                    <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_106]
+                                        Group By Operator [GBY_105] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                          PARTITION_ONLY_SHUFFLE [RS_76]
+                                            Group By Operator [GBY_75] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_74] (rows=1339446 width=0)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_94]
+                                    <-Reducer 9 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_108]
+                                        Group By Operator [GBY_107] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                          PARTITION_ONLY_SHUFFLE [RS_81]
+                                            Group By Operator [GBY_80] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_79] (rows=1339446 width=8)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Merge Join Operator [MERGEJOIN_94]
+


[13/75] [abbrv] [partial] hive git commit: HIVE-20718: Add perf cli driver with constraints (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)

Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query59.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query59.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query59.q.out
new file mode 100644
index 0000000..4e7c921
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query59.q.out
@@ -0,0 +1,234 @@
+PREHOOK: query: explain
+with wss as 
+ (select d_week_seq,
+        ss_store_sk,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from store_sales,date_dim
+ where d_date_sk = ss_sold_date_sk
+ group by d_week_seq,ss_store_sk
+ )
+  select  s_store_name1,s_store_id1,d_week_seq1
+       ,sun_sales1/sun_sales2,mon_sales1/mon_sales2
+       ,tue_sales1/tue_sales1,wed_sales1/wed_sales2,thu_sales1/thu_sales2
+       ,fri_sales1/fri_sales2,sat_sales1/sat_sales2
+ from
+ (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
+        ,s_store_id s_store_id1,sun_sales sun_sales1
+        ,mon_sales mon_sales1,tue_sales tue_sales1
+        ,wed_sales wed_sales1,thu_sales thu_sales1
+        ,fri_sales fri_sales1,sat_sales sat_sales1
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185 and 1185 + 11) y,
+ (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
+        ,s_store_id s_store_id2,sun_sales sun_sales2
+        ,mon_sales mon_sales2,tue_sales tue_sales2
+        ,wed_sales wed_sales2,thu_sales thu_sales2
+        ,fri_sales fri_sales2,sat_sales sat_sales2
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185+ 12 and 1185 + 23) x
+ where s_store_id1=s_store_id2
+   and d_week_seq1=d_week_seq2-52
+ order by s_store_name1,s_store_id1,d_week_seq1
+limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@store
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+with wss as 
+ (select d_week_seq,
+        ss_store_sk,
+        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
+        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
+        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
+        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
+        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
+        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
+        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
+ from store_sales,date_dim
+ where d_date_sk = ss_sold_date_sk
+ group by d_week_seq,ss_store_sk
+ )
+  select  s_store_name1,s_store_id1,d_week_seq1
+       ,sun_sales1/sun_sales2,mon_sales1/mon_sales2
+       ,tue_sales1/tue_sales1,wed_sales1/wed_sales2,thu_sales1/thu_sales2
+       ,fri_sales1/fri_sales2,sat_sales1/sat_sales2
+ from
+ (select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
+        ,s_store_id s_store_id1,sun_sales sun_sales1
+        ,mon_sales mon_sales1,tue_sales tue_sales1
+        ,wed_sales wed_sales1,thu_sales thu_sales1
+        ,fri_sales fri_sales1,sat_sales sat_sales1
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185 and 1185 + 11) y,
+ (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
+        ,s_store_id s_store_id2,sun_sales sun_sales2
+        ,mon_sales mon_sales2,tue_sales tue_sales2
+        ,wed_sales wed_sales2,thu_sales thu_sales2
+        ,fri_sales fri_sales2,sat_sales sat_sales2
+  from wss,store,date_dim d
+  where d.d_week_seq = wss.d_week_seq and
+        ss_store_sk = s_store_sk and 
+        d_month_seq between 1185+ 12 and 1185 + 23) x
+ where s_store_id1=s_store_id2
+   and d_week_seq1=d_week_seq2-52
+ order by s_store_name1,s_store_id1,d_week_seq1
+limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@store
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Map 13 (SIMPLE_EDGE), Reducer 9 (SIMPLE_EDGE)
+Reducer 11 <- Map 15 (SIMPLE_EDGE), Reducer 10 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 13 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Map 14 (SIMPLE_EDGE), Reducer 4 (SIMPLE_EDGE)
+Reducer 6 <- Reducer 11 (SIMPLE_EDGE), Reducer 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Map 1 (SIMPLE_EDGE), Map 12 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_207]
+        Limit [LIM_206] (rows=100 width=976)
+          Number of rows:100
+          Select Operator [SEL_205] (rows=1012347 width=976)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+          <-Reducer 6 [SIMPLE_EDGE]
+            SHUFFLE [RS_57]
+              Select Operator [SEL_56] (rows=1012347 width=976)
+                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+                Merge Join Operator [MERGEJOIN_181] (rows=1012347 width=1648)
+                  Conds:RS_53._col11, _col0=RS_54._col0, _col7(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col11","_col12","_col14","_col15","_col16","_col17","_col18","_col19"]
+                <-Reducer 11 [SIMPLE_EDGE]
+                  SHUFFLE [RS_54]
+                    PartitionCols:_col0, _col7
+                    Select Operator [SEL_46] (rows=28847 width=776)
+                      Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                      Merge Join Operator [MERGEJOIN_180] (rows=28847 width=776)
+                        Conds:RS_43._col1=RS_204._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col10"]
+                      <-Map 15 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_204]
+                          PartitionCols:_col0
+                          Select Operator [SEL_203] (rows=1704 width=104)
+                            Output:["_col0","_col1"]
+                            TableScan [TS_38] (rows=1704 width=104)
+                              default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id"]
+                      <-Reducer 10 [SIMPLE_EDGE]
+                        SHUFFLE [RS_43]
+                          PartitionCols:_col1
+                          Merge Join Operator [MERGEJOIN_179] (rows=28847 width=676)
+                            Conds:RS_202._col0=RS_198._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"]
+                          <-Map 13 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_198]
+                              PartitionCols:_col0
+                              Select Operator [SEL_196] (rows=317 width=4)
+                                Output:["_col0"]
+                                Filter Operator [FIL_194] (rows=317 width=8)
+                                  predicate:(d_month_seq BETWEEN 1197 AND 1208 and d_week_seq is not null)
+                                  TableScan [TS_15] (rows=73049 width=8)
+                                    default@date_dim,d,Tbl:COMPLETE,Col:COMPLETE,Output:["d_month_seq","d_week_seq"]
+                          <-Reducer 9 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_202]
+                              PartitionCols:_col0
+                              Group By Operator [GBY_201] (rows=1196832 width=679)
+                                Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)"],keys:KEY._col0, KEY._col1
+                              <-Reducer 8 [SIMPLE_EDGE]
+                                SHUFFLE [RS_32]
+                                  PartitionCols:_col0, _col1
+                                  Group By Operator [GBY_31] (rows=525329897 width=679)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7"],aggregations:["sum(_col2)","sum(_col3)","sum(_col5)","sum(_col6)","sum(_col7)","sum(_col8)"],keys:_col0, _col1
+                                    Select Operator [SEL_29] (rows=525329897 width=138)
+                                      Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7","_col8"]
+                                      Merge Join Operator [MERGEJOIN_178] (rows=525329897 width=138)
+                                        Conds:RS_185._col0=RS_190._col0(Inner),Output:["_col1","_col2","_col4","_col5","_col6","_col8","_col9","_col10","_col11"]
+                                      <-Map 1 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_185]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_183] (rows=525329897 width=114)
+                                            Output:["_col0","_col1","_col2"]
+                                            Filter Operator [FIL_182] (rows=525329897 width=114)
+                                              predicate:(ss_sold_date_sk is not null and ss_store_sk is not null)
+                                              TableScan [TS_0] (rows=575995635 width=114)
+                                                default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_store_sk","ss_sales_price"]
+                                      <-Map 12 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_190]
+                                          PartitionCols:_col0
+                                          Select Operator [SEL_188] (rows=73049 width=36)
+                                            Output:["_col0","_col1","_col2","_col3","_col5","_col6","_col7","_col8"]
+                                            Filter Operator [FIL_186] (rows=73049 width=99)
+                                              predicate:d_week_seq is not null
+                                              TableScan [TS_3] (rows=73049 width=99)
+                                                default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_week_seq","d_day_name"]
+                <-Reducer 5 [SIMPLE_EDGE]
+                  SHUFFLE [RS_53]
+                    PartitionCols:_col11, _col0
+                    Merge Join Operator [MERGEJOIN_177] (rows=28847 width=976)
+                      Conds:RS_50._col1=RS_200._col0(Inner),Output:["_col0","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col11","_col12"]
+                    <-Map 14 [SIMPLE_EDGE] vectorized
+                      SHUFFLE [RS_200]
+                        PartitionCols:_col0
+                        Select Operator [SEL_199] (rows=1704 width=192)
+                          Output:["_col0","_col1","_col2"]
+                          TableScan [TS_18] (rows=1704 width=192)
+                            default@store,store,Tbl:COMPLETE,Col:COMPLETE,Output:["s_store_sk","s_store_id","s_store_name"]
+                    <-Reducer 4 [SIMPLE_EDGE]
+                      SHUFFLE [RS_50]
+                        PartitionCols:_col1
+                        Merge Join Operator [MERGEJOIN_176] (rows=28847 width=788)
+                          Conds:RS_192._col0=RS_197._col0(Inner),Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                        <-Map 13 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_197]
+                            PartitionCols:_col0
+                            Select Operator [SEL_195] (rows=317 width=4)
+                              Output:["_col0"]
+                              Filter Operator [FIL_193] (rows=317 width=8)
+                                predicate:(d_month_seq BETWEEN 1185 AND 1196 and d_week_seq is not null)
+                                 Please refer to the previous TableScan [TS_15]
+                        <-Reducer 3 [SIMPLE_EDGE] vectorized
+                          SHUFFLE [RS_192]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_191] (rows=1196832 width=791)
+                              Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(VALUE._col0)","sum(VALUE._col1)","sum(VALUE._col2)","sum(VALUE._col3)","sum(VALUE._col4)","sum(VALUE._col5)","sum(VALUE._col6)"],keys:KEY._col0, KEY._col1
+                            <-Reducer 2 [SIMPLE_EDGE]
+                              SHUFFLE [RS_12]
+                                PartitionCols:_col0, _col1
+                                Group By Operator [GBY_11] (rows=525329897 width=791)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"],aggregations:["sum(_col2)","sum(_col3)","sum(_col4)","sum(_col5)","sum(_col6)","sum(_col7)","sum(_col8)"],keys:_col0, _col1
+                                  Select Operator [SEL_9] (rows=525329897 width=142)
+                                    Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                    Merge Join Operator [MERGEJOIN_175] (rows=525329897 width=142)
+                                      Conds:RS_184._col0=RS_189._col0(Inner),Output:["_col1","_col2","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11"]
+                                    <-Map 1 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_184]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_183]
+                                    <-Map 12 [SIMPLE_EDGE] vectorized
+                                      SHUFFLE [RS_189]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_187] (rows=73049 width=36)
+                                          Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8"]
+                                           Please refer to the previous Filter Operator [FIL_186]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out
new file mode 100644
index 0000000..85c962f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query6.q.out
@@ -0,0 +1,236 @@
+Warning: Map Join MAPJOIN[172][bigTable=?] in task 'Reducer 15' is a cross product
+PREHOOK: query: explain
+select  a.ca_state state, count(*) cnt
+ from customer_address a
+     ,customer c
+     ,store_sales s
+     ,date_dim d
+     ,item i
+ where       a.ca_address_sk = c.c_current_addr_sk
+ 	and c.c_customer_sk = s.ss_customer_sk
+ 	and s.ss_sold_date_sk = d.d_date_sk
+ 	and s.ss_item_sk = i.i_item_sk
+ 	and d.d_month_seq = 
+ 	     (select distinct (d_month_seq)
+ 	      from date_dim
+               where d_year = 2000
+ 	        and d_moy = 2 )
+ 	and i.i_current_price > 1.2 * 
+             (select avg(j.i_current_price) 
+ 	     from item j 
+ 	     where j.i_category = i.i_category)
+ group by a.ca_state
+ having count(*) >= 10
+ order by cnt 
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@customer
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+POSTHOOK: query: explain
+select  a.ca_state state, count(*) cnt
+ from customer_address a
+     ,customer c
+     ,store_sales s
+     ,date_dim d
+     ,item i
+ where       a.ca_address_sk = c.c_current_addr_sk
+ 	and c.c_customer_sk = s.ss_customer_sk
+ 	and s.ss_sold_date_sk = d.d_date_sk
+ 	and s.ss_item_sk = i.i_item_sk
+ 	and d.d_month_seq = 
+ 	     (select distinct (d_month_seq)
+ 	      from date_dim
+               where d_year = 2000
+ 	        and d_moy = 2 )
+ 	and i.i_current_price > 1.2 * 
+             (select avg(j.i_current_price) 
+ 	     from item j 
+ 	     where j.i_category = i.i_category)
+ group by a.ca_state
+ having count(*) >= 10
+ order by cnt 
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@customer
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 1 <- Reducer 3 (BROADCAST_EDGE)
+Map 16 <- Reducer 15 (BROADCAST_EDGE)
+Map 6 <- Map 1 (BROADCAST_EDGE), Reducer 17 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 12 <- Map 11 (SIMPLE_EDGE), Map 13 (SIMPLE_EDGE)
+Reducer 15 <- Map 14 (SIMPLE_EDGE), Reducer 5 (BROADCAST_EDGE)
+Reducer 17 <- Map 16 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Map 2 (SIMPLE_EDGE)
+Reducer 4 <- Map 2 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (CUSTOM_SIMPLE_EDGE)
+Reducer 7 <- Map 6 (SIMPLE_EDGE), Reducer 12 (SIMPLE_EDGE)
+Reducer 8 <- Map 16 (SIMPLE_EDGE), Reducer 7 (SIMPLE_EDGE)
+Reducer 9 <- Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 10 vectorized
+      File Output Operator [FS_234]
+        Limit [LIM_233] (rows=1 width=94)
+          Number of rows:100
+          Select Operator [SEL_232] (rows=1 width=94)
+            Output:["_col0","_col1"]
+          <-Reducer 9 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_231]
+              Filter Operator [FIL_230] (rows=1 width=94)
+                predicate:(_col1 >= 10L)
+                Group By Operator [GBY_229] (rows=1 width=94)
+                  Output:["_col0","_col1"],aggregations:["count(VALUE._col0)"],keys:KEY._col0
+                <-Reducer 8 [SIMPLE_EDGE]
+                  SHUFFLE [RS_68]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_67] (rows=1 width=94)
+                      Output:["_col0","_col1"],aggregations:["count()"],keys:_col9
+                      Merge Join Operator [MERGEJOIN_175] (rows=316 width=86)
+                        Conds:RS_63._col4=RS_214._col0(Inner),Output:["_col9"]
+                      <-Map 16 [SIMPLE_EDGE] vectorized
+                        SHUFFLE [RS_214]
+                          PartitionCols:_col0
+                          Select Operator [SEL_213] (rows=154000 width=227)
+                            Output:["_col0"]
+                            Filter Operator [FIL_212] (rows=154000 width=227)
+                              predicate:(_col4 > _col1)
+                              Map Join Operator [MAPJOIN_211] (rows=462000 width=227)
+                                Conds:RS_208._col0=SEL_210._col2(Inner),HybridGraceHashJoin:true,Output:["_col1","_col3","_col4"]
+                              <-Reducer 15 [BROADCAST_EDGE] vectorized
+                                BROADCAST [RS_208]
+                                  PartitionCols:_col0
+                                  Map Join Operator [MAPJOIN_207] (rows=10 width=202)
+                                    Conds:(Inner),Output:["_col0","_col1"]
+                                  <-Reducer 5 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_204]
+                                      Select Operator [SEL_203] (rows=1 width=8)
+                                        Filter Operator [FIL_202] (rows=1 width=8)
+                                          predicate:(sq_count_check(_col0) <= 1)
+                                          Group By Operator [GBY_201] (rows=1 width=8)
+                                            Output:["_col0"],aggregations:["count(VALUE._col0)"]
+                                          <-Reducer 4 [CUSTOM_SIMPLE_EDGE] vectorized
+                                            PARTITION_ONLY_SHUFFLE [RS_200]
+                                              Group By Operator [GBY_199] (rows=1 width=8)
+                                                Output:["_col0"],aggregations:["count()"]
+                                                Select Operator [SEL_198] (rows=25 width=4)
+                                                  Group By Operator [GBY_197] (rows=25 width=4)
+                                                    Output:["_col0"],keys:KEY._col0
+                                                  <-Map 2 [SIMPLE_EDGE] vectorized
+                                                    SHUFFLE [RS_187]
+                                                      PartitionCols:_col0
+                                                      Group By Operator [GBY_185] (rows=25 width=4)
+                                                        Output:["_col0"],keys:d_month_seq
+                                                        Select Operator [SEL_183] (rows=50 width=12)
+                                                          Output:["d_month_seq"]
+                                                          Filter Operator [FIL_181] (rows=50 width=12)
+                                                            predicate:((d_moy = 2) and (d_year = 2000))
+                                                            TableScan [TS_3] (rows=73049 width=12)
+                                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_month_seq","d_year","d_moy"]
+                                  <-Select Operator [SEL_206] (rows=10 width=202)
+                                      Output:["_col0","_col1"]
+                                      Group By Operator [GBY_205] (rows=10 width=210)
+                                        Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)","count(VALUE._col1)"],keys:KEY._col0
+                                      <-Map 14 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_196]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_195] (rows=10 width=210)
+                                            Output:["_col0","_col1","_col2"],aggregations:["sum(i_current_price)","count(i_current_price)"],keys:i_category
+                                            Filter Operator [FIL_194] (rows=462000 width=201)
+                                              predicate:i_category is not null
+                                              TableScan [TS_22] (rows=462000 width=201)
+                                                default@item,j,Tbl:COMPLETE,Col:COMPLETE,Output:["i_current_price","i_category"]
+                              <-Select Operator [SEL_210] (rows=462000 width=205)
+                                  Output:["_col0","_col1","_col2"]
+                                  Filter Operator [FIL_209] (rows=462000 width=205)
+                                    predicate:i_category is not null
+                                    TableScan [TS_43] (rows=462000 width=205)
+                                      default@item,i,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_current_price","i_category"]
+                      <-Reducer 7 [SIMPLE_EDGE]
+                        SHUFFLE [RS_63]
+                          PartitionCols:_col4
+                          Merge Join Operator [MERGEJOIN_174] (rows=7192227 width=90)
+                            Conds:RS_223._col5=RS_61._col0(Inner),Output:["_col4","_col9"]
+                          <-Map 6 [SIMPLE_EDGE] vectorized
+                            SHUFFLE [RS_223]
+                              PartitionCols:_col5
+                              Map Join Operator [MAPJOIN_222] (rows=7192227 width=4)
+                                Conds:RS_193._col0=SEL_221._col0(Inner),HybridGraceHashJoin:true,Output:["_col4","_col5"]
+                              <-Map 1 [BROADCAST_EDGE] vectorized
+                                BROADCAST [RS_193]
+                                  PartitionCols:_col0
+                                  Map Join Operator [MAPJOIN_192] (rows=660 width=4)
+                                    Conds:SEL_191._col1=RS_189._col0(Inner),HybridGraceHashJoin:true,Output:["_col0"]
+                                  <-Reducer 3 [BROADCAST_EDGE] vectorized
+                                    BROADCAST [RS_189]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_188] (rows=25 width=4)
+                                        Output:["_col0"],keys:KEY._col0
+                                      <-Map 2 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_186]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_184] (rows=25 width=4)
+                                            Output:["_col0"],keys:d_month_seq
+                                            Select Operator [SEL_182] (rows=50 width=12)
+                                              Output:["d_month_seq"]
+                                              Filter Operator [FIL_180] (rows=50 width=12)
+                                                predicate:((d_moy = 2) and (d_year = 2000) and d_month_seq is not null)
+                                                 Please refer to the previous TableScan [TS_3]
+                                  <-Select Operator [SEL_191] (rows=73049 width=8)
+                                      Output:["_col0","_col1"]
+                                      Filter Operator [FIL_190] (rows=73049 width=8)
+                                        predicate:d_month_seq is not null
+                                        TableScan [TS_0] (rows=73049 width=8)
+                                          default@date_dim,d,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_month_seq"]
+                              <-Select Operator [SEL_221] (rows=525327388 width=11)
+                                  Output:["_col0","_col1","_col2"]
+                                  Filter Operator [FIL_220] (rows=525327388 width=11)
+                                    predicate:((ss_item_sk BETWEEN DynamicValue(RS_64_i_i_item_sk_min) AND DynamicValue(RS_64_i_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_64_i_i_item_sk_bloom_filter))) and ss_customer_sk is not null and ss_sold_date_sk is not null)
+                                    TableScan [TS_10] (rows=575995635 width=11)
+                                      default@store_sales,s,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_customer_sk"]
+                                    <-Reducer 17 [BROADCAST_EDGE] vectorized
+                                      BROADCAST [RS_219]
+                                        Group By Operator [GBY_218] (rows=1 width=12)
+                                          Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                        <-Map 16 [CUSTOM_SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_217]
+                                            Group By Operator [GBY_216] (rows=1 width=12)
+                                              Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                              Select Operator [SEL_215] (rows=154000 width=4)
+                                                Output:["_col0"]
+                                                 Please refer to the previous Select Operator [SEL_213]
+                          <-Reducer 12 [SIMPLE_EDGE]
+                            SHUFFLE [RS_61]
+                              PartitionCols:_col0
+                              Merge Join Operator [MERGEJOIN_171] (rows=80000000 width=90)
+                                Conds:RS_226._col1=RS_228._col0(Inner),Output:["_col0","_col3"]
+                              <-Map 11 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_226]
+                                  PartitionCols:_col1
+                                  Select Operator [SEL_225] (rows=80000000 width=8)
+                                    Output:["_col0","_col1"]
+                                    Filter Operator [FIL_224] (rows=80000000 width=8)
+                                      predicate:c_current_addr_sk is not null
+                                      TableScan [TS_13] (rows=80000000 width=8)
+                                        default@customer,c,Tbl:COMPLETE,Col:COMPLETE,Output:["c_customer_sk","c_current_addr_sk"]
+                              <-Map 13 [SIMPLE_EDGE] vectorized
+                                SHUFFLE [RS_228]
+                                  PartitionCols:_col0
+                                  Select Operator [SEL_227] (rows=40000000 width=90)
+                                    Output:["_col0","_col1"]
+                                    TableScan [TS_16] (rows=40000000 width=90)
+                                      default@customer_address,a,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_state"]
+

http://git-wip-us.apache.org/repos/asf/hive/blob/b8299551/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out b/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out
new file mode 100644
index 0000000..cb94e4f
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/tez/constraints/query60.q.out
@@ -0,0 +1,496 @@
+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_category in ('Children'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ 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 i_item_id
+      ,total_sales
+ limit 100
+PREHOOK: type: QUERY
+PREHOOK: Input: default@catalog_sales
+PREHOOK: Input: default@customer_address
+PREHOOK: Input: default@date_dim
+PREHOOK: Input: default@item
+PREHOOK: Input: default@store_sales
+PREHOOK: Input: default@web_sales
+PREHOOK: Output: hdfs://### HDFS PATH ###
+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_category in ('Children'))
+ and     ss_item_sk              = i_item_sk
+ and     ss_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ss_addr_sk              = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     cs_item_sk              = i_item_sk
+ and     cs_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     cs_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6 
+ 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_category in ('Children'))
+ and     ws_item_sk              = i_item_sk
+ and     ws_sold_date_sk         = d_date_sk
+ and     d_year                  = 1999
+ and     d_moy                   = 9
+ and     ws_bill_addr_sk         = ca_address_sk
+ and     ca_gmt_offset           = -6
+ 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 i_item_id
+      ,total_sales
+ limit 100
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@catalog_sales
+POSTHOOK: Input: default@customer_address
+POSTHOOK: Input: default@date_dim
+POSTHOOK: Input: default@item
+POSTHOOK: Input: default@store_sales
+POSTHOOK: Input: default@web_sales
+POSTHOOK: Output: hdfs://### HDFS PATH ###
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Map 17 <- Reducer 21 (BROADCAST_EDGE), Reducer 29 (BROADCAST_EDGE), Reducer 8 (BROADCAST_EDGE)
+Map 32 <- Reducer 11 (BROADCAST_EDGE), Reducer 24 (BROADCAST_EDGE), Reducer 30 (BROADCAST_EDGE)
+Map 33 <- Reducer 14 (BROADCAST_EDGE), Reducer 27 (BROADCAST_EDGE), Reducer 31 (BROADCAST_EDGE)
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 11 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 12 <- Reducer 2 (SIMPLE_EDGE), Reducer 26 (SIMPLE_EDGE)
+Reducer 13 <- Reducer 12 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 14 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 16 <- Map 15 (SIMPLE_EDGE)
+Reducer 18 <- Map 17 (SIMPLE_EDGE), Map 20 (SIMPLE_EDGE)
+Reducer 19 <- Map 28 (SIMPLE_EDGE), Reducer 18 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Reducer 16 (ONE_TO_ONE_EDGE)
+Reducer 21 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 22 <- Map 20 (SIMPLE_EDGE), Map 32 (SIMPLE_EDGE)
+Reducer 23 <- Map 28 (SIMPLE_EDGE), Reducer 22 (SIMPLE_EDGE)
+Reducer 24 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 25 <- Map 20 (SIMPLE_EDGE), Map 33 (SIMPLE_EDGE)
+Reducer 26 <- Map 28 (SIMPLE_EDGE), Reducer 25 (SIMPLE_EDGE)
+Reducer 27 <- Map 20 (CUSTOM_SIMPLE_EDGE)
+Reducer 29 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 3 <- Reducer 19 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 30 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 31 <- Map 28 (CUSTOM_SIMPLE_EDGE)
+Reducer 4 <- Reducer 3 (SIMPLE_EDGE), Union 5 (CONTAINS)
+Reducer 6 <- Union 5 (SIMPLE_EDGE)
+Reducer 7 <- Reducer 6 (SIMPLE_EDGE)
+Reducer 8 <- Reducer 2 (CUSTOM_SIMPLE_EDGE)
+Reducer 9 <- Reducer 2 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 7 vectorized
+      File Output Operator [FS_375]
+        Limit [LIM_374] (rows=100 width=212)
+          Number of rows:100
+          Select Operator [SEL_373] (rows=1717 width=212)
+            Output:["_col0","_col1"]
+          <-Reducer 6 [SIMPLE_EDGE] vectorized
+            SHUFFLE [RS_372]
+              Group By Operator [GBY_371] (rows=1717 width=212)
+                Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+              <-Union 5 [SIMPLE_EDGE]
+                <-Reducer 10 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_388]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_387] (rows=1717 width=212)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Top N Key Operator [TNK_386] (rows=5151 width=212)
+                        keys:_col0,sort order:+,top n:100
+                        Group By Operator [GBY_385] (rows=1717 width=212)
+                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                        <-Reducer 9 [SIMPLE_EDGE]
+                          SHUFFLE [RS_69]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_68] (rows=1717 width=212)
+                              Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                              Merge Join Operator [MERGEJOIN_305] (rows=746132 width=100)
+                                Conds:RS_64._col0=RS_65._col3(Inner),Output:["_col1","_col7"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_64]
+                                  PartitionCols:_col0
+                                  Merge Join Operator [MERGEJOIN_295] (rows=34340 width=104)
+                                    Conds:RS_323._col1=RS_329._col0(Inner),Output:["_col0","_col1"]
+                                  <-Map 1 [SIMPLE_EDGE] vectorized
+                                    SHUFFLE [RS_323]
+                                      PartitionCols:_col1
+                                      Select Operator [SEL_322] (rows=462000 width=104)
+                                        Output:["_col0","_col1"]
+                                        TableScan [TS_0] (rows=462000 width=104)
+                                          default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_sk","i_item_id"]
+                                  <-Reducer 16 [ONE_TO_ONE_EDGE] vectorized
+                                    FORWARD [RS_329]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_328] (rows=23100 width=100)
+                                        Output:["_col0"],keys:KEY._col0
+                                      <-Map 15 [SIMPLE_EDGE] vectorized
+                                        SHUFFLE [RS_327]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_326] (rows=23100 width=100)
+                                            Output:["_col0"],keys:i_item_id
+                                            Select Operator [SEL_325] (rows=46200 width=190)
+                                              Output:["i_item_id"]
+                                              Filter Operator [FIL_324] (rows=46200 width=190)
+                                                predicate:(i_category = 'Children')
+                                                TableScan [TS_2] (rows=462000 width=190)
+                                                  default@item,item,Tbl:COMPLETE,Col:COMPLETE,Output:["i_item_id","i_category"]
+                              <-Reducer 23 [SIMPLE_EDGE]
+                                SHUFFLE [RS_65]
+                                  PartitionCols:_col3
+                                  Select Operator [SEL_60] (rows=1550375 width=13)
+                                    Output:["_col3","_col4"]
+                                    Merge Join Operator [MERGEJOIN_300] (rows=1550375 width=13)
+                                      Conds:RS_57._col1=RS_350._col0(Inner),Output:["_col2","_col3"]
+                                    <-Map 28 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_350]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_347] (rows=8000000 width=4)
+                                          Output:["_col0"]
+                                          Filter Operator [FIL_346] (rows=8000000 width=112)
+                                            predicate:(ca_gmt_offset = -6)
+                                            TableScan [TS_15] (rows=40000000 width=112)
+                                              default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE,Output:["ca_address_sk","ca_gmt_offset"]
+                                    <-Reducer 22 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_57]
+                                        PartitionCols:_col1
+                                        Merge Join Operator [MERGEJOIN_299] (rows=7751872 width=98)
+                                          Conds:RS_384._col0=RS_334._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 20 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_334]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_331] (rows=50 width=4)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_330] (rows=50 width=12)
+                                                predicate:((d_moy = 9) and (d_year = 1999))
+                                                TableScan [TS_12] (rows=73049 width=12)
+                                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:COMPLETE,Output:["d_date_sk","d_year","d_moy"]
+                                        <-Map 32 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_384]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_383] (rows=285117733 width=123)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_382] (rows=285117733 width=123)
+                                                predicate:((cs_bill_addr_sk BETWEEN DynamicValue(RS_58_customer_address_ca_address_sk_min) AND DynamicValue(RS_58_customer_address_ca_address_sk_max) and in_bloom_filter(cs_bill_addr_sk, DynamicValue(RS_58_customer_address_ca_address_sk_bloom_filter))) and (cs_item_sk BETWEEN DynamicValue(RS_64_item_i_item_sk_min) AND DynamicValue(RS_64_item_i_item_sk_max) and in_bloom_filter(cs_item_sk, DynamicValue(RS_64_item_i_item_sk_bloom_filter))) and (cs_sold_date_sk BETWEEN DynamicValue(RS_55_date_dim_d_date_sk_min) AND DynamicValue(RS_55_date_dim_d_date_sk_max) and in_bloom_filter(cs_sold_date_sk, DynamicValue(RS_55_date_dim_d_date_sk_bloom_filter))) and cs_bill_addr_sk is not null and cs_sold_date_sk is not null)
+                                                TableScan [TS_45] (rows=287989836 width=123)
+                                                  default@catalog_sales,catalog_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["cs_sold_date_sk","cs_bill_addr_sk","cs_item_sk","cs_ext_sales_price"]
+                                                <-Reducer 11 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_381]
+                                                    Group By Operator [GBY_380] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_240]
+                                                        Group By Operator [GBY_239] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_238] (rows=34340 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                                                <-Reducer 24 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_377]
+                                                    Group By Operator [GBY_376] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_342]
+                                                        Group By Operator [GBY_339] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_335] (rows=50 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_331]
+                                                <-Reducer 30 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_379]
+                                                    Group By Operator [GBY_378] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                    <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_358]
+                                                        Group By Operator [GBY_355] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                          Select Operator [SEL_351] (rows=8000000 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_347]
+                <-Reducer 13 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_401]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_400] (rows=1717 width=212)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Top N Key Operator [TNK_399] (rows=5151 width=212)
+                        keys:_col0,sort order:+,top n:100
+                        Group By Operator [GBY_398] (rows=1717 width=212)
+                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                        <-Reducer 12 [SIMPLE_EDGE]
+                          SHUFFLE [RS_106]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_105] (rows=1717 width=212)
+                              Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                              Merge Join Operator [MERGEJOIN_306] (rows=379339 width=201)
+                                Conds:RS_101._col0=RS_102._col2(Inner),Output:["_col1","_col7"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_101]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                              <-Reducer 26 [SIMPLE_EDGE]
+                                SHUFFLE [RS_102]
+                                  PartitionCols:_col2
+                                  Select Operator [SEL_97] (rows=788222 width=110)
+                                    Output:["_col2","_col4"]
+                                    Merge Join Operator [MERGEJOIN_303] (rows=788222 width=110)
+                                      Conds:RS_94._col2=RS_352._col0(Inner),Output:["_col1","_col3"]
+                                    <-Map 28 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_352]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_347]
+                                    <-Reducer 25 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_94]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_302] (rows=3941109 width=118)
+                                          Conds:RS_397._col0=RS_336._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 20 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_336]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_331]
+                                        <-Map 33 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_397]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_396] (rows=143931246 width=123)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_395] (rows=143931246 width=123)
+                                                predicate:((ws_bill_addr_sk BETWEEN DynamicValue(RS_95_customer_address_ca_address_sk_min) AND DynamicValue(RS_95_customer_address_ca_address_sk_max) and in_bloom_filter(ws_bill_addr_sk, DynamicValue(RS_95_customer_address_ca_address_sk_bloom_filter))) and (ws_item_sk BETWEEN DynamicValue(RS_101_item_i_item_sk_min) AND DynamicValue(RS_101_item_i_item_sk_max) and in_bloom_filter(ws_item_sk, DynamicValue(RS_101_item_i_item_sk_bloom_filter))) and (ws_sold_date_sk BETWEEN DynamicValue(RS_92_date_dim_d_date_sk_min) AND DynamicValue(RS_92_date_dim_d_date_sk_max) and in_bloom_filter(ws_sold_date_sk, DynamicValue(RS_92_date_dim_d_date_sk_bloom_filter))) and ws_bill_addr_sk is not null and ws_sold_date_sk is not null)
+                                                TableScan [TS_82] (rows=144002668 width=123)
+                                                  default@web_sales,web_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ws_sold_date_sk","ws_item_sk","ws_bill_addr_sk","ws_ext_sales_price"]
+                                                <-Reducer 14 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_394]
+                                                    Group By Operator [GBY_393] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_286]
+                                                        Group By Operator [GBY_285] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_284] (rows=34340 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                                                <-Reducer 27 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_390]
+                                                    Group By Operator [GBY_389] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_343]
+                                                        Group By Operator [GBY_340] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_337] (rows=50 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_331]
+                                                <-Reducer 31 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_392]
+                                                    Group By Operator [GBY_391] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                    <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_359]
+                                                        Group By Operator [GBY_356] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                          Select Operator [SEL_353] (rows=8000000 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_347]
+                <-Reducer 4 [CONTAINS] vectorized
+                  Reduce Output Operator [RS_370]
+                    PartitionCols:_col0
+                    Group By Operator [GBY_369] (rows=1717 width=212)
+                      Output:["_col0","_col1"],aggregations:["sum(_col1)"],keys:_col0
+                      Top N Key Operator [TNK_368] (rows=5151 width=212)
+                        keys:_col0,sort order:+,top n:100
+                        Group By Operator [GBY_367] (rows=1717 width=212)
+                          Output:["_col0","_col1"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0
+                        <-Reducer 3 [SIMPLE_EDGE]
+                          SHUFFLE [RS_33]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_32] (rows=1717 width=212)
+                              Output:["_col0","_col1"],aggregations:["sum(_col7)"],keys:_col1
+                              Merge Join Operator [MERGEJOIN_304] (rows=1384530 width=100)
+                                Conds:RS_28._col0=RS_29._col2(Inner),Output:["_col1","_col7"]
+                              <-Reducer 2 [SIMPLE_EDGE]
+                                SHUFFLE [RS_28]
+                                  PartitionCols:_col0
+                                   Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+                              <-Reducer 19 [SIMPLE_EDGE]
+                                SHUFFLE [RS_29]
+                                  PartitionCols:_col2
+                                  Select Operator [SEL_24] (rows=2876890 width=4)
+                                    Output:["_col2","_col4"]
+                                    Merge Join Operator [MERGEJOIN_297] (rows=2876890 width=4)
+                                      Conds:RS_21._col2=RS_348._col0(Inner),Output:["_col1","_col3"]
+                                    <-Map 28 [SIMPLE_EDGE] vectorized
+                                      PARTITION_ONLY_SHUFFLE [RS_348]
+                                        PartitionCols:_col0
+                                         Please refer to the previous Select Operator [SEL_347]
+                                    <-Reducer 18 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_21]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_296] (rows=14384447 width=4)
+                                          Conds:RS_366._col0=RS_332._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 20 [SIMPLE_EDGE] vectorized
+                                          PARTITION_ONLY_SHUFFLE [RS_332]
+                                            PartitionCols:_col0
+                                             Please refer to the previous Select Operator [SEL_331]
+                                        <-Map 17 [SIMPLE_EDGE] vectorized
+                                          SHUFFLE [RS_366]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_365] (rows=525327191 width=118)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_364] (rows=525327191 width=118)
+                                                predicate:((ss_addr_sk BETWEEN DynamicValue(RS_22_customer_address_ca_address_sk_min) AND DynamicValue(RS_22_customer_address_ca_address_sk_max) and in_bloom_filter(ss_addr_sk, DynamicValue(RS_22_customer_address_ca_address_sk_bloom_filter))) and (ss_item_sk BETWEEN DynamicValue(RS_28_item_i_item_sk_min) AND DynamicValue(RS_28_item_i_item_sk_max) and in_bloom_filter(ss_item_sk, DynamicValue(RS_28_item_i_item_sk_bloom_filter))) and (ss_sold_date_sk BETWEEN DynamicValue(RS_19_date_dim_d_date_sk_min) AND DynamicValue(RS_19_date_dim_d_date_sk_max) and in_bloom_filter(ss_sold_date_sk, DynamicValue(RS_19_date_dim_d_date_sk_bloom_filter))) and ss_addr_sk is not null and ss_sold_date_sk is not null)
+                                                TableScan [TS_9] (rows=575995635 width=118)
+                                                  default@store_sales,store_sales,Tbl:COMPLETE,Col:COMPLETE,Output:["ss_sold_date_sk","ss_item_sk","ss_addr_sk","ss_ext_sales_price"]
+                                                <-Reducer 21 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_345]
+                                                    Group By Operator [GBY_344] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Map 20 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_341]
+                                                        Group By Operator [GBY_338] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_333] (rows=50 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_331]
+                                                <-Reducer 29 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_361]
+                                                    Group By Operator [GBY_360] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=8000000)"]
+                                                    <-Map 28 [CUSTOM_SIMPLE_EDGE] vectorized
+                                                      PARTITION_ONLY_SHUFFLE [RS_357]
+                                                        Group By Operator [GBY_354] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=8000000)"]
+                                                          Select Operator [SEL_349] (rows=8000000 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Select Operator [SEL_347]
+                                                <-Reducer 8 [BROADCAST_EDGE] vectorized
+                                                  BROADCAST [RS_363]
+                                                    Group By Operator [GBY_362] (rows=1 width=12)
+                                                      Output:["_col0","_col1","_col2"],aggregations:["min(VALUE._col0)","max(VALUE._col1)","bloom_filter(VALUE._col2, expectedEntries=1000000)"]
+                                                    <-Reducer 2 [CUSTOM_SIMPLE_EDGE]
+                                                      SHUFFLE [RS_204]
+                                                        Group By Operator [GBY_203] (rows=1 width=12)
+                                                          Output:["_col0","_col1","_col2"],aggregations:["min(_col0)","max(_col0)","bloom_filter(_col0, expectedEntries=1000000)"]
+                                                          Select Operator [SEL_202] (rows=34340 width=4)
+                                                            Output:["_col0"]
+                                                             Please refer to the previous Merge Join Operator [MERGEJOIN_295]
+