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

[02/10] hive git commit: HIVE-15544 : Support scalar subqueries (Vineet Garg via Ashutosh Chauhan)

http://git-wip-us.apache.org/repos/asf/hive/blob/d9343f6d/ql/src/test/results/clientpositive/perf/query81.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/perf/query81.q.out b/ql/src/test/results/clientpositive/perf/query81.q.out
new file mode 100644
index 0000000..92616b2
--- /dev/null
+++ b/ql/src/test/results/clientpositive/perf/query81.q.out
@@ -0,0 +1,308 @@
+Warning: Shuffle Join MERGEJOIN[154][tables = [$hdt$_4, $hdt$_5, $hdt$_6]] in Stage 'Reducer 22' is a cross product
+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
+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
+Plan optimized by CBO.
+
+Vertex dependency in root stage
+Reducer 10 <- Reducer 9 (SIMPLE_EDGE)
+Reducer 14 <- Map 13 (SIMPLE_EDGE), Map 19 (SIMPLE_EDGE)
+Reducer 15 <- Map 20 (SIMPLE_EDGE), Reducer 14 (SIMPLE_EDGE)
+Reducer 16 <- Reducer 15 (SIMPLE_EDGE)
+Reducer 17 <- Reducer 16 (SIMPLE_EDGE), Reducer 23 (SIMPLE_EDGE)
+Reducer 18 <- Reducer 17 (SIMPLE_EDGE)
+Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 6 (SIMPLE_EDGE)
+Reducer 22 <- Map 21 (SIMPLE_EDGE), Map 30 (SIMPLE_EDGE), Reducer 27 (SIMPLE_EDGE)
+Reducer 23 <- Reducer 22 (SIMPLE_EDGE)
+Reducer 25 <- Map 24 (SIMPLE_EDGE), Map 28 (SIMPLE_EDGE)
+Reducer 26 <- Map 29 (SIMPLE_EDGE), Reducer 25 (SIMPLE_EDGE)
+Reducer 27 <- Reducer 26 (SIMPLE_EDGE)
+Reducer 3 <- Reducer 10 (SIMPLE_EDGE), Reducer 2 (SIMPLE_EDGE)
+Reducer 4 <- Reducer 18 (SIMPLE_EDGE), Reducer 3 (SIMPLE_EDGE)
+Reducer 5 <- Reducer 4 (SIMPLE_EDGE)
+Reducer 8 <- Map 11 (SIMPLE_EDGE), Map 7 (SIMPLE_EDGE)
+Reducer 9 <- Map 12 (SIMPLE_EDGE), Reducer 8 (SIMPLE_EDGE)
+
+Stage-0
+  Fetch Operator
+    limit:100
+    Stage-1
+      Reducer 5
+      File Output Operator [FS_102]
+        Limit [LIM_101] (rows=100 width=1)
+          Number of rows:100
+          Select Operator [SEL_100] (rows=930023387364950016 width=1)
+            Output:["_col0","_col1","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9","_col10","_col11","_col12","_col13","_col14","_col15"]
+          <-Reducer 4 [SIMPLE_EDGE]
+            SHUFFLE [RS_99]
+              Select Operator [SEL_98] (rows=930023387364950016 width=1)
+                Output:["_col0","_col1","_col11","_col12","_col13","_col14","_col15","_col2","_col3","_col4","_col5","_col6","_col7","_col8","_col9"]
+                Filter Operator [FIL_97] (rows=930023387364950016 width=1)
+                  predicate:(_col2 > CASE WHEN (_col22 is null) THEN (null) ELSE (_col21) END)
+                  Select Operator [SEL_96] (rows=2790070162094850048 width=1)
+                    Output:["_col2","_col4","_col5","_col6","_col7","_col8","_col9","_col11","_col12","_col13","_col14","_col16","_col18","_col19","_col20","_col21","_col22"]
+                    Merge Join Operator [MERGEJOIN_162] (rows=2790070162094850048 width=1)
+                      Conds:RS_93._col19=RS_94._col2(Left Outer),Output:["_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col20","_col21","_col22"]
+                    <-Reducer 18 [SIMPLE_EDGE]
+                      SHUFFLE [RS_94]
+                        PartitionCols:_col2
+                        Select Operator [SEL_86] (rows=2536427365110644736 width=1)
+                          Output:["_col0","_col1","_col2"]
+                          Group By Operator [GBY_85] (rows=2536427365110644736 width=1)
+                            Output:["_col0","_col1"],aggregations:["avg(VALUE._col0)"],keys:KEY._col0
+                          <-Reducer 17 [SIMPLE_EDGE]
+                            SHUFFLE [RS_84]
+                              PartitionCols:_col0
+                              Group By Operator [GBY_83] (rows=5072854730221289472 width=1)
+                                Output:["_col0","_col1"],aggregations:["avg(_col2)"],keys:_col3
+                                Select Operator [SEL_82] (rows=5072854730221289472 width=1)
+                                  Output:["_col3","_col2"]
+                                  Merge Join Operator [MERGEJOIN_161] (rows=5072854730221289472 width=1)
+                                    Conds:RS_79._col1=RS_80._col0(Inner),Output:["_col2","_col3"]
+                                  <-Reducer 16 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_79]
+                                      PartitionCols:_col1
+                                      Select Operator [SEL_45] (rows=22000000 width=1014)
+                                        Output:["_col1","_col2"]
+                                        Group By Operator [GBY_44] (rows=22000000 width=1014)
+                                          Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                                        <-Reducer 15 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_43]
+                                            PartitionCols:_col0, _col1
+                                            Group By Operator [GBY_42] (rows=44000000 width=1014)
+                                              Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col7, _col1
+                                              Select Operator [SEL_41] (rows=44000000 width=1014)
+                                                Output:["_col7","_col1","_col3"]
+                                                Merge Join Operator [MERGEJOIN_159] (rows=44000000 width=1014)
+                                                  Conds:RS_38._col2=RS_39._col0(Inner),Output:["_col1","_col3","_col7"]
+                                                <-Map 20 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_39]
+                                                    PartitionCols:_col0
+                                                    Select Operator [SEL_34] (rows=40000000 width=1014)
+                                                      Output:["_col0","_col1"]
+                                                      Filter Operator [FIL_148] (rows=40000000 width=1014)
+                                                        predicate:ca_address_sk is not null
+                                                        TableScan [TS_32] (rows=40000000 width=1014)
+                                                          default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state"]
+                                                <-Reducer 14 [SIMPLE_EDGE]
+                                                  SHUFFLE [RS_38]
+                                                    PartitionCols:_col2
+                                                    Merge Join Operator [MERGEJOIN_158] (rows=31678769 width=106)
+                                                      Conds:RS_35._col0=RS_36._col0(Inner),Output:["_col1","_col2","_col3"]
+                                                    <-Map 13 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_35]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_28] (rows=28798881 width=106)
+                                                          Output:["_col0","_col1","_col2","_col3"]
+                                                          Filter Operator [FIL_146] (rows=28798881 width=106)
+                                                            predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null)
+                                                            TableScan [TS_26] (rows=28798881 width=106)
+                                                              default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_returned_date_sk","cr_returning_customer_sk","cr_returning_addr_sk","cr_return_amt_inc_tax"]
+                                                    <-Map 19 [SIMPLE_EDGE]
+                                                      SHUFFLE [RS_36]
+                                                        PartitionCols:_col0
+                                                        Select Operator [SEL_31] (rows=36524 width=1119)
+                                                          Output:["_col0"]
+                                                          Filter Operator [FIL_147] (rows=36524 width=1119)
+                                                            predicate:((d_year = 1998) and d_date_sk is not null)
+                                                            TableScan [TS_29] (rows=73049 width=1119)
+                                                              default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
+                                  <-Reducer 23 [SIMPLE_EDGE]
+                                    SHUFFLE [RS_80]
+                                      PartitionCols:_col0
+                                      Group By Operator [GBY_77] (rows=4611686018427387903 width=1)
+                                        Output:["_col0"],keys:KEY._col0
+                                      <-Reducer 22 [SIMPLE_EDGE]
+                                        SHUFFLE [RS_76]
+                                          PartitionCols:_col0
+                                          Group By Operator [GBY_75] (rows=9223372036854775807 width=1)
+                                            Output:["_col0"],keys:_col2
+                                            Merge Join Operator [MERGEJOIN_154] (rows=9223372036854775807 width=1)
+                                              Conds:(Inner),(Inner),Output:["_col2"]
+                                            <-Map 21 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_70]
+                                                Select Operator [SEL_47] (rows=80000000 width=4)
+                                                  TableScan [TS_46] (rows=80000000 width=860)
+                                                    default@customer,customer,Tbl:COMPLETE,Col:COMPLETE
+                                            <-Map 30 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_72]
+                                                Select Operator [SEL_69] (rows=40000000 width=4)
+                                                  TableScan [TS_68] (rows=40000000 width=1014)
+                                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:COMPLETE
+                                            <-Reducer 27 [SIMPLE_EDGE]
+                                              SHUFFLE [RS_71]
+                                                Select Operator [SEL_67] (rows=22000000 width=1014)
+                                                  Output:["_col1"]
+                                                  Group By Operator [GBY_66] (rows=22000000 width=1014)
+                                                    Output:["_col0","_col1"],keys:KEY._col0, KEY._col1
+                                                  <-Reducer 26 [SIMPLE_EDGE]
+                                                    SHUFFLE [RS_65]
+                                                      PartitionCols:_col0, _col1
+                                                      Group By Operator [GBY_64] (rows=44000000 width=1014)
+                                                        Output:["_col0","_col1"],keys:_col7, _col1
+                                                        Select Operator [SEL_63] (rows=44000000 width=1014)
+                                                          Output:["_col7","_col1"]
+                                                          Merge Join Operator [MERGEJOIN_153] (rows=44000000 width=1014)
+                                                            Conds:RS_60._col2=RS_61._col0(Inner),Output:["_col1","_col7"]
+                                                          <-Map 29 [SIMPLE_EDGE]
+                                                            SHUFFLE [RS_61]
+                                                              PartitionCols:_col0
+                                                              Select Operator [SEL_56] (rows=40000000 width=1014)
+                                                                Output:["_col0","_col1"]
+                                                                Filter Operator [FIL_151] (rows=40000000 width=1014)
+                                                                  predicate:ca_address_sk is not null
+                                                                  TableScan [TS_54] (rows=40000000 width=1014)
+                                                                    default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state"]
+                                                          <-Reducer 25 [SIMPLE_EDGE]
+                                                            SHUFFLE [RS_60]
+                                                              PartitionCols:_col2
+                                                              Merge Join Operator [MERGEJOIN_152] (rows=31678769 width=106)
+                                                                Conds:RS_57._col0=RS_58._col0(Inner),Output:["_col1","_col2"]
+                                                              <-Map 24 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_57]
+                                                                  PartitionCols:_col0
+                                                                  Select Operator [SEL_50] (rows=28798881 width=106)
+                                                                    Output:["_col0","_col1","_col2"]
+                                                                    Filter Operator [FIL_149] (rows=28798881 width=106)
+                                                                      predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null)
+                                                                      TableScan [TS_48] (rows=28798881 width=106)
+                                                                        default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_returned_date_sk","cr_returning_customer_sk","cr_returning_addr_sk"]
+                                                              <-Map 28 [SIMPLE_EDGE]
+                                                                SHUFFLE [RS_58]
+                                                                  PartitionCols:_col0
+                                                                  Select Operator [SEL_53] (rows=36524 width=1119)
+                                                                    Output:["_col0"]
+                                                                    Filter Operator [FIL_150] (rows=36524 width=1119)
+                                                                      predicate:((d_year = 1998) and d_date_sk is not null)
+                                                                      TableScan [TS_51] (rows=73049 width=1119)
+                                                                        default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
+                    <-Reducer 3 [SIMPLE_EDGE]
+                      SHUFFLE [RS_93]
+                        PartitionCols:_col19
+                        Merge Join Operator [MERGEJOIN_160] (rows=96800003 width=860)
+                          Conds:RS_90._col0=RS_91._col0(Inner),Output:["_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17","_col19","_col20"]
+                        <-Reducer 10 [SIMPLE_EDGE]
+                          SHUFFLE [RS_91]
+                            PartitionCols:_col0
+                            Group By Operator [GBY_24] (rows=22000000 width=1014)
+                              Output:["_col0","_col1","_col2"],aggregations:["sum(VALUE._col0)"],keys:KEY._col0, KEY._col1
+                            <-Reducer 9 [SIMPLE_EDGE]
+                              SHUFFLE [RS_23]
+                                PartitionCols:_col0, _col1
+                                Group By Operator [GBY_22] (rows=44000000 width=1014)
+                                  Output:["_col0","_col1","_col2"],aggregations:["sum(_col3)"],keys:_col1, _col7
+                                  Select Operator [SEL_21] (rows=44000000 width=1014)
+                                    Output:["_col1","_col7","_col3"]
+                                    Merge Join Operator [MERGEJOIN_157] (rows=44000000 width=1014)
+                                      Conds:RS_18._col2=RS_19._col0(Inner),Output:["_col1","_col3","_col7"]
+                                    <-Map 12 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_19]
+                                        PartitionCols:_col0
+                                        Select Operator [SEL_14] (rows=40000000 width=1014)
+                                          Output:["_col0","_col1"]
+                                          Filter Operator [FIL_145] (rows=40000000 width=1014)
+                                            predicate:ca_address_sk is not null
+                                            TableScan [TS_12] (rows=40000000 width=1014)
+                                              default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_state"]
+                                    <-Reducer 8 [SIMPLE_EDGE]
+                                      SHUFFLE [RS_18]
+                                        PartitionCols:_col2
+                                        Merge Join Operator [MERGEJOIN_156] (rows=31678769 width=106)
+                                          Conds:RS_15._col0=RS_16._col0(Inner),Output:["_col1","_col2","_col3"]
+                                        <-Map 11 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_16]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_11] (rows=36524 width=1119)
+                                              Output:["_col0"]
+                                              Filter Operator [FIL_144] (rows=36524 width=1119)
+                                                predicate:((d_year = 1998) and d_date_sk is not null)
+                                                TableScan [TS_9] (rows=73049 width=1119)
+                                                  default@date_dim,date_dim,Tbl:COMPLETE,Col:NONE,Output:["d_date_sk","d_year"]
+                                        <-Map 7 [SIMPLE_EDGE]
+                                          SHUFFLE [RS_15]
+                                            PartitionCols:_col0
+                                            Select Operator [SEL_8] (rows=28798881 width=106)
+                                              Output:["_col0","_col1","_col2","_col3"]
+                                              Filter Operator [FIL_143] (rows=28798881 width=106)
+                                                predicate:(cr_returned_date_sk is not null and cr_returning_addr_sk is not null and cr_returning_customer_sk is not null)
+                                                TableScan [TS_6] (rows=28798881 width=106)
+                                                  default@catalog_returns,catalog_returns,Tbl:COMPLETE,Col:NONE,Output:["cr_returned_date_sk","cr_returning_customer_sk","cr_returning_addr_sk","cr_return_amt_inc_tax"]
+                        <-Reducer 2 [SIMPLE_EDGE]
+                          SHUFFLE [RS_90]
+                            PartitionCols:_col0
+                            Merge Join Operator [MERGEJOIN_155] (rows=88000001 width=860)
+                              Conds:RS_87._col2=RS_88._col0(Inner),Output:["_col0","_col1","_col3","_col4","_col5","_col7","_col8","_col9","_col10","_col11","_col12","_col14","_col15","_col16","_col17"]
+                            <-Map 1 [SIMPLE_EDGE]
+                              SHUFFLE [RS_87]
+                                PartitionCols:_col2
+                                Select Operator [SEL_2] (rows=80000000 width=860)
+                                  Output:["_col0","_col1","_col2","_col3","_col4","_col5"]
+                                  Filter Operator [FIL_141] (rows=80000000 width=860)
+                                    predicate:(c_customer_sk is not null and c_current_addr_sk is not null)
+                                    TableScan [TS_0] (rows=80000000 width=860)
+                                      default@customer,customer,Tbl:COMPLETE,Col:NONE,Output:["c_customer_sk","c_customer_id","c_current_addr_sk","c_salutation","c_first_name","c_last_name"]
+                            <-Map 6 [SIMPLE_EDGE]
+                              SHUFFLE [RS_88]
+                                PartitionCols:_col0
+                                Select Operator [SEL_5] (rows=20000000 width=1014)
+                                  Output:["_col0","_col1","_col10","_col11","_col2","_col3","_col4","_col5","_col6","_col8","_col9"]
+                                  Filter Operator [FIL_142] (rows=20000000 width=1014)
+                                    predicate:((ca_state = 'IL') and ca_address_sk is not null)
+                                    TableScan [TS_3] (rows=40000000 width=1014)
+                                      default@customer_address,customer_address,Tbl:COMPLETE,Col:NONE,Output:["ca_address_sk","ca_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/d9343f6d/ql/src/test/results/clientpositive/show_functions.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/show_functions.q.out b/ql/src/test/results/clientpositive/show_functions.q.out
index 990b695..90b86c3 100644
--- a/ql/src/test/results/clientpositive/show_functions.q.out
+++ b/ql/src/test/results/clientpositive/show_functions.q.out
@@ -212,6 +212,7 @@ sort_array_by
 soundex
 space
 split
+sq_count_check
 sqrt
 stack
 std

http://git-wip-us.apache.org/repos/asf/hive/blob/d9343f6d/ql/src/test/results/clientpositive/spark/cbo_subq_not_in.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/cbo_subq_not_in.q.out b/ql/src/test/results/clientpositive/spark/cbo_subq_not_in.q.out
index c006d11..8d37fff 100644
--- a/ql/src/test/results/clientpositive/spark/cbo_subq_not_in.q.out
+++ b/ql/src/test/results/clientpositive/spark/cbo_subq_not_in.q.out
@@ -219,44 +219,6 @@ almond aquamarine sandy cyan gainsboro	18
 almond aquamarine yellow dodger mint	7
 almond azure aquamarine papaya violet	12
 almond azure blanched chiffon midnight	23
-PREHOOK: query: select p_mfgr, p_name, p_size 
-from part b where b.p_size not in 
-  (select min(p_size) 
-  from (select p_mfgr, p_size from part) a 
-  where p_size < 10 and b.p_mfgr = a.p_mfgr
-  ) order by  p_name
-PREHOOK: type: QUERY
-PREHOOK: Input: default@part
-#### A masked pattern was here ####
-POSTHOOK: query: select p_mfgr, p_name, p_size 
-from part b where b.p_size not in 
-  (select min(p_size) 
-  from (select p_mfgr, p_size from part) a 
-  where p_size < 10 and b.p_mfgr = a.p_mfgr
-  ) order by  p_name
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@part
-#### A masked pattern was here ####
-Manufacturer#5	almond antique blue firebrick mint	31
-Manufacturer#3	almond antique chartreuse khaki white	17
-Manufacturer#1	almond antique chartreuse lavender yellow	34
-Manufacturer#3	almond antique forest lavender goldenrod	14
-Manufacturer#4	almond antique gainsboro frosted violet	10
-Manufacturer#5	almond antique medium spring khaki	6
-Manufacturer#3	almond antique metallic orange dim	19
-Manufacturer#3	almond antique olive coral navajo	45
-Manufacturer#1	almond antique salmon chartreuse burlywood	6
-Manufacturer#2	almond antique violet chocolate turquoise	14
-Manufacturer#4	almond antique violet mint lemon	39
-Manufacturer#2	almond antique violet turquoise frosted	40
-Manufacturer#1	almond aquamarine burnished black steel	28
-Manufacturer#5	almond aquamarine dodger light gainsboro	46
-Manufacturer#4	almond aquamarine floral ivory bisque	27
-Manufacturer#1	almond aquamarine pink moccasin thistle	42
-Manufacturer#2	almond aquamarine rose maroon antique	25
-Manufacturer#2	almond aquamarine sandy cyan gainsboro	18
-Manufacturer#4	almond azure aquamarine papaya violet	12
-Manufacturer#5	almond azure blanched chiffon midnight	23
 PREHOOK: query: select li.l_partkey, count(*) 
 from lineitem li 
 where li.l_linenumber = 1 and 

http://git-wip-us.apache.org/repos/asf/hive/blob/d9343f6d/ql/src/test/results/clientpositive/spark/subquery_exists.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/subquery_exists.q.out b/ql/src/test/results/clientpositive/spark/subquery_exists.q.out
index f8b8712..fc76158 100644
--- a/ql/src/test/results/clientpositive/spark/subquery_exists.q.out
+++ b/ql/src/test/results/clientpositive/spark/subquery_exists.q.out
@@ -1024,3 +1024,140 @@ POSTHOOK: Input: default@src
 97	val_97
 98	val_98
 98	val_98
+PREHOOK: query: create table t(i int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t
+POSTHOOK: query: create table t(i int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t
+PREHOOK: query: insert into t values(1)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(1)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.i EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+PREHOOK: query: insert into t values(0)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(0)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.i EXPRESSION [(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+Warning: Shuffle Join JOIN[18][tables = [$hdt$_0, $hdt$_1]] in Work 'Reducer 2' is a cross product
+PREHOOK: query: explain select * from t where exists (select count(*) from src where 1=2)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select * from t where exists (select count(*) from src where 1=2)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Spark
+      Edges:
+        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 1), Reducer 4 (PARTITION-LEVEL SORT, 1)
+        Reducer 4 <- Map 3 (GROUP PARTITION-LEVEL SORT, 1)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: t
+                  Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                  Select Operator
+                    expressions: i (type: int)
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                    Reduce Output Operator
+                      sort order: 
+                      Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                      value expressions: _col0 (type: int)
+        Map 3 
+            Map Operator Tree:
+                TableScan
+                  alias: src
+                  Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: COMPLETE
+                  Select Operator
+                    Statistics: Num rows: 500 Data size: 2000 Basic stats: COMPLETE Column stats: COMPLETE
+                    Filter Operator
+                      predicate: false (type: boolean)
+                      Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                      Group By Operator
+                        aggregations: count(0)
+                        mode: hash
+                        outputColumnNames: _col0
+                        Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                        Reduce Output Operator
+                          key expressions: true (type: boolean)
+                          sort order: +
+                          Map-reduce partition columns: true (type: boolean)
+                          Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                          value expressions: _col0 (type: bigint)
+        Reducer 2 
+            Reduce Operator Tree:
+              Join Operator
+                condition map:
+                     Inner Join 0 to 1
+                keys:
+                  0 
+                  1 
+                outputColumnNames: _col0
+                Statistics: Num rows: 2 Data size: 12 Basic stats: COMPLETE Column stats: NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 2 Data size: 12 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 4 
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Select Operator
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Group By Operator
+                    keys: true (type: boolean)
+                    mode: complete
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                    Select Operator
+                      Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        sort order: 
+                        Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+Warning: Shuffle Join JOIN[18][tables = [$hdt$_0, $hdt$_1]] in Work 'Reducer 2' is a cross product
+PREHOOK: query: select * from t where exists (select count(*) from src where 1=2)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select * from t where exists (select count(*) from src where 1=2)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+0
+1
+PREHOOK: query: drop table t
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@t
+PREHOOK: Output: default@t
+POSTHOOK: query: drop table t
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@t
+POSTHOOK: Output: default@t

http://git-wip-us.apache.org/repos/asf/hive/blob/d9343f6d/ql/src/test/results/clientpositive/spark/subquery_in.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/subquery_in.q.out b/ql/src/test/results/clientpositive/spark/subquery_in.q.out
index a339814..37a6617 100644
--- a/ql/src/test/results/clientpositive/spark/subquery_in.q.out
+++ b/ql/src/test/results/clientpositive/spark/subquery_in.q.out
@@ -470,247 +470,6 @@ POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 almond antique medium spring khaki	6
 almond antique salmon chartreuse burlywood	6
-PREHOOK: query: explain
-select p_mfgr, p_name, p_size 
-from part b where b.p_size in 
-	(select min(p_size) 
-	 from (select p_mfgr, p_size, rank() over(partition by p_mfgr order by p_size) as r from part) a 
-	 where r <= 2 and b.p_mfgr = a.p_mfgr
-	)
-PREHOOK: type: QUERY
-POSTHOOK: query: explain
-select p_mfgr, p_name, p_size 
-from part b where b.p_size in 
-	(select min(p_size) 
-	 from (select p_mfgr, p_size, rank() over(partition by p_mfgr order by p_size) as r from part) a 
-	 where r <= 2 and b.p_mfgr = a.p_mfgr
-	)
-POSTHOOK: type: QUERY
-STAGE DEPENDENCIES:
-  Stage-1 is a root stage
-  Stage-0 depends on stages: Stage-1
-
-STAGE PLANS:
-  Stage: Stage-1
-    Spark
-      Edges:
-        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 2), Reducer 7 (PARTITION-LEVEL SORT, 2)
-        Reducer 4 <- Map 3 (PARTITION-LEVEL SORT, 2)
-        Reducer 5 <- Reducer 4 (PARTITION-LEVEL SORT, 2), Reducer 9 (PARTITION-LEVEL SORT, 2)
-        Reducer 6 <- Reducer 5 (GROUP, 2)
-        Reducer 7 <- Reducer 6 (GROUP, 2)
-        Reducer 9 <- Map 8 (GROUP, 2)
-#### A masked pattern was here ####
-      Vertices:
-        Map 1 
-            Map Operator Tree:
-                TableScan
-                  alias: b
-                  Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                  Select Operator
-                    expressions: p_name (type: string), p_mfgr (type: string), p_size (type: int)
-                    outputColumnNames: _col0, _col1, _col2
-                    Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col1 (type: string), _col2 (type: int)
-                      sort order: ++
-                      Map-reduce partition columns: _col1 (type: string), _col2 (type: int)
-                      Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col0 (type: string)
-        Map 3 
-            Map Operator Tree:
-                TableScan
-                  alias: part
-                  Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: p_mfgr (type: string), p_size (type: int)
-                    sort order: ++
-                    Map-reduce partition columns: p_mfgr (type: string)
-                    Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                    TopN Hash Memory Usage: 0.1
-        Map 8 
-            Map Operator Tree:
-                TableScan
-                  alias: b
-                  Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                  Select Operator
-                    expressions: p_mfgr (type: string)
-                    outputColumnNames: p_mfgr
-                    Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                    Group By Operator
-                      keys: p_mfgr (type: string)
-                      mode: hash
-                      outputColumnNames: _col0
-                      Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                      Reduce Output Operator
-                        key expressions: _col0 (type: string)
-                        sort order: +
-                        Map-reduce partition columns: _col0 (type: string)
-                        Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-        Reducer 2 
-            Reduce Operator Tree:
-              Join Operator
-                condition map:
-                     Inner Join 0 to 1
-                keys:
-                  0 _col1 (type: string), _col2 (type: int)
-                  1 _col1 (type: string), _col0 (type: int)
-                outputColumnNames: _col0, _col1, _col2
-                Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
-                Select Operator
-                  expressions: _col1 (type: string), _col0 (type: string), _col2 (type: int)
-                  outputColumnNames: _col0, _col1, _col2
-                  Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
-                  File Output Operator
-                    compressed: false
-                    Statistics: Num rows: 28 Data size: 3461 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 4 
-            Reduce Operator Tree:
-              Select Operator
-                expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: int)
-                outputColumnNames: _col2, _col5
-                Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                PTF Operator
-                  Function definitions:
-                      Input definition
-                        input alias: ptf_0
-                        output shape: _col2: string, _col5: int
-                        type: WINDOWING
-                      Windowing table definition
-                        input alias: ptf_1
-                        name: windowingtablefunction
-                        order by: _col5 ASC NULLS FIRST
-                        partition by: _col2
-                        raw input shape:
-                        window functions:
-                            window function definition
-                              alias: rank_window_0
-                              arguments: _col5
-                              name: rank
-                              window function: GenericUDAFRankEvaluator
-                              window frame: PRECEDING(MAX)~FOLLOWING(MAX)
-                              isPivotResult: true
-                  Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
-                  Filter Operator
-                    predicate: (rank_window_0 <= 2) (type: boolean)
-                    Statistics: Num rows: 8 Data size: 968 Basic stats: COMPLETE Column stats: NONE
-                    Select Operator
-                      expressions: _col2 (type: string), _col5 (type: int)
-                      outputColumnNames: _col0, _col1
-                      Statistics: Num rows: 8 Data size: 968 Basic stats: COMPLETE Column stats: NONE
-                      Reduce Output Operator
-                        key expressions: _col0 (type: string)
-                        sort order: +
-                        Map-reduce partition columns: _col0 (type: string)
-                        Statistics: Num rows: 8 Data size: 968 Basic stats: COMPLETE Column stats: NONE
-                        value expressions: _col1 (type: int)
-        Reducer 5 
-            Reduce Operator Tree:
-              Join Operator
-                condition map:
-                     Inner Join 0 to 1
-                keys:
-                  0 _col0 (type: string)
-                  1 _col0 (type: string)
-                outputColumnNames: _col1, _col2
-                Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
-                Select Operator
-                  expressions: _col2 (type: string), _col1 (type: int)
-                  outputColumnNames: _col2, _col1
-                  Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
-                  Group By Operator
-                    aggregations: min(_col1)
-                    keys: _col2 (type: string)
-                    mode: hash
-                    outputColumnNames: _col0, _col1
-                    Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col0 (type: string)
-                      sort order: +
-                      Map-reduce partition columns: _col0 (type: string)
-                      Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col1 (type: int)
-        Reducer 6 
-            Reduce Operator Tree:
-              Group By Operator
-                aggregations: min(VALUE._col0)
-                keys: KEY._col0 (type: string)
-                mode: mergepartial
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
-                Group By Operator
-                  keys: _col0 (type: string), _col1 (type: int)
-                  mode: hash
-                  outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: int)
-                    sort order: ++
-                    Map-reduce partition columns: _col0 (type: string), _col1 (type: int)
-                    Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
-        Reducer 7 
-            Reduce Operator Tree:
-              Group By Operator
-                keys: KEY._col0 (type: string), KEY._col1 (type: int)
-                mode: mergepartial
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 3 Data size: 370 Basic stats: COMPLETE Column stats: NONE
-                Select Operator
-                  expressions: _col1 (type: int), _col0 (type: string)
-                  outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 3 Data size: 370 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col1 (type: string), _col0 (type: int)
-                    sort order: ++
-                    Map-reduce partition columns: _col1 (type: string), _col0 (type: int)
-                    Statistics: Num rows: 3 Data size: 370 Basic stats: COMPLETE Column stats: NONE
-        Reducer 9 
-            Reduce Operator Tree:
-              Group By Operator
-                keys: KEY._col0 (type: string)
-                mode: mergepartial
-                outputColumnNames: _col0
-                Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col0 (type: string)
-                  Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
-
-  Stage: Stage-0
-    Fetch Operator
-      limit: -1
-      Processor Tree:
-        ListSink
-
-PREHOOK: query: select p_mfgr, p_name, p_size 
-from part b where b.p_size in 
-	(select min(p_size) 
-	 from (select p_mfgr, p_size, rank() over(partition by p_mfgr order by p_size) as r from part) a 
-	 where r <= 2 and b.p_mfgr = a.p_mfgr
-	)
-PREHOOK: type: QUERY
-PREHOOK: Input: default@part
-#### A masked pattern was here ####
-POSTHOOK: query: select p_mfgr, p_name, p_size 
-from part b where b.p_size in 
-	(select min(p_size) 
-	 from (select p_mfgr, p_size, rank() over(partition by p_mfgr order by p_size) as r from part) a 
-	 where r <= 2 and b.p_mfgr = a.p_mfgr
-	)
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@part
-#### A masked pattern was here ####
-Manufacturer#1	almond antique burnished rose metallic	2
-Manufacturer#1	almond antique burnished rose metallic	2
-Manufacturer#2	almond aquamarine midnight light salmon	2
-Manufacturer#3	almond antique misty red olive	1
-Manufacturer#4	almond aquamarine yellow dodger mint	7
-Manufacturer#5	almond antique sky peru orange	2
 PREHOOK: query: explain 
 select * 
 from src b 
@@ -1362,9 +1121,9 @@ POSTHOOK: Input: default@lineitem
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
 NULL
-PREHOOK: query: explain select * from part where p_brand <> 'Brand#14' AND p_size IN (select min(p_size) from part p where p.p_type = part.p_type group by p_type) AND p_size <> 340
+PREHOOK: query: explain select * from part where p_brand <> 'Brand#14' AND p_size IN (select (p_size) from part p where p.p_type = part.p_type group by p_size) AND p_size <> 340
 PREHOOK: type: QUERY
-POSTHOOK: query: explain select * from part where p_brand <> 'Brand#14' AND p_size IN (select min(p_size) from part p where p.p_type = part.p_type group by p_type) AND p_size <> 340
+POSTHOOK: query: explain select * from part where p_brand <> 'Brand#14' AND p_size IN (select (p_size) from part p where p.p_type = part.p_type group by p_size) AND p_size <> 340
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -1374,11 +1133,10 @@ STAGE PLANS:
   Stage: Stage-1
     Spark
       Edges:
-        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 2), Reducer 6 (PARTITION-LEVEL SORT, 2)
-        Reducer 4 <- Map 3 (PARTITION-LEVEL SORT, 2), Reducer 8 (PARTITION-LEVEL SORT, 2)
-        Reducer 5 <- Reducer 4 (GROUP, 2)
-        Reducer 6 <- Reducer 5 (GROUP, 2)
-        Reducer 8 <- Map 7 (GROUP, 2)
+        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 2), Reducer 5 (PARTITION-LEVEL SORT, 2)
+        Reducer 4 <- Map 3 (PARTITION-LEVEL SORT, 2), Reducer 7 (PARTITION-LEVEL SORT, 2)
+        Reducer 5 <- Reducer 4 (GROUP PARTITION-LEVEL SORT, 2)
+        Reducer 7 <- Map 6 (GROUP, 2)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -1414,7 +1172,7 @@ STAGE PLANS:
                       Map-reduce partition columns: _col0 (type: string)
                       Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE Column stats: NONE
                       value expressions: _col1 (type: int)
-        Map 7 
+        Map 6 
             Map Operator Tree:
                 TableScan
                   alias: part
@@ -1458,59 +1216,48 @@ STAGE PLANS:
                 keys:
                   0 _col0 (type: string)
                   1 _col0 (type: string)
-                outputColumnNames: _col0, _col1, _col2
+                outputColumnNames: _col1, _col2
                 Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
-                Group By Operator
-                  aggregations: min(_col1)
-                  keys: _col2 (type: string), _col0 (type: string)
-                  mode: hash
-                  outputColumnNames: _col0, _col1, _col2
-                  Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col0 (type: string), _col1 (type: string)
-                    sort order: ++
-                    Map-reduce partition columns: _col0 (type: string), _col1 (type: string)
-                    Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
-                    value expressions: _col2 (type: int)
-        Reducer 5 
-            Reduce Operator Tree:
-              Group By Operator
-                aggregations: min(VALUE._col0)
-                keys: KEY._col0 (type: string), KEY._col1 (type: string)
-                mode: mergepartial
-                outputColumnNames: _col0, _col1, _col2
-                Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
-                  expressions: _col0 (type: string), _col2 (type: int)
-                  outputColumnNames: _col1, _col2
-                  Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
+                  expressions: _col2 (type: string), _col1 (type: int)
+                  outputColumnNames: _col2, _col1
+                  Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
                   Group By Operator
-                    keys: _col1 (type: string), _col2 (type: int)
+                    keys: _col2 (type: string), _col1 (type: int)
                     mode: hash
                     outputColumnNames: _col0, _col1
-                    Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
+                    Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
                     Reduce Output Operator
                       key expressions: _col0 (type: string), _col1 (type: int)
                       sort order: ++
                       Map-reduce partition columns: _col0 (type: string), _col1 (type: int)
-                      Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
-        Reducer 6 
+                      Statistics: Num rows: 28 Data size: 3461 Basic stats: COMPLETE Column stats: NONE
+        Reducer 5 
             Reduce Operator Tree:
               Group By Operator
                 keys: KEY._col0 (type: string), KEY._col1 (type: int)
                 mode: mergepartial
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
                 Select Operator
                   expressions: _col1 (type: int), _col0 (type: string)
                   outputColumnNames: _col0, _col1
-                  Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
-                  Reduce Output Operator
-                    key expressions: _col1 (type: string), _col0 (type: int)
-                    sort order: ++
-                    Map-reduce partition columns: _col1 (type: string), _col0 (type: int)
+                  Statistics: Num rows: 14 Data size: 1730 Basic stats: COMPLETE Column stats: NONE
+                  Group By Operator
+                    keys: _col1 (type: string), _col0 (type: int)
+                    mode: complete
+                    outputColumnNames: _col0, _col1
                     Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
-        Reducer 8 
+                    Select Operator
+                      expressions: _col1 (type: int), _col0 (type: string)
+                      outputColumnNames: _col0, _col1
+                      Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
+                      Reduce Output Operator
+                        key expressions: _col1 (type: string), _col0 (type: int)
+                        sort order: ++
+                        Map-reduce partition columns: _col1 (type: string), _col0 (type: int)
+                        Statistics: Num rows: 7 Data size: 865 Basic stats: COMPLETE Column stats: NONE
+        Reducer 7 
             Reduce Operator Tree:
               Group By Operator
                 keys: KEY._col0 (type: string)
@@ -1529,11 +1276,11 @@ STAGE PLANS:
       Processor Tree:
         ListSink
 
-PREHOOK: query: select * from part where p_brand <> 'Brand#14' AND p_size IN (select min(p_size) from part p where p.p_type = part.p_type group by p_type) AND p_size <> 340
+PREHOOK: query: select * from part where p_brand <> 'Brand#14' AND p_size IN (select (p_size) from part p where p.p_type = part.p_type group by p_size) AND p_size <> 340
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part
 #### A masked pattern was here ####
-POSTHOOK: query: select * from part where p_brand <> 'Brand#14' AND p_size IN (select min(p_size) from part p where p.p_type = part.p_type group by p_type) AND p_size <> 340
+POSTHOOK: query: select * from part where p_brand <> 'Brand#14' AND p_size IN (select (p_size) from part p where p.p_type = part.p_type group by p_size) AND p_size <> 340
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@part
 #### A masked pattern was here ####
@@ -1548,6 +1295,7 @@ POSTHOOK: Input: default@part
 17273	almond antique forest lavender goldenrod	Manufacturer#3	Brand#35	PROMO ANODIZED TIN	14	JUMBO CASE	1190.27	along the
 17927	almond aquamarine yellow dodger mint	Manufacturer#4	Brand#41	ECONOMY BRUSHED COPPER	7	SM PKG	1844.92	ites. eve
 191709	almond antique violet turquoise frosted	Manufacturer#2	Brand#22	ECONOMY POLISHED STEEL	40	MED BOX	1800.7	 haggle
+192697	almond antique blue firebrick mint	Manufacturer#5	Brand#52	MEDIUM BURNISHED TIN	31	LG DRUM	1789.69	ickly ir
 195606	almond aquamarine sandy cyan gainsboro	Manufacturer#2	Brand#25	STANDARD PLATED TIN	18	SM PKG	1701.6	ic de
 33357	almond azure aquamarine papaya violet	Manufacturer#4	Brand#41	STANDARD ANODIZED TIN	12	WRAP CASE	1290.35	reful
 40982	almond antique misty red olive	Manufacturer#3	Brand#32	ECONOMY PLATED COPPER	1	LG PKG	1922.98	c foxes can s
@@ -4754,6 +4502,28 @@ POSTHOOK: Input: default@part
 85768
 86428
 90681
+PREHOOK: query: create table t(i int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t
+POSTHOOK: query: create table t(i int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t
+PREHOOK: query: insert into t values(1)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(1)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.i EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+PREHOOK: query: insert into t values(0)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(0)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.i EXPRESSION [(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
 PREHOOK: query: create table tempty(i int)
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
@@ -4762,6 +4532,126 @@ POSTHOOK: query: create table tempty(i int)
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@tempty
+PREHOOK: query: explain select * from t where i IN (select count(*) from tempty)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select * from t where i IN (select count(*) from tempty)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-1
+    Spark
+      Edges:
+        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 2), Reducer 5 (PARTITION-LEVEL SORT, 2)
+        Reducer 4 <- Map 3 (GROUP, 1)
+        Reducer 5 <- Reducer 4 (GROUP, 2)
+#### A masked pattern was here ####
+      Vertices:
+        Map 1 
+            Map Operator Tree:
+                TableScan
+                  alias: t
+                  Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                  Select Operator
+                    expressions: i (type: int)
+                    outputColumnNames: _col0
+                    Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                    Reduce Output Operator
+                      key expressions: UDFToLong(_col0) (type: bigint)
+                      sort order: +
+                      Map-reduce partition columns: UDFToLong(_col0) (type: bigint)
+                      Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                      value expressions: _col0 (type: int)
+        Map 3 
+            Map Operator Tree:
+                TableScan
+                  alias: tempty
+                  Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE
+                  Select Operator
+                    Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE
+                    Group By Operator
+                      aggregations: count()
+                      mode: hash
+                      outputColumnNames: _col0
+                      Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                      Reduce Output Operator
+                        sort order: 
+                        Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                        value expressions: _col0 (type: bigint)
+        Reducer 2 
+            Reduce Operator Tree:
+              Join Operator
+                condition map:
+                     Inner Join 0 to 1
+                keys:
+                  0 UDFToLong(_col0) (type: bigint)
+                  1 _col0 (type: bigint)
+                outputColumnNames: _col0
+                Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                File Output Operator
+                  compressed: false
+                  Statistics: Num rows: 2 Data size: 2 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 4 
+            Reduce Operator Tree:
+              Group By Operator
+                aggregations: count(VALUE._col0)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  keys: _col0 (type: bigint)
+                  mode: hash
+                  outputColumnNames: _col0
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: _col0 (type: bigint)
+                    sort order: +
+                    Map-reduce partition columns: _col0 (type: bigint)
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+        Reducer 5 
+            Reduce Operator Tree:
+              Group By Operator
+                keys: KEY._col0 (type: bigint)
+                mode: mergepartial
+                outputColumnNames: _col0
+                Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                Reduce Output Operator
+                  key expressions: _col0 (type: bigint)
+                  sort order: +
+                  Map-reduce partition columns: _col0 (type: bigint)
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+PREHOOK: query: select * from t where i IN (select count(*) from tempty)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t
+PREHOOK: Input: default@tempty
+#### A masked pattern was here ####
+POSTHOOK: query: select * from t where i IN (select count(*) from tempty)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t
+POSTHOOK: Input: default@tempty
+#### A masked pattern was here ####
+0
+PREHOOK: query: drop table t
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@t
+PREHOOK: Output: default@t
+POSTHOOK: query: drop table t
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@t
+POSTHOOK: Output: default@t
 PREHOOK: query: create table tnull(i int)
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
@@ -4776,7 +4666,7 @@ PREHOOK: Output: default@tnull
 POSTHOOK: query: insert into tnull values(NULL) , (NULL)
 POSTHOOK: type: QUERY
 POSTHOOK: Output: default@tnull
-POSTHOOK: Lineage: tnull.i EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+POSTHOOK: Lineage: tnull.i EXPRESSION [(values__tmp__table__3)values__tmp__table__3.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
 PREHOOK: query: select * from part where p_size IN (select i from tempty)
 PREHOOK: type: QUERY
 PREHOOK: Input: default@part

http://git-wip-us.apache.org/repos/asf/hive/blob/d9343f6d/ql/src/test/results/clientpositive/subquery_exists.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/subquery_exists.q.out b/ql/src/test/results/clientpositive/subquery_exists.q.out
index 9c02d6a..5b8d510 100644
--- a/ql/src/test/results/clientpositive/subquery_exists.q.out
+++ b/ql/src/test/results/clientpositive/subquery_exists.q.out
@@ -1066,3 +1066,142 @@ POSTHOOK: Input: default@src
 97	val_97
 98	val_98
 98	val_98
+PREHOOK: query: create table t(i int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t
+POSTHOOK: query: create table t(i int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t
+PREHOOK: query: insert into t values(1)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(1)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.i EXPRESSION [(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+PREHOOK: query: insert into t values(0)
+PREHOOK: type: QUERY
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(0)
+POSTHOOK: type: QUERY
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.i EXPRESSION [(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col1, type:string, comment:), ]
+Warning: Shuffle Join JOIN[18][tables = [$hdt$_0, $hdt$_1]] in Stage 'Stage-1:MAPRED' is a cross product
+PREHOOK: query: explain select * from t where exists (select count(*) from src where 1=2)
+PREHOOK: type: QUERY
+POSTHOOK: query: explain select * from t where exists (select count(*) from src where 1=2)
+POSTHOOK: type: QUERY
+STAGE DEPENDENCIES:
+  Stage-2 is a root stage
+  Stage-1 depends on stages: Stage-2
+  Stage-0 depends on stages: Stage-1
+
+STAGE PLANS:
+  Stage: Stage-2
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: src
+            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: COMPLETE
+            Select Operator
+              Statistics: Num rows: 500 Data size: 2000 Basic stats: COMPLETE Column stats: COMPLETE
+              Filter Operator
+                predicate: false (type: boolean)
+                Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                Group By Operator
+                  aggregations: count(0)
+                  mode: hash
+                  outputColumnNames: _col0
+                  Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                  Reduce Output Operator
+                    key expressions: true (type: boolean)
+                    sort order: +
+                    Map-reduce partition columns: true (type: boolean)
+                    Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+                    value expressions: _col0 (type: bigint)
+      Reduce Operator Tree:
+        Group By Operator
+          aggregations: count(VALUE._col0)
+          mode: mergepartial
+          outputColumnNames: _col0
+          Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+          Select Operator
+            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE
+            Group By Operator
+              keys: true (type: boolean)
+              mode: complete
+              outputColumnNames: _col0
+              Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+              Select Operator
+                Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+                File Output Operator
+                  compressed: false
+                  table:
+                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                      serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
+
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: t
+            Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+            Select Operator
+              expressions: i (type: int)
+              outputColumnNames: _col0
+              Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+              Reduce Output Operator
+                sort order: 
+                Statistics: Num rows: 2 Data size: 2 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col0 (type: int)
+          TableScan
+            Reduce Output Operator
+              sort order: 
+              Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: COMPLETE
+      Reduce Operator Tree:
+        Join Operator
+          condition map:
+               Inner Join 0 to 1
+          keys:
+            0 
+            1 
+          outputColumnNames: _col0
+          Statistics: Num rows: 2 Data size: 12 Basic stats: COMPLETE Column stats: NONE
+          File Output Operator
+            compressed: false
+            Statistics: Num rows: 2 Data size: 12 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
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+      Processor Tree:
+        ListSink
+
+Warning: Shuffle Join JOIN[18][tables = [$hdt$_0, $hdt$_1]] in Stage 'Stage-1:MAPRED' is a cross product
+PREHOOK: query: select * from t where exists (select count(*) from src where 1=2)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Input: default@t
+#### A masked pattern was here ####
+POSTHOOK: query: select * from t where exists (select count(*) from src where 1=2)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Input: default@t
+#### A masked pattern was here ####
+0
+1
+PREHOOK: query: drop table t
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@t
+PREHOOK: Output: default@t
+POSTHOOK: query: drop table t
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@t
+POSTHOOK: Output: default@t