http://git-wip-us.apache.org/repos/asf/hive/blob/bddf5a7a/ql/src/test/results/clientpositive/subquery_notexists.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/subquery_notexists.q.out 
b/ql/src/test/results/clientpositive/subquery_notexists.q.out
index b916d2f..268f659 100644
--- a/ql/src/test/results/clientpositive/subquery_notexists.q.out
+++ b/ql/src/test/results/clientpositive/subquery_notexists.q.out
@@ -17,110 +17,40 @@ where not exists
   )
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
-  Stage-4 is a root stage
-  Stage-2 depends on stages: Stage-4
-  Stage-3 depends on stages: Stage-2
-  Stage-1 depends on stages: Stage-3
+  Stage-2 is a root stage
+  Stage-1 depends on stages: Stage-2
   Stage-0 depends on stages: Stage-1
 
 STAGE PLANS:
-  Stage: Stage-4
+  Stage: Stage-2
     Map Reduce
       Map Operator Tree:
           TableScan
-            alias: b
+            alias: a
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-            Select Operator
-              expressions: key (type: string), value (type: string)
-              outputColumnNames: key, value
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
+            Filter Operator
+              predicate: ((value = value) and (key = key) and (value > 
'val_2')) (type: boolean)
+              Statistics: Num rows: 41 Data size: 435 Basic stats: COMPLETE 
Column stats: NONE
               Group By Operator
                 keys: key (type: string), value (type: string)
                 mode: hash
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 500 Data size: 5312 Basic stats: 
COMPLETE Column stats: NONE
+                Statistics: Num rows: 41 Data size: 435 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: 500 Data size: 5312 Basic stats: 
COMPLETE Column stats: NONE
+                  Statistics: Num rows: 41 Data size: 435 Basic stats: 
COMPLETE Column stats: NONE
       Reduce Operator Tree:
         Group By Operator
           keys: KEY._col0 (type: string), KEY._col1 (type: string)
           mode: mergepartial
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE 
Column stats: NONE
-          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-2
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: a
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-            Filter Operator
-              predicate: (value > 'val_2') (type: boolean)
-              Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE 
Column stats: NONE
-              Select Operator
-                expressions: key (type: string), value (type: string)
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 166 Data size: 1763 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: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
-          TableScan
-            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: 250 Data size: 2656 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: string), _col1 (type: string)
-            1 _col0 (type: string), _col1 (type: string)
-          outputColumnNames: _col2, _col3
-          Statistics: Num rows: 275 Data size: 2921 Basic stats: COMPLETE 
Column stats: NONE
-          Group By Operator
-            keys: _col2 (type: string), _col3 (type: string)
-            mode: hash
-            outputColumnNames: _col0, _col1
-            Statistics: Num rows: 275 Data size: 2921 Basic stats: COMPLETE 
Column stats: NONE
-            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-3
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            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: 275 Data size: 2921 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: string), KEY._col1 (type: string)
-          mode: mergepartial
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 137 Data size: 1455 Basic stats: COMPLETE 
Column stats: NONE
+          Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE Column 
stats: NONE
           Select Operator
             expressions: _col0 (type: string), _col1 (type: string), true 
(type: boolean)
             outputColumnNames: _col0, _col1, _col2
-            Statistics: Num rows: 137 Data size: 1455 Basic stats: COMPLETE 
Column stats: NONE
+            Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
             File Output Operator
               compressed: false
               table:
@@ -148,7 +78,7 @@ STAGE PLANS:
               key expressions: _col0 (type: string), _col1 (type: string)
               sort order: ++
               Map-reduce partition columns: _col0 (type: string), _col1 (type: 
string)
-              Statistics: Num rows: 137 Data size: 1455 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col2 (type: boolean)
       Reduce Operator Tree:
         Join Operator
@@ -338,46 +268,11 @@ where not exists
   )
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
-  Stage-4 is a root stage
-  Stage-2 depends on stages: Stage-4
-  Stage-3 depends on stages: Stage-2
-  Stage-1 depends on stages: Stage-3
+  Stage-2 is a root stage
+  Stage-1 depends on stages: Stage-2
   Stage-0 depends on stages: Stage-1
 
 STAGE PLANS:
-  Stage: Stage-4
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: b
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-            Select Operator
-              expressions: value (type: string)
-              outputColumnNames: value
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-              Group By Operator
-                keys: value (type: string)
-                mode: hash
-                outputColumnNames: _col0
-                Statistics: Num rows: 500 Data size: 5312 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: 500 Data size: 5312 Basic stats: 
COMPLETE Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: string)
-          mode: mergepartial
-          outputColumnNames: _col0
-          Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE 
Column stats: NONE
-          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-2
     Map Reduce
       Map Operator Tree:
@@ -385,77 +280,41 @@ STAGE PLANS:
             alias: a
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
             Filter Operator
-              predicate: (value > 'val_2') (type: boolean)
-              Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE 
Column stats: NONE
+              predicate: ((value = value) and (value > 'val_2')) (type: 
boolean)
+              Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE 
Column stats: NONE
               Select Operator
-                expressions: key (type: string), value (type: string)
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col1 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col1 (type: string)
-                  Statistics: Num rows: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string)
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: string)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col1 (type: string)
-            1 _col0 (type: string)
-          outputColumnNames: _col0, _col2
-          Statistics: Num rows: 275 Data size: 2921 Basic stats: COMPLETE 
Column stats: NONE
-          Select Operator
-            expressions: _col2 (type: string), _col0 (type: string)
-            outputColumnNames: _col2, _col0
-            Statistics: Num rows: 275 Data size: 2921 Basic stats: COMPLETE 
Column stats: NONE
-            Group By Operator
-              keys: _col2 (type: string), _col0 (type: string)
-              mode: hash
-              outputColumnNames: _col0, _col1
-              Statistics: Num rows: 275 Data size: 2921 Basic stats: COMPLETE 
Column stats: NONE
-              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-3
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: string), _col1 (type: string)
-              sort order: ++
-              Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 275 Data size: 2921 Basic stats: COMPLETE 
Column stats: NONE
+                expressions: value (type: string), key (type: string)
+                outputColumnNames: value, key
+                Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE 
Column stats: NONE
+                Group By Operator
+                  keys: value (type: string), key (type: string)
+                  mode: hash
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 83 Data size: 881 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)
+                    Statistics: Num rows: 83 Data size: 881 Basic stats: 
COMPLETE Column stats: NONE
       Reduce Operator Tree:
         Group By Operator
           keys: KEY._col0 (type: string), KEY._col1 (type: string)
           mode: mergepartial
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 137 Data size: 1455 Basic stats: COMPLETE 
Column stats: NONE
+          Statistics: Num rows: 41 Data size: 435 Basic stats: COMPLETE Column 
stats: NONE
           Select Operator
             expressions: _col0 (type: string)
             outputColumnNames: _col1
-            Statistics: Num rows: 137 Data size: 1455 Basic stats: COMPLETE 
Column stats: NONE
+            Statistics: Num rows: 41 Data size: 435 Basic stats: COMPLETE 
Column stats: NONE
             Group By Operator
               keys: _col1 (type: string)
               mode: complete
               outputColumnNames: _col0
-              Statistics: Num rows: 68 Data size: 722 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
               Select Operator
                 expressions: _col0 (type: string), true (type: boolean)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 68 Data size: 722 Basic stats: COMPLETE 
Column stats: NONE
+                Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
                 File Output Operator
                   compressed: false
                   table:
@@ -484,7 +343,7 @@ STAGE PLANS:
               key expressions: _col0 (type: string)
               sort order: +
               Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 68 Data size: 722 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col1 (type: boolean)
       Reduce Operator Tree:
         Join Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/bddf5a7a/ql/src/test/results/clientpositive/subquery_notexists_having.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/subquery_notexists_having.q.out 
b/ql/src/test/results/clientpositive/subquery_notexists_having.q.out
index 0ca743d..d78a552 100644
--- a/ql/src/test/results/clientpositive/subquery_notexists_having.q.out
+++ b/ql/src/test/results/clientpositive/subquery_notexists_having.q.out
@@ -20,10 +20,8 @@ having not exists
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1, Stage-4
-  Stage-5 is a root stage
-  Stage-3 depends on stages: Stage-5
-  Stage-4 depends on stages: Stage-3
+  Stage-2 depends on stages: Stage-1, Stage-3
+  Stage-3 is a root stage
   Stage-0 depends on stages: Stage-2
 
 STAGE PLANS:
@@ -74,7 +72,7 @@ STAGE PLANS:
               key expressions: _col0 (type: string), _col1 (type: string)
               sort order: ++
               Map-reduce partition columns: _col0 (type: string), _col1 (type: 
string)
-              Statistics: Num rows: 91 Data size: 969 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col2 (type: boolean)
       Reduce Operator Tree:
         Join Operator
@@ -100,44 +98,6 @@ STAGE PLANS:
                     output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                     serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
 
-  Stage: Stage-5
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: b
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-            Select Operator
-              expressions: key (type: string), value (type: string)
-              outputColumnNames: key, value
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-              Group By Operator
-                keys: key (type: string), value (type: string)
-                mode: hash
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 500 Data size: 5312 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: 500 Data size: 5312 Basic stats: 
COMPLETE Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: string), KEY._col1 (type: string)
-          mode: mergepartial
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE 
Column stats: NONE
-          Group By Operator
-            keys: _col0 (type: string), _col1 (type: string)
-            mode: complete
-            outputColumnNames: _col0, _col1
-            Statistics: Num rows: 125 Data size: 1328 Basic stats: COMPLETE 
Column stats: NONE
-            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-3
     Map Reduce
       Map Operator Tree:
@@ -145,63 +105,28 @@ STAGE PLANS:
             alias: a
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
             Filter Operator
-              predicate: (value > 'val_12') (type: boolean)
-              Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE 
Column stats: NONE
-              Select Operator
-                expressions: key (type: string), value (type: string)
+              predicate: ((value = value) and (key = key) and (value > 
'val_12')) (type: boolean)
+              Statistics: Num rows: 41 Data size: 435 Basic stats: COMPLETE 
Column stats: NONE
+              Group By Operator
+                keys: key (type: string), value (type: string)
+                mode: hash
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
+                Statistics: Num rows: 41 Data size: 435 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: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
-          TableScan
-            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: 125 Data size: 1328 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: string), _col1 (type: string)
-            1 _col0 (type: string), _col1 (type: string)
-          outputColumnNames: _col2, _col3
-          Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE 
Column stats: NONE
-          Group By Operator
-            keys: _col2 (type: string), _col3 (type: string)
-            mode: hash
-            outputColumnNames: _col0, _col1
-            Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE 
Column stats: NONE
-            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-4
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            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: 182 Data size: 1939 Basic stats: COMPLETE 
Column stats: NONE
+                  Statistics: Num rows: 41 Data size: 435 Basic stats: 
COMPLETE Column stats: NONE
       Reduce Operator Tree:
         Group By Operator
           keys: KEY._col0 (type: string), KEY._col1 (type: string)
           mode: mergepartial
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 91 Data size: 969 Basic stats: COMPLETE Column 
stats: NONE
+          Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE Column 
stats: NONE
           Select Operator
             expressions: _col0 (type: string), _col1 (type: string), true 
(type: boolean)
             outputColumnNames: _col0, _col1, _col2
-            Statistics: Num rows: 91 Data size: 969 Basic stats: COMPLETE 
Column stats: NONE
+            Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
             File Output Operator
               compressed: false
               table:
@@ -273,10 +198,8 @@ having not exists
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1, Stage-4
-  Stage-5 is a root stage
-  Stage-3 depends on stages: Stage-5
-  Stage-4 depends on stages: Stage-3
+  Stage-2 depends on stages: Stage-1, Stage-3
+  Stage-3 is a root stage
   Stage-0 depends on stages: Stage-2
 
 STAGE PLANS:
@@ -332,7 +255,7 @@ STAGE PLANS:
               key expressions: _col0 (type: string)
               sort order: +
               Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 45 Data size: 479 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col1 (type: boolean)
       Reduce Operator Tree:
         Join Operator
@@ -358,48 +281,6 @@ STAGE PLANS:
                     output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                     serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
 
-  Stage: Stage-5
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: b
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-            Select Operator
-              expressions: value (type: string), key (type: string)
-              outputColumnNames: value, key
-              Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-              Group By Operator
-                keys: value (type: string), key (type: string)
-                mode: hash
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 500 Data size: 5312 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)
-                  Statistics: Num rows: 500 Data size: 5312 Basic stats: 
COMPLETE Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: string), KEY._col1 (type: string)
-          mode: mergepartial
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE 
Column stats: NONE
-          Select Operator
-            expressions: _col0 (type: string)
-            outputColumnNames: _col1
-            Statistics: Num rows: 250 Data size: 2656 Basic stats: COMPLETE 
Column stats: NONE
-            Group By Operator
-              keys: _col1 (type: string)
-              mode: complete
-              outputColumnNames: _col0
-              Statistics: Num rows: 125 Data size: 1328 Basic stats: COMPLETE 
Column stats: NONE
-              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-3
     Map Reduce
       Map Operator Tree:
@@ -407,77 +288,41 @@ STAGE PLANS:
             alias: a
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
             Filter Operator
-              predicate: (value > 'val_12') (type: boolean)
-              Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE 
Column stats: NONE
+              predicate: ((value = value) and (value > 'val_12')) (type: 
boolean)
+              Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE 
Column stats: NONE
               Select Operator
-                expressions: key (type: string), value (type: string)
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col1 (type: string)
-                  sort order: +
-                  Map-reduce partition columns: _col1 (type: string)
-                  Statistics: Num rows: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string)
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: string)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 125 Data size: 1328 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col1 (type: string)
-            1 _col0 (type: string)
-          outputColumnNames: _col0, _col2
-          Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE 
Column stats: NONE
-          Select Operator
-            expressions: _col2 (type: string), _col0 (type: string)
-            outputColumnNames: _col2, _col0
-            Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE 
Column stats: NONE
-            Group By Operator
-              keys: _col2 (type: string), _col0 (type: string)
-              mode: hash
-              outputColumnNames: _col0, _col1
-              Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE 
Column stats: NONE
-              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-4
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: string), _col1 (type: string)
-              sort order: ++
-              Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE 
Column stats: NONE
+                expressions: value (type: string), key (type: string)
+                outputColumnNames: value, key
+                Statistics: Num rows: 83 Data size: 881 Basic stats: COMPLETE 
Column stats: NONE
+                Group By Operator
+                  keys: value (type: string), key (type: string)
+                  mode: hash
+                  outputColumnNames: _col0, _col1
+                  Statistics: Num rows: 83 Data size: 881 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)
+                    Statistics: Num rows: 83 Data size: 881 Basic stats: 
COMPLETE Column stats: NONE
       Reduce Operator Tree:
         Group By Operator
           keys: KEY._col0 (type: string), KEY._col1 (type: string)
           mode: mergepartial
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 91 Data size: 969 Basic stats: COMPLETE Column 
stats: NONE
+          Statistics: Num rows: 41 Data size: 435 Basic stats: COMPLETE Column 
stats: NONE
           Select Operator
             expressions: _col0 (type: string)
             outputColumnNames: _col1
-            Statistics: Num rows: 91 Data size: 969 Basic stats: COMPLETE 
Column stats: NONE
+            Statistics: Num rows: 41 Data size: 435 Basic stats: COMPLETE 
Column stats: NONE
             Group By Operator
               keys: _col1 (type: string)
               mode: complete
               outputColumnNames: _col0
-              Statistics: Num rows: 45 Data size: 479 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
               Select Operator
                 expressions: _col0 (type: string), true (type: boolean)
                 outputColumnNames: _col0, _col1
-                Statistics: Num rows: 45 Data size: 479 Basic stats: COMPLETE 
Column stats: NONE
+                Statistics: Num rows: 20 Data size: 212 Basic stats: COMPLETE 
Column stats: NONE
                 File Output Operator
                   compressed: false
                   table:

http://git-wip-us.apache.org/repos/asf/hive/blob/bddf5a7a/ql/src/test/results/clientpositive/subquery_notin_having.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/subquery_notin_having.q.out 
b/ql/src/test/results/clientpositive/subquery_notin_having.q.out
index 644e70e..375a48a 100644
--- a/ql/src/test/results/clientpositive/subquery_notin_having.q.out
+++ b/ql/src/test/results/clientpositive/subquery_notin_having.q.out
@@ -227,20 +227,12 @@ having b.p_mfgr not in
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1, Stage-6
-  Stage-3 depends on stages: Stage-2, Stage-12
+  Stage-2 depends on stages: Stage-1, Stage-5
+  Stage-3 depends on stages: Stage-2, Stage-7
   Stage-4 is a root stage
-  Stage-5 depends on stages: Stage-4, Stage-8
-  Stage-6 depends on stages: Stage-5
-  Stage-7 is a root stage
-  Stage-8 depends on stages: Stage-7
-  Stage-9 is a root stage
-  Stage-10 depends on stages: Stage-9, Stage-14
-  Stage-11 depends on stages: Stage-10
-  Stage-12 depends on stages: Stage-11, Stage-15
-  Stage-13 is a root stage
-  Stage-14 depends on stages: Stage-13
-  Stage-15 is a root stage
+  Stage-5 depends on stages: Stage-4
+  Stage-6 is a root stage
+  Stage-7 depends on stages: Stage-6
   Stage-0 depends on stages: Stage-3
 
 STAGE PLANS:
@@ -295,7 +287,7 @@ STAGE PLANS:
               key expressions: _col0 (type: double)
               sort order: +
               Map-reduce partition columns: _col0 (type: double)
-              Statistics: Num rows: 3 Data size: 399 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 1 Data size: 121 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col1 (type: bigint), _col2 (type: bigint)
       Reduce Operator Tree:
         Join Operator
@@ -325,10 +317,10 @@ STAGE PLANS:
               value expressions: _col3 (type: bigint), _col4 (type: bigint)
           TableScan
             Reduce Output Operator
-              key expressions: _col3 (type: string), _col1 (type: double)
+              key expressions: _col0 (type: string), _col1 (type: double)
               sort order: ++
-              Map-reduce partition columns: _col3 (type: string), _col1 (type: 
double)
-              Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE 
Column stats: NONE
+              Map-reduce partition columns: _col0 (type: string), _col1 (type: 
double)
+              Statistics: Num rows: 1 Data size: 121 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col2 (type: boolean)
       Reduce Operator Tree:
         Join Operator
@@ -336,19 +328,19 @@ STAGE PLANS:
                Left Outer Join0 to 1
           keys:
             0 _col0 (type: string), _col1 (type: double)
-            1 _col3 (type: string), _col1 (type: double)
+            1 _col0 (type: string), _col1 (type: double)
           outputColumnNames: _col0, _col1, _col3, _col4, _col7
           Statistics: Num rows: 15 Data size: 1903 Basic stats: COMPLETE 
Column stats: NONE
           Filter Operator
-            predicate: CASE WHEN ((_col3 = 0)) THEN (true) WHEN (_col3 is 
null) THEN (true) WHEN (_col7 is not null) THEN (false) WHEN (_col0 is null) 
THEN (null) WHEN ((_col4 < _col3)) THEN (false) ELSE (true) END (type: boolean)
-            Statistics: Num rows: 7 Data size: 888 Basic stats: COMPLETE 
Column stats: NONE
+            predicate: (not CASE WHEN ((_col3 = 0)) THEN (false) WHEN (_col3 
is null) THEN (false) WHEN (_col7 is not null) THEN (true) WHEN (_col0 is null) 
THEN (null) WHEN ((_col4 < _col3)) THEN (true) ELSE (false) END) (type: boolean)
+            Statistics: Num rows: 8 Data size: 1014 Basic stats: COMPLETE 
Column stats: NONE
             Select Operator
               expressions: _col0 (type: string), _col1 (type: double)
               outputColumnNames: _col0, _col1
-              Statistics: Num rows: 7 Data size: 888 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 8 Data size: 1014 Basic stats: COMPLETE 
Column stats: NONE
               File Output Operator
                 compressed: false
-                Statistics: Num rows: 7 Data size: 888 Basic stats: COMPLETE 
Column stats: NONE
+                Statistics: Num rows: 8 Data size: 1014 Basic stats: COMPLETE 
Column stats: NONE
                 table:
                     input format: 
org.apache.hadoop.mapred.SequenceFileInputFormat
                     output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
@@ -384,70 +376,34 @@ STAGE PLANS:
           outputColumnNames: _col0, _col1, _col2
           Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
           Filter Operator
-            predicate: ((_col2 - _col1) > 600.0) (type: boolean)
-            Statistics: Num rows: 4 Data size: 484 Basic stats: COMPLETE 
Column stats: NONE
+            predicate: ((_col1 = _col1) and ((_col2 - _col1) > 600.0)) (type: 
boolean)
+            Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
             Select Operator
-              expressions: _col0 (type: string), _col1 (type: double)
-              outputColumnNames: _col0, _col1
-              Statistics: Num rows: 4 Data size: 484 Basic stats: COMPLETE 
Column stats: NONE
-              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
+              expressions: _col1 (type: double), _col0 (type: string)
+              outputColumnNames: _col1, _col0
+              Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
+              Group By Operator
+                aggregations: count(), count(_col0)
+                keys: _col1 (type: double)
+                mode: hash
+                outputColumnNames: _col0, _col1, _col2
+                Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
+                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-5
     Map Reduce
       Map Operator Tree:
           TableScan
             Reduce Output Operator
-              key expressions: _col1 (type: double)
-              sort order: +
-              Map-reduce partition columns: _col1 (type: double)
-              Statistics: Num rows: 4 Data size: 484 Basic stats: COMPLETE 
Column stats: NONE
-              value expressions: _col0 (type: string)
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: double)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: double)
-              Statistics: Num rows: 6 Data size: 726 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col1 (type: double)
-            1 _col0 (type: double)
-          outputColumnNames: _col0, _col3
-          Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE Column 
stats: NONE
-          Select Operator
-            expressions: _col3 (type: double), _col0 (type: string)
-            outputColumnNames: _col3, _col0
-            Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE 
Column stats: NONE
-            Group By Operator
-              aggregations: count(), count(_col0)
-              keys: _col3 (type: double)
-              mode: hash
-              outputColumnNames: _col0, _col1, _col2
-              Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE 
Column stats: NONE
-              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-6
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
               key expressions: _col0 (type: double)
               sort order: +
               Map-reduce partition columns: _col0 (type: double)
-              Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col1 (type: bigint), _col2 (type: bigint)
       Reduce Operator Tree:
         Group By Operator
@@ -455,7 +411,7 @@ STAGE PLANS:
           keys: KEY._col0 (type: double)
           mode: mergepartial
           outputColumnNames: _col0, _col1, _col2
-          Statistics: Num rows: 3 Data size: 399 Basic stats: COMPLETE Column 
stats: NONE
+          Statistics: Num rows: 1 Data size: 121 Basic stats: COMPLETE Column 
stats: NONE
           File Output Operator
             compressed: false
             table:
@@ -463,74 +419,7 @@ STAGE PLANS:
                 output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                 serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
-  Stage: Stage-7
-    Map Reduce
-      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), p_retailprice (type: double)
-              outputColumnNames: p_mfgr, p_retailprice
-              Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE 
Column stats: NONE
-              Group By Operator
-                aggregations: min(p_retailprice)
-                keys: p_mfgr (type: string)
-                mode: hash
-                outputColumnNames: _col0, _col1
-                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
-                  value expressions: _col1 (type: double)
-      Reduce Operator Tree:
-        Group By Operator
-          aggregations: min(VALUE._col0)
-          keys: KEY._col0 (type: string)
-          mode: mergepartial
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
-          Select Operator
-            expressions: _col1 (type: double)
-            outputColumnNames: _col1
-            Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
-            Group By Operator
-              keys: _col1 (type: double)
-              mode: hash
-              outputColumnNames: _col0
-              Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
-              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-8
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: double)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: double)
-              Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: double)
-          mode: mergepartial
-          outputColumnNames: _col0
-          Statistics: Num rows: 6 Data size: 726 Basic stats: COMPLETE Column 
stats: NONE
-          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-9
+  Stage: Stage-6
     Map Reduce
       Map Operator Tree:
           TableScan
@@ -560,57 +449,25 @@ STAGE PLANS:
           outputColumnNames: _col0, _col1, _col2
           Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
           Filter Operator
-            predicate: ((_col2 - _col1) > 600.0) (type: boolean)
-            Statistics: Num rows: 4 Data size: 484 Basic stats: COMPLETE 
Column stats: NONE
+            predicate: ((_col1 = _col1) and ((_col2 - _col1) > 600.0)) (type: 
boolean)
+            Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
             Select Operator
               expressions: _col0 (type: string), _col1 (type: double)
               outputColumnNames: _col0, _col1
-              Statistics: Num rows: 4 Data size: 484 Basic stats: COMPLETE 
Column stats: NONE
-              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-10
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col1 (type: double)
-              sort order: +
-              Map-reduce partition columns: _col1 (type: double)
-              Statistics: Num rows: 4 Data size: 484 Basic stats: COMPLETE 
Column stats: NONE
-              value expressions: _col0 (type: string)
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: double)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: double)
-              Statistics: Num rows: 6 Data size: 726 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col1 (type: double)
-            1 _col0 (type: double)
-          outputColumnNames: _col0, _col3
-          Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE Column 
stats: NONE
-          Group By Operator
-            keys: _col0 (type: string), _col3 (type: double)
-            mode: hash
-            outputColumnNames: _col0, _col1
-            Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE 
Column stats: NONE
-            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
+              Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
+              Group By Operator
+                keys: _col0 (type: string), _col1 (type: double)
+                mode: hash
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
+                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-11
+  Stage: Stage-7
     Map Reduce
       Map Operator Tree:
           TableScan
@@ -618,94 +475,20 @@ STAGE PLANS:
               key expressions: _col0 (type: string), _col1 (type: double)
               sort order: ++
               Map-reduce partition columns: _col0 (type: string), _col1 (type: 
double)
-              Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 2 Data size: 242 Basic stats: COMPLETE 
Column stats: NONE
       Reduce Operator Tree:
         Group By Operator
           keys: KEY._col0 (type: string), KEY._col1 (type: double)
           mode: mergepartial
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 3 Data size: 399 Basic stats: COMPLETE Column 
stats: NONE
-          Select Operator
-            expressions: _col0 (type: string), _col1 (type: double), true 
(type: boolean)
-            outputColumnNames: _col0, _col1, _col2
-            Statistics: Num rows: 3 Data size: 399 Basic stats: COMPLETE 
Column stats: NONE
-            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-12
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: string)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 3 Data size: 399 Basic stats: COMPLETE 
Column stats: NONE
-              value expressions: _col1 (type: double), _col2 (type: boolean)
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: string)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: string)
-              Statistics: Num rows: 6 Data size: 726 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: string)
-            1 _col0 (type: string)
-          outputColumnNames: _col1, _col2, _col3
-          Statistics: Num rows: 6 Data size: 798 Basic stats: COMPLETE Column 
stats: NONE
-          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-13
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: b
-            Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE 
Column stats: NONE
+          Statistics: Num rows: 1 Data size: 121 Basic stats: COMPLETE Column 
stats: NONE
+          Filter Operator
+            predicate: (_col0 = _col0) (type: boolean)
+            Statistics: Num rows: 1 Data size: 121 Basic stats: COMPLETE 
Column stats: NONE
             Select Operator
-              expressions: p_mfgr (type: string), p_retailprice (type: double)
-              outputColumnNames: p_mfgr, p_retailprice
-              Statistics: Num rows: 26 Data size: 3147 Basic stats: COMPLETE 
Column stats: NONE
-              Group By Operator
-                aggregations: min(p_retailprice)
-                keys: p_mfgr (type: string)
-                mode: hash
-                outputColumnNames: _col0, _col1
-                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
-                  value expressions: _col1 (type: double)
-      Reduce Operator Tree:
-        Group By Operator
-          aggregations: min(VALUE._col0)
-          keys: KEY._col0 (type: string)
-          mode: mergepartial
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
-          Select Operator
-            expressions: _col1 (type: double)
-            outputColumnNames: _col1
-            Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
-            Group By Operator
-              keys: _col1 (type: double)
-              mode: hash
-              outputColumnNames: _col0
-              Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
+              expressions: _col0 (type: string), _col1 (type: double), true 
(type: boolean)
+              outputColumnNames: _col0, _col1, _col2
+              Statistics: Num rows: 1 Data size: 121 Basic stats: COMPLETE 
Column stats: NONE
               File Output Operator
                 compressed: false
                 table:
@@ -713,66 +496,6 @@ STAGE PLANS:
                     output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                     serde: 
org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
-  Stage: Stage-14
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: double)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: double)
-              Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: double)
-          mode: mergepartial
-          outputColumnNames: _col0
-          Statistics: Num rows: 6 Data size: 726 Basic stats: COMPLETE Column 
stats: NONE
-          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-15
-    Map Reduce
-      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
-      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
-          Group By Operator
-            keys: _col0 (type: string)
-            mode: complete
-            outputColumnNames: _col0
-            Statistics: Num rows: 6 Data size: 726 Basic stats: COMPLETE 
Column stats: NONE
-            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-0
     Fetch Operator
       limit: -1
@@ -1336,17 +1059,12 @@ POSTHOOK: query: explain SELECT c1 FROM t1 group by c1 
having c1 NOT IN (SELECT
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
-  Stage-2 depends on stages: Stage-1, Stage-5
-  Stage-3 depends on stages: Stage-2, Stage-9
+  Stage-2 depends on stages: Stage-1, Stage-3, Stage-5
+  Stage-3 is a root stage
+  Stage-4 is a root stage
+  Stage-5 depends on stages: Stage-4, Stage-6
   Stage-6 is a root stage
-  Stage-4 depends on stages: Stage-6
-  Stage-5 depends on stages: Stage-4
-  Stage-10 is a root stage
-  Stage-7 depends on stages: Stage-10
-  Stage-8 depends on stages: Stage-7
-  Stage-9 depends on stages: Stage-8, Stage-11
-  Stage-11 is a root stage
-  Stage-0 depends on stages: Stage-3
+  Stage-0 depends on stages: Stage-2
 
 STAGE PLANS:
   Stage: Stage-1
@@ -1398,154 +1116,60 @@ STAGE PLANS:
               Map-reduce partition columns: _col0 (type: int)
               Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col1 (type: bigint), _col2 (type: bigint)
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Left Outer Join0 to 1
-          keys:
-            0 _col0 (type: int)
-            1 _col0 (type: int)
-          outputColumnNames: _col0, _col2, _col3
-          Statistics: Num rows: 2 Data size: 171 Basic stats: COMPLETE Column 
stats: NONE
-          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-3
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: int), _col0 (type: int)
-              sort order: ++
-              Map-reduce partition columns: _col0 (type: int), _col0 (type: 
int)
-              Statistics: Num rows: 2 Data size: 171 Basic stats: COMPLETE 
Column stats: NONE
-              value expressions: _col2 (type: bigint), _col3 (type: bigint)
           TableScan
             Reduce Output Operator
-              key expressions: _col3 (type: int), _col1 (type: int)
-              sort order: ++
-              Map-reduce partition columns: _col3 (type: int), _col1 (type: 
int)
+              key expressions: _col3 (type: int)
+              sort order: +
+              Map-reduce partition columns: _col3 (type: int)
               Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE 
Column stats: NONE
               value expressions: _col2 (type: boolean)
       Reduce Operator Tree:
         Join Operator
           condition map:
                Left Outer Join0 to 1
+               Left Outer Join0 to 2
           keys:
-            0 _col0 (type: int), _col0 (type: int)
-            1 _col3 (type: int), _col1 (type: int)
+            0 _col0 (type: int)
+            1 _col0 (type: int)
+            2 _col3 (type: int)
           outputColumnNames: _col0, _col2, _col3, _col6
-          Statistics: Num rows: 2 Data size: 188 Basic stats: COMPLETE Column 
stats: NONE
+          Statistics: Num rows: 4 Data size: 343 Basic stats: COMPLETE Column 
stats: NONE
           Filter Operator
-            predicate: CASE WHEN ((_col2 = 0)) THEN (true) WHEN (_col2 is 
null) THEN (true) WHEN (_col6 is not null) THEN (false) WHEN (_col0 is null) 
THEN (null) WHEN ((_col3 < _col2)) THEN (false) ELSE (true) END (type: boolean)
-            Statistics: Num rows: 1 Data size: 94 Basic stats: COMPLETE Column 
stats: NONE
+            predicate: (not CASE WHEN ((_col2 = 0)) THEN (false) WHEN (_col2 
is null) THEN (false) WHEN (_col6 is not null) THEN (true) WHEN (_col0 is null) 
THEN (null) WHEN ((_col3 < _col2)) THEN (true) ELSE (false) END) (type: boolean)
+            Statistics: Num rows: 2 Data size: 171 Basic stats: COMPLETE 
Column stats: NONE
             Select Operator
               expressions: _col0 (type: int)
               outputColumnNames: _col0
-              Statistics: Num rows: 1 Data size: 94 Basic stats: COMPLETE 
Column stats: NONE
+              Statistics: Num rows: 2 Data size: 171 Basic stats: COMPLETE 
Column stats: NONE
               File Output Operator
                 compressed: false
-                Statistics: Num rows: 1 Data size: 94 Basic stats: COMPLETE 
Column stats: NONE
+                Statistics: Num rows: 2 Data size: 171 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-6
+  Stage: Stage-3
     Map Reduce
       Map Operator Tree:
           TableScan
-            alias: t1
-            Statistics: Num rows: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
-            Select Operator
-              expressions: c1 (type: int)
-              outputColumnNames: c1
-              Statistics: Num rows: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
+            alias: t2
+            Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
+            Filter Operator
+              predicate: (c1 = c1) (type: boolean)
+              Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE 
Column stats: NONE
               Group By Operator
+                aggregations: count(), count(c1)
                 keys: c1 (type: int)
                 mode: hash
-                outputColumnNames: _col0
-                Statistics: Num rows: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
+                outputColumnNames: _col0, _col1, _col2
+                Statistics: Num rows: 1 Data size: 2 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: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: int)
-          mode: mergepartial
-          outputColumnNames: _col0
-          Statistics: Num rows: 2 Data size: 156 Basic stats: COMPLETE Column 
stats: NONE
-          Group By Operator
-            keys: _col0 (type: int)
-            mode: complete
-            outputColumnNames: _col0
-            Statistics: Num rows: 1 Data size: 78 Basic stats: COMPLETE Column 
stats: NONE
-            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-4
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: t2
-            Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
-            Select Operator
-              expressions: c1 (type: int)
-              outputColumnNames: _col0
-              Statistics: Num rows: 3 Data size: 6 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: 3 Data size: 6 Basic stats: COMPLETE 
Column stats: NONE
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: int)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: int)
-              Statistics: Num rows: 1 Data size: 78 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: int)
-            1 _col0 (type: int)
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
-          Group By Operator
-            aggregations: count(), count(_col0)
-            keys: _col1 (type: int)
-            mode: hash
-            outputColumnNames: _col0, _col1, _col2
-            Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
-            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-5
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: int)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: int)
-              Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE 
Column stats: NONE
-              value expressions: _col1 (type: bigint), _col2 (type: bigint)
+                  Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE 
Column stats: NONE
+                  value expressions: _col1 (type: bigint), _col2 (type: bigint)
       Reduce Operator Tree:
         Group By Operator
           aggregations: count(VALUE._col0), count(VALUE._col1)
@@ -1560,104 +1184,34 @@ STAGE PLANS:
                 output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                 serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
-  Stage: Stage-10
+  Stage: Stage-4
     Map Reduce
       Map Operator Tree:
           TableScan
-            alias: t1
-            Statistics: Num rows: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
-            Select Operator
-              expressions: c1 (type: int)
-              outputColumnNames: c1
-              Statistics: Num rows: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
+            alias: t2
+            Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
+            Filter Operator
+              predicate: (c1 = c1) (type: boolean)
+              Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE 
Column stats: NONE
               Group By Operator
                 keys: c1 (type: int)
                 mode: hash
                 outputColumnNames: _col0
-                Statistics: Num rows: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
+                Statistics: Num rows: 1 Data size: 2 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: 4 Data size: 313 Basic stats: COMPLETE 
Column stats: NONE
+                  Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE 
Column stats: NONE
       Reduce Operator Tree:
         Group By Operator
           keys: KEY._col0 (type: int)
           mode: mergepartial
           outputColumnNames: _col0
-          Statistics: Num rows: 2 Data size: 156 Basic stats: COMPLETE Column 
stats: NONE
-          Group By Operator
-            keys: _col0 (type: int)
-            mode: complete
-            outputColumnNames: _col0
-            Statistics: Num rows: 1 Data size: 78 Basic stats: COMPLETE Column 
stats: NONE
-            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-7
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            alias: t2
-            Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
-            Select Operator
-              expressions: c1 (type: int)
-              outputColumnNames: _col0
-              Statistics: Num rows: 3 Data size: 6 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: 3 Data size: 6 Basic stats: COMPLETE 
Column stats: NONE
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: int)
-              sort order: +
-              Map-reduce partition columns: _col0 (type: int)
-              Statistics: Num rows: 1 Data size: 78 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Join Operator
-          condition map:
-               Inner Join 0 to 1
-          keys:
-            0 _col0 (type: int)
-            1 _col0 (type: int)
-          outputColumnNames: _col0, _col1
-          Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
-          Group By Operator
-            keys: _col0 (type: int), _col1 (type: int)
-            mode: hash
-            outputColumnNames: _col0, _col1
-            Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE Column 
stats: NONE
-            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-8
-    Map Reduce
-      Map Operator Tree:
-          TableScan
-            Reduce Output Operator
-              key expressions: _col0 (type: int), _col1 (type: int)
-              sort order: ++
-              Map-reduce partition columns: _col0 (type: int), _col1 (type: 
int)
-              Statistics: Num rows: 3 Data size: 6 Basic stats: COMPLETE 
Column stats: NONE
-      Reduce Operator Tree:
-        Group By Operator
-          keys: KEY._col0 (type: int), KEY._col1 (type: int)
-          mode: mergepartial
-          outputColumnNames: _col0, _col1
           Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE Column 
stats: NONE
           Select Operator
-            expressions: _col0 (type: int), _col1 (type: int), true (type: 
boolean)
-            outputColumnNames: _col0, _col1, _col2
+            expressions: _col0 (type: int), true (type: boolean)
+            outputColumnNames: _col0, _col2
             Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE Column 
stats: NONE
             File Output Operator
               compressed: false
@@ -1666,7 +1220,7 @@ STAGE PLANS:
                   output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                   serde: 
org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
-  Stage: Stage-9
+  Stage: Stage-5
     Map Reduce
       Map Operator Tree:
           TableScan
@@ -1675,7 +1229,7 @@ STAGE PLANS:
               sort order: +
               Map-reduce partition columns: _col0 (type: int)
               Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE 
Column stats: NONE
-              value expressions: _col1 (type: int), _col2 (type: boolean)
+              value expressions: _col2 (type: boolean)
           TableScan
             Reduce Output Operator
               key expressions: _col0 (type: int)
@@ -1689,7 +1243,7 @@ STAGE PLANS:
           keys:
             0 _col0 (type: int)
             1 _col0 (type: int)
-          outputColumnNames: _col1, _col2, _col3
+          outputColumnNames: _col2, _col3
           Statistics: Num rows: 1 Data size: 2 Basic stats: COMPLETE Column 
stats: NONE
           File Output Operator
             compressed: false
@@ -1698,7 +1252,7 @@ STAGE PLANS:
                 output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                 serde: org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
-  Stage: Stage-11
+  Stage: Stage-6
     Map Reduce
       Map Operator Tree:
           TableScan

Reply via email to