hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khorg...@apache.org
Subject [8/9] hive git commit: HIVE-10563 : MiniTezCliDriver tests ordering issues (Hari Subramaniyan via Sushanth Sowmyan) (branch-1.2 patch)
Date Fri, 29 May 2015 22:42:40 GMT
http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/cbo_windowing.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cbo_windowing.q.out b/ql/src/test/results/clientpositive/cbo_windowing.q.out
index 1a274b0..57201b5 100644
--- a/ql/src/test/results/clientpositive/cbo_windowing.q.out
+++ b/ql/src/test/results/clientpositive/cbo_windowing.q.out
@@ -1,10 +1,14 @@
 PREHOOK: query: -- 9. Test Windowing Functions
+-- SORT_QUERY_RESULTS
+
 select count(c_int) over() from cbo_t1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
 POSTHOOK: query: -- 9. Test Windowing Functions
+-- SORT_QUERY_RESULTS
+
 select count(c_int) over() from cbo_t1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
@@ -41,14 +45,6 @@ POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
 18	18.0	1	1	1	1	1	0.0	1	NULL
-18	18.0	1	1	2	1	1	0.0	1	NULL
-18	18.0	1	1	3	1	1	0.0	1	NULL
-18	18.0	1	1	4	1	1	0.0	1	NULL
-18	18.0	1	1	5	1	1	0.0	1	1.0
-18	18.0	1	1	6	1	1	0.0	1	1.0
-18	18.0	1	1	7	1	1	0.0	1	1.0
-18	18.0	1	1	8	1	1	0.0	1	1.0
-18	18.0	1	1	9	1	1	0.0	1	1.0
 18	18.0	1	1	10	1	1	0.0	1	1.0
 18	18.0	1	1	11	1	1	0.0	1	1.0
 18	18.0	1	1	12	1	1	0.0	1	1.0
@@ -59,7 +55,15 @@ POSTHOOK: Input: default@cbo_t1@dt=2014
 18	18.0	1	1	17	1	1	0.0	1	1.0
 18	18.0	1	1	18	1	1	0.0	1	1.0
 18	18.0	1	1	19	1	1	0.0	1	1.0
+18	18.0	1	1	2	1	1	0.0	1	NULL
 18	18.0	1	1	20	1	1	0.0	1	1.0
+18	18.0	1	1	3	1	1	0.0	1	NULL
+18	18.0	1	1	4	1	1	0.0	1	NULL
+18	18.0	1	1	5	1	1	0.0	1	1.0
+18	18.0	1	1	6	1	1	0.0	1	1.0
+18	18.0	1	1	7	1	1	0.0	1	1.0
+18	18.0	1	1	8	1	1	0.0	1	1.0
+18	18.0	1	1	9	1	1	0.0	1	1.0
 PREHOOK: query: select * from (select count(c_int) over(), sum(c_float) over(), max(c_int) over(), min(c_int) over(), row_number() over(), rank() over(), dense_rank() over(), percent_rank() over(), lead(c_int, 2, c_int) over(), lag(c_float, 2, c_float) over() from cbo_t1) cbo_t1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -71,14 +75,6 @@ POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
 18	18.0	1	1	1	1	1	0.0	1	NULL
-18	18.0	1	1	2	1	1	0.0	1	NULL
-18	18.0	1	1	3	1	1	0.0	1	NULL
-18	18.0	1	1	4	1	1	0.0	1	NULL
-18	18.0	1	1	5	1	1	0.0	1	1.0
-18	18.0	1	1	6	1	1	0.0	1	1.0
-18	18.0	1	1	7	1	1	0.0	1	1.0
-18	18.0	1	1	8	1	1	0.0	1	1.0
-18	18.0	1	1	9	1	1	0.0	1	1.0
 18	18.0	1	1	10	1	1	0.0	1	1.0
 18	18.0	1	1	11	1	1	0.0	1	1.0
 18	18.0	1	1	12	1	1	0.0	1	1.0
@@ -89,7 +85,15 @@ POSTHOOK: Input: default@cbo_t1@dt=2014
 18	18.0	1	1	17	1	1	0.0	1	1.0
 18	18.0	1	1	18	1	1	0.0	1	1.0
 18	18.0	1	1	19	1	1	0.0	1	1.0
+18	18.0	1	1	2	1	1	0.0	1	NULL
 18	18.0	1	1	20	1	1	0.0	1	1.0
+18	18.0	1	1	3	1	1	0.0	1	NULL
+18	18.0	1	1	4	1	1	0.0	1	NULL
+18	18.0	1	1	5	1	1	0.0	1	1.0
+18	18.0	1	1	6	1	1	0.0	1	1.0
+18	18.0	1	1	7	1	1	0.0	1	1.0
+18	18.0	1	1	8	1	1	0.0	1	1.0
+18	18.0	1	1	9	1	1	0.0	1	1.0
 PREHOOK: query: select x from (select count(c_int) over() as x, sum(c_float) over() from cbo_t1) cbo_t1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -171,13 +175,16 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
-NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
 1	1	1	1.0	1.0	1.0	1.0	1.0	1.0
-1	1	2	1.0	2.0	1.0	2.0	1.0	1.0
 1	1	1	1.0	1.0	1.0	1.0	1.0	1.0
-1	1	2	1.0	2.0	1.0	2.0	1.0	1.0
 1	1	1	1.0	1.0	1.0	1.0	1.0	1.0
+1	1	1	1.0	1.0	1.0	1.0	1.0	1.0
+1	1	2	1.0	10.0	1.0	2.0	1.0	1.0
+1	1	2	1.0	11.0	1.0	2.0	1.0	1.0
+1	1	2	1.0	12.0	1.0	2.0	1.0	1.0
+1	1	2	1.0	2.0	1.0	2.0	1.0	1.0
+1	1	2	1.0	2.0	1.0	2.0	1.0	1.0
+1	1	2	1.0	2.0	1.0	2.0	1.0	1.0
 1	1	2	1.0	2.0	1.0	2.0	1.0	1.0
 1	1	2	1.0	3.0	1.0	2.0	1.0	1.0
 1	1	2	1.0	4.0	1.0	2.0	1.0	1.0
@@ -186,11 +193,8 @@ NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
 1	1	2	1.0	7.0	1.0	2.0	1.0	1.0
 1	1	2	1.0	8.0	1.0	2.0	1.0	1.0
 1	1	2	1.0	9.0	1.0	2.0	1.0	1.0
-1	1	2	1.0	10.0	1.0	2.0	1.0	1.0
-1	1	2	1.0	11.0	1.0	2.0	1.0	1.0
-1	1	2	1.0	12.0	1.0	2.0	1.0	1.0
-1	1	1	1.0	1.0	1.0	1.0	1.0	1.0
-1	1	2	1.0	2.0	1.0	2.0	1.0	1.0
+NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
+NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
 PREHOOK: query: select i, a, h, b, c, d, e, f, g, a as x, a +1 as y from (select max(c_int) over (partition by key order by value range UNBOUNDED PRECEDING) a, min(c_int) over (partition by key order by value range current row) b, count(c_int) over(partition by key order by value range 1 PRECEDING) c, avg(value) over (partition by key order by value range between unbounded preceding and unbounded following) d, sum(value) over (partition by key order by value range between unbounded preceding and current row) e, avg(c_float) over (partition by key order by value range between 1 preceding and unbounded following) f, sum(c_float) over (partition by key order by value range between 1 preceding and current row) g, max(c_float) over (partition by key order by value range between 1 preceding and unbounded following) h, min(c_float) over (partition by key order by value range between 1 preceding and 1 following) i from cbo_t1) cbo_t1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -201,12 +205,6 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-NULL	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
-NULL	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
-1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
-1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
-1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
-1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
 1.0	1	1.0	1	12	1.0	12.0	1.0	12.0	1	2
 1.0	1	1.0	1	12	1.0	12.0	1.0	12.0	1	2
 1.0	1	1.0	1	12	1.0	12.0	1.0	12.0	1	2
@@ -221,6 +219,12 @@ NULL	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
 1.0	1	1.0	1	12	1.0	12.0	1.0	12.0	1	2
 1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
 1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
+1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
+1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
+1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
+1.0	1	1.0	1	2	1.0	2.0	1.0	2.0	1	2
+NULL	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
+NULL	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL
 PREHOOK: query: select *, rank() over(partition by key order by value) as rr from src1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src1

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/cross_product_check_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cross_product_check_1.q.out b/ql/src/test/results/clientpositive/cross_product_check_1.q.out
index b83cb6f..3ab418a 100644
--- a/ql/src/test/results/clientpositive/cross_product_check_1.q.out
+++ b/ql/src/test/results/clientpositive/cross_product_check_1.q.out
@@ -1,10 +1,14 @@
-PREHOOK: query: create table A as
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+create table A as
 select * from src
 PREHOOK: type: CREATETABLE_AS_SELECT
 PREHOOK: Input: default@src
 PREHOOK: Output: database:default
 PREHOOK: Output: default@A
-POSTHOOK: query: create table A as
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+create table A as
 select * from src
 POSTHOOK: type: CREATETABLE_AS_SELECT
 POSTHOOK: Input: default@src
@@ -181,12 +185,12 @@ STAGE PLANS:
 Warning: Shuffle Join JOIN[16][tables = [a, od1]] in Stage 'Stage-3:MAPRED' is a cross product
 PREHOOK: query: explain select * from A join 
          (select d1.key 
-          from B d1 join B d2 on d1.key = d2.key 
+          from B d1 join B d2 on d1.key = d2.key
           where 1 = 1 group by d1.key) od1
 PREHOOK: type: QUERY
 POSTHOOK: query: explain select * from A join 
          (select d1.key 
-          from B d1 join B d2 on d1.key = d2.key 
+          from B d1 join B d2 on d1.key = d2.key
           where 1 = 1 group by d1.key) od1
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
@@ -308,9 +312,9 @@ STAGE PLANS:
 
 Warning: Shuffle Join JOIN[14][tables = [a, od1]] in Stage 'Stage-3:MAPRED' is a cross product
 Warning: Shuffle Join JOIN[4][tables = [d1, d2]] in Stage 'Stage-1:MAPRED' is a cross product
-PREHOOK: query: explain select * from A join (select d1.key from B d1 join B d2 where 1 = 1 group by d1.key) od1
+PREHOOK: query: explain select * from A join (select d1.key from B d1 join B d2 where 1 = 1  group by d1.key) od1
 PREHOOK: type: QUERY
-POSTHOOK: query: explain select * from A join (select d1.key from B d1 join B d2 where 1 = 1 group by d1.key) od1
+POSTHOOK: query: explain select * from A join (select d1.key from B d1 join B d2 where 1 = 1  group by d1.key) od1
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -422,11 +426,11 @@ STAGE PLANS:
 
 Warning: Shuffle Join JOIN[21][tables = [ss, od1]] in Stage 'Stage-2:MAPRED' is a cross product
 PREHOOK: query: explain select * from 
-(select A.key from A group by key) ss join 
+(select A.key from A  group by key) ss join
 (select d1.key from B d1 join B d2 on d1.key = d2.key where 1 = 1 group by d1.key) od1
 PREHOOK: type: QUERY
 POSTHOOK: query: explain select * from 
-(select A.key from A group by key) ss join 
+(select A.key from A  group by key) ss join
 (select d1.key from B d1 join B d2 on d1.key = d2.key where 1 = 1 group by d1.key) od1
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/cross_product_check_2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cross_product_check_2.q.out b/ql/src/test/results/clientpositive/cross_product_check_2.q.out
index 02b03d7..6910b40 100644
--- a/ql/src/test/results/clientpositive/cross_product_check_2.q.out
+++ b/ql/src/test/results/clientpositive/cross_product_check_2.q.out
@@ -1,24 +1,28 @@
-PREHOOK: query: create table A as
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+create table A as
 select * from src
 PREHOOK: type: CREATETABLE_AS_SELECT
 PREHOOK: Input: default@src
 PREHOOK: Output: database:default
 PREHOOK: Output: default@A
-POSTHOOK: query: create table A as
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+create table A as
 select * from src
 POSTHOOK: type: CREATETABLE_AS_SELECT
 POSTHOOK: Input: default@src
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@A
 PREHOOK: query: create table B as
-select * from src
+select * from src order by key
 limit 10
 PREHOOK: type: CREATETABLE_AS_SELECT
 PREHOOK: Input: default@src
 PREHOOK: Output: database:default
 PREHOOK: Output: default@B
 POSTHOOK: query: create table B as
-select * from src
+select * from src order by key
 limit 10
 POSTHOOK: type: CREATETABLE_AS_SELECT
 POSTHOOK: Input: default@src
@@ -45,11 +49,11 @@ STAGE PLANS:
         $hdt$_1:b 
           TableScan
             alias: b
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             Select Operator
               expressions: key (type: string), value (type: string)
               outputColumnNames: _col0, _col1
-              Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
               HashTable Sink Operator
                 keys:
                   0 
@@ -121,10 +125,10 @@ STAGE PLANS:
         d1 
           TableScan
             alias: d1
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             Filter Operator
               predicate: key is not null (type: boolean)
-              Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 5 Data size: 48 Basic stats: COMPLETE Column stats: NONE
               HashTable Sink Operator
                 keys:
                   0 key (type: string)
@@ -135,10 +139,10 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: d2
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             Filter Operator
               predicate: key is not null (type: boolean)
-              Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 5 Data size: 48 Basic stats: COMPLETE Column stats: NONE
               Map Join Operator
                 condition map:
                      Inner Join 0 to 1
@@ -146,7 +150,7 @@ STAGE PLANS:
                   0 key (type: string)
                   1 key (type: string)
                 outputColumnNames: _col0, _col1, _col5, _col6
-                Statistics: Num rows: 5 Data size: 57 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
                 Map Join Operator
                   condition map:
                        Inner Join 0 to 1
@@ -204,10 +208,10 @@ STAGE PLANS:
         od1:d1 
           TableScan
             alias: d1
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             Filter Operator
               predicate: key is not null (type: boolean)
-              Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 5 Data size: 48 Basic stats: COMPLETE Column stats: NONE
               HashTable Sink Operator
                 keys:
                   0 key (type: string)
@@ -218,10 +222,10 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: d2
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             Filter Operator
               predicate: key is not null (type: boolean)
-              Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 5 Data size: 48 Basic stats: COMPLETE Column stats: NONE
               Map Join Operator
                 condition map:
                      Inner Join 0 to 1
@@ -229,17 +233,17 @@ STAGE PLANS:
                   0 key (type: string)
                   1 key (type: string)
                 outputColumnNames: _col0
-                Statistics: Num rows: 5 Data size: 57 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
                 Group By Operator
                   keys: _col0 (type: string)
                   mode: hash
                   outputColumnNames: _col0
-                  Statistics: Num rows: 5 Data size: 57 Basic stats: COMPLETE Column stats: NONE
+                  Statistics: Num rows: 5 Data size: 52 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: 5 Data size: 57 Basic stats: COMPLETE Column stats: NONE
+                    Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
       Local Work:
         Map Reduce Local Work
       Reduce Operator Tree:
@@ -247,7 +251,7 @@ STAGE PLANS:
           keys: KEY._col0 (type: string)
           mode: mergepartial
           outputColumnNames: _col0
-          Statistics: Num rows: 2 Data size: 22 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 2 Data size: 20 Basic stats: COMPLETE Column stats: NONE
           File Output Operator
             compressed: false
             table:
@@ -327,7 +331,7 @@ STAGE PLANS:
         od1:d1 
           TableScan
             alias: d1
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             HashTable Sink Operator
               keys:
                 0 
@@ -338,7 +342,7 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: d2
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: COMPLETE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: COMPLETE
             Map Join Operator
               condition map:
                    Inner Join 0 to 1
@@ -346,17 +350,17 @@ STAGE PLANS:
                 0 
                 1 
               outputColumnNames: _col0
-              Statistics: Num rows: 11 Data size: 114 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 11 Data size: 105 Basic stats: COMPLETE Column stats: NONE
               Group By Operator
                 keys: _col0 (type: string)
                 mode: hash
                 outputColumnNames: _col0
-                Statistics: Num rows: 11 Data size: 114 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 11 Data size: 105 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: 11 Data size: 114 Basic stats: COMPLETE Column stats: NONE
+                  Statistics: Num rows: 11 Data size: 105 Basic stats: COMPLETE Column stats: NONE
       Local Work:
         Map Reduce Local Work
       Reduce Operator Tree:
@@ -364,7 +368,7 @@ STAGE PLANS:
           keys: KEY._col0 (type: string)
           mode: mergepartial
           outputColumnNames: _col0
-          Statistics: Num rows: 5 Data size: 51 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 5 Data size: 47 Basic stats: COMPLETE Column stats: NONE
           File Output Operator
             compressed: false
             table:
@@ -563,7 +567,7 @@ STAGE PLANS:
           TableScan
             Reduce Output Operator
               sort order: 
-              Statistics: Num rows: 2 Data size: 22 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 2 Data size: 20 Basic stats: COMPLETE Column stats: NONE
               value expressions: _col0 (type: string)
       Reduce Operator Tree:
         Join Operator
@@ -592,10 +596,10 @@ STAGE PLANS:
         od1:d1 
           TableScan
             alias: d1
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             Filter Operator
               predicate: key is not null (type: boolean)
-              Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 5 Data size: 48 Basic stats: COMPLETE Column stats: NONE
               HashTable Sink Operator
                 keys:
                   0 key (type: string)
@@ -606,10 +610,10 @@ STAGE PLANS:
       Map Operator Tree:
           TableScan
             alias: d2
-            Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
+            Statistics: Num rows: 10 Data size: 96 Basic stats: COMPLETE Column stats: NONE
             Filter Operator
               predicate: key is not null (type: boolean)
-              Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
+              Statistics: Num rows: 5 Data size: 48 Basic stats: COMPLETE Column stats: NONE
               Map Join Operator
                 condition map:
                      Inner Join 0 to 1
@@ -617,17 +621,17 @@ STAGE PLANS:
                   0 key (type: string)
                   1 key (type: string)
                 outputColumnNames: _col0
-                Statistics: Num rows: 5 Data size: 57 Basic stats: COMPLETE Column stats: NONE
+                Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
                 Group By Operator
                   keys: _col0 (type: string)
                   mode: hash
                   outputColumnNames: _col0
-                  Statistics: Num rows: 5 Data size: 57 Basic stats: COMPLETE Column stats: NONE
+                  Statistics: Num rows: 5 Data size: 52 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: 5 Data size: 57 Basic stats: COMPLETE Column stats: NONE
+                    Statistics: Num rows: 5 Data size: 52 Basic stats: COMPLETE Column stats: NONE
       Local Work:
         Map Reduce Local Work
       Reduce Operator Tree:
@@ -635,7 +639,7 @@ STAGE PLANS:
           keys: KEY._col0 (type: string)
           mode: mergepartial
           outputColumnNames: _col0
-          Statistics: Num rows: 2 Data size: 22 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 2 Data size: 20 Basic stats: COMPLETE Column stats: NONE
           File Output Operator
             compressed: false
             table:

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/ctas.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/ctas.q.out b/ql/src/test/results/clientpositive/ctas.q.out
index 586a832..6f17a74 100644
--- a/ql/src/test/results/clientpositive/ctas.q.out
+++ b/ql/src/test/results/clientpositive/ctas.q.out
@@ -1,10 +1,12 @@
 PREHOOK: query: -- EXCLUDE_HADOOP_MAJOR_VERSIONS( 0.20S)
+-- SORT_QUERY_RESULTS
 
 create table nzhang_Tmp(a int, b string)
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@nzhang_Tmp
 POSTHOOK: query: -- EXCLUDE_HADOOP_MAJOR_VERSIONS( 0.20S)
+-- SORT_QUERY_RESULTS
 
 create table nzhang_Tmp(a int, b string)
 POSTHOOK: type: CREATETABLE

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/dynpart_sort_optimization2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/dynpart_sort_optimization2.q.out b/ql/src/test/results/clientpositive/dynpart_sort_optimization2.q.out
index 153e9bf..1ec7556 100644
--- a/ql/src/test/results/clientpositive/dynpart_sort_optimization2.q.out
+++ b/ql/src/test/results/clientpositive/dynpart_sort_optimization2.q.out
@@ -1,6 +1,10 @@
-PREHOOK: query: drop table ss
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+drop table ss
 PREHOOK: type: DROPTABLE
-POSTHOOK: query: drop table ss
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+drop table ss
 POSTHOOK: type: DROPTABLE
 PREHOOK: query: drop table ss_orc
 PREHOOK: type: DROPTABLE
@@ -213,17 +217,17 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452617
 #### A masked pattern was here ####
+10022.63	3952.8	2452617
+1765.07	-4648.8	2452617
 2.1	-2026.3	2452617
 2.99	-11.32	2452617
-85.8	25.61	2452617
-552.96	-1363.84	2452617
-565.92	196.48	2452617
-879.07	-2185.76	2452617
-1765.07	-4648.8	2452617
 3423.95	-3164.07	2452617
 5362.01	-600.28	2452617
+552.96	-1363.84	2452617
+565.92	196.48	2452617
 7412.83	2071.68	2452617
-10022.63	3952.8	2452617
+85.8	25.61	2452617
+879.07	-2185.76	2452617
 PREHOOK: query: desc formatted ss_part partition(ss_sold_date_sk=2452638)
 PREHOOK: type: DESCTABLE
 PREHOOK: Input: default@ss_part
@@ -276,18 +280,18 @@ POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452638
 #### A masked pattern was here ####
 0.15	-241.22	2452638
+10171.1	660.48	2452638
+1327.08	57.97	2452638
+1413.19	178.08	2452638
 150.39	-162.12	2452638
+1524.33	494.37	2452638
 156.67	-4626.56	2452638
 181.03	-207.24	2452638
+1971.35	-488.25	2452638
 267.01	-3266.36	2452638
 317.87	-3775.38	2452638
-1327.08	57.97	2452638
-1413.19	178.08	2452638
-1524.33	494.37	2452638
-1971.35	-488.25	2452638
 4133.98	-775.72	2452638
 4329.49	-4000.51	2452638
-10171.1	660.48	2452638
 PREHOOK: query: explain insert overwrite table ss_part partition (ss_sold_date_sk)
 select ss_net_paid_inc_tax,
   ss_net_profit,
@@ -435,16 +439,16 @@ POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452617
 #### A masked pattern was here ####
 10022.63	3952.8	2452617
+1765.07	-4648.8	2452617
+2.1	-2026.3	2452617
 2.99	-11.32	2452617
 3423.95	-3164.07	2452617
 5362.01	-600.28	2452617
+552.96	-1363.84	2452617
 565.92	196.48	2452617
-85.8	25.61	2452617
 7412.83	2071.68	2452617
+85.8	25.61	2452617
 879.07	-2185.76	2452617
-1765.07	-4648.8	2452617
-552.96	-1363.84	2452617
-2.1	-2026.3	2452617
 PREHOOK: query: desc formatted ss_part partition(ss_sold_date_sk=2452638)
 PREHOOK: type: DESCTABLE
 PREHOOK: Input: default@ss_part
@@ -496,19 +500,19 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452638
 #### A masked pattern was here ####
-4329.49	-4000.51	2452638
+0.15	-241.22	2452638
+10171.1	660.48	2452638
+1327.08	57.97	2452638
 1413.19	178.08	2452638
 150.39	-162.12	2452638
 1524.33	494.37	2452638
-0.15	-241.22	2452638
-267.01	-3266.36	2452638
+156.67	-4626.56	2452638
 181.03	-207.24	2452638
 1971.35	-488.25	2452638
-1327.08	57.97	2452638
-156.67	-4626.56	2452638
+267.01	-3266.36	2452638
 317.87	-3775.38	2452638
-10171.1	660.48	2452638
 4133.98	-775.72	2452638
+4329.49	-4000.51	2452638
 PREHOOK: query: -- SORT DYNAMIC PARTITION DISABLED
 
 explain insert overwrite table ss_part partition (ss_sold_date_sk)
@@ -676,17 +680,17 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452617
 #### A masked pattern was here ####
+10022.63	3952.8	2452617
+1765.07	-4648.8	2452617
 2.1	-2026.3	2452617
 2.99	-11.32	2452617
-85.8	25.61	2452617
-552.96	-1363.84	2452617
-565.92	196.48	2452617
-879.07	-2185.76	2452617
-1765.07	-4648.8	2452617
 3423.95	-3164.07	2452617
 5362.01	-600.28	2452617
+552.96	-1363.84	2452617
+565.92	196.48	2452617
 7412.83	2071.68	2452617
-10022.63	3952.8	2452617
+85.8	25.61	2452617
+879.07	-2185.76	2452617
 PREHOOK: query: desc formatted ss_part partition(ss_sold_date_sk=2452638)
 PREHOOK: type: DESCTABLE
 PREHOOK: Input: default@ss_part
@@ -739,18 +743,18 @@ POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452638
 #### A masked pattern was here ####
 0.15	-241.22	2452638
+10171.1	660.48	2452638
+1327.08	57.97	2452638
+1413.19	178.08	2452638
 150.39	-162.12	2452638
+1524.33	494.37	2452638
 156.67	-4626.56	2452638
 181.03	-207.24	2452638
+1971.35	-488.25	2452638
 267.01	-3266.36	2452638
 317.87	-3775.38	2452638
-1327.08	57.97	2452638
-1413.19	178.08	2452638
-1524.33	494.37	2452638
-1971.35	-488.25	2452638
 4133.98	-775.72	2452638
 4329.49	-4000.51	2452638
-10171.1	660.48	2452638
 PREHOOK: query: explain insert overwrite table ss_part partition (ss_sold_date_sk)
 select ss_net_paid_inc_tax,
   ss_net_profit,
@@ -896,17 +900,17 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452617
 #### A masked pattern was here ####
+10022.63	3952.8	2452617
+1765.07	-4648.8	2452617
+2.1	-2026.3	2452617
+2.99	-11.32	2452617
 3423.95	-3164.07	2452617
 5362.01	-600.28	2452617
+552.96	-1363.84	2452617
 565.92	196.48	2452617
-85.8	25.61	2452617
 7412.83	2071.68	2452617
+85.8	25.61	2452617
 879.07	-2185.76	2452617
-1765.07	-4648.8	2452617
-552.96	-1363.84	2452617
-2.1	-2026.3	2452617
-10022.63	3952.8	2452617
-2.99	-11.32	2452617
 PREHOOK: query: desc formatted ss_part partition(ss_sold_date_sk=2452638)
 PREHOOK: type: DESCTABLE
 PREHOOK: Input: default@ss_part
@@ -958,19 +962,19 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part
 POSTHOOK: Input: default@ss_part@ss_sold_date_sk=2452638
 #### A masked pattern was here ####
-4329.49	-4000.51	2452638
+0.15	-241.22	2452638
+10171.1	660.48	2452638
+1327.08	57.97	2452638
 1413.19	178.08	2452638
 150.39	-162.12	2452638
 1524.33	494.37	2452638
-0.15	-241.22	2452638
-267.01	-3266.36	2452638
+156.67	-4626.56	2452638
 181.03	-207.24	2452638
 1971.35	-488.25	2452638
-1327.08	57.97	2452638
-156.67	-4626.56	2452638
+267.01	-3266.36	2452638
 317.87	-3775.38	2452638
-10171.1	660.48	2452638
 4133.98	-775.72	2452638
+4329.49	-4000.51	2452638
 PREHOOK: query: -- VECTORIZATION IS ENABLED
 
 create table ss_orc (
@@ -1194,17 +1198,17 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part_orc
 POSTHOOK: Input: default@ss_part_orc@ss_sold_date_sk=2452617
 #### A masked pattern was here ####
+10022.63	3952.8	2452617
+1765.07	-4648.8	2452617
 2.1	-2026.3	2452617
 2.99	-11.32	2452617
-85.8	25.61	2452617
-552.96	-1363.84	2452617
-565.92	196.48	2452617
-879.07	-2185.76	2452617
-1765.07	-4648.8	2452617
 3423.95	-3164.07	2452617
 5362.01	-600.28	2452617
+552.96	-1363.84	2452617
+565.92	196.48	2452617
 7412.83	2071.68	2452617
-10022.63	3952.8	2452617
+85.8	25.61	2452617
+879.07	-2185.76	2452617
 PREHOOK: query: desc formatted ss_part_orc partition(ss_sold_date_sk=2452638)
 PREHOOK: type: DESCTABLE
 PREHOOK: Input: default@ss_part_orc
@@ -1257,18 +1261,18 @@ POSTHOOK: Input: default@ss_part_orc
 POSTHOOK: Input: default@ss_part_orc@ss_sold_date_sk=2452638
 #### A masked pattern was here ####
 0.15	-241.22	2452638
+10171.1	660.48	2452638
+1327.08	57.97	2452638
+1413.19	178.08	2452638
 150.39	-162.12	2452638
+1524.33	494.37	2452638
 156.67	-4626.56	2452638
 181.03	-207.24	2452638
+1971.35	-488.25	2452638
 267.01	-3266.36	2452638
 317.87	-3775.38	2452638
-1327.08	57.97	2452638
-1413.19	178.08	2452638
-1524.33	494.37	2452638
-1971.35	-488.25	2452638
 4133.98	-775.72	2452638
 4329.49	-4000.51	2452638
-10171.1	660.48	2452638
 PREHOOK: query: explain insert overwrite table ss_part_orc partition (ss_sold_date_sk)
 select ss_net_paid_inc_tax,
   ss_net_profit,
@@ -1415,17 +1419,17 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part_orc
 POSTHOOK: Input: default@ss_part_orc@ss_sold_date_sk=2452617
 #### A masked pattern was here ####
+10022.63	3952.8	2452617
+1765.07	-4648.8	2452617
+2.1	-2026.3	2452617
+2.99	-11.32	2452617
 3423.95	-3164.07	2452617
 5362.01	-600.28	2452617
+552.96	-1363.84	2452617
 565.92	196.48	2452617
-85.8	25.61	2452617
 7412.83	2071.68	2452617
+85.8	25.61	2452617
 879.07	-2185.76	2452617
-1765.07	-4648.8	2452617
-552.96	-1363.84	2452617
-2.1	-2026.3	2452617
-10022.63	3952.8	2452617
-2.99	-11.32	2452617
 PREHOOK: query: desc formatted ss_part_orc partition(ss_sold_date_sk=2452638)
 PREHOOK: type: DESCTABLE
 PREHOOK: Input: default@ss_part_orc
@@ -1477,19 +1481,19 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@ss_part_orc
 POSTHOOK: Input: default@ss_part_orc@ss_sold_date_sk=2452638
 #### A masked pattern was here ####
-4329.49	-4000.51	2452638
+0.15	-241.22	2452638
+10171.1	660.48	2452638
+1327.08	57.97	2452638
 1413.19	178.08	2452638
 150.39	-162.12	2452638
 1524.33	494.37	2452638
-0.15	-241.22	2452638
-267.01	-3266.36	2452638
+156.67	-4626.56	2452638
 181.03	-207.24	2452638
 1971.35	-488.25	2452638
-1327.08	57.97	2452638
-156.67	-4626.56	2452638
+267.01	-3266.36	2452638
 317.87	-3775.38	2452638
-10171.1	660.48	2452638
 4133.98	-775.72	2452638
+4329.49	-4000.51	2452638
 PREHOOK: query: drop table ss_orc
 PREHOOK: type: DROPTABLE
 PREHOOK: Input: default@ss_orc
@@ -1629,21 +1633,21 @@ POSTHOOK: Input: default@src
 POSTHOOK: Output: default@hive13_dp1@day=day
 POSTHOOK: Lineage: hive13_dp1 PARTITION(day=day).k1 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ]
 POSTHOOK: Lineage: hive13_dp1 PARTITION(day=day).k2 EXPRESSION [(src)src.FieldSchema(name:value, type:string, comment:default), ]
-PREHOOK: query: select * from hive13_dp1 limit 5
+PREHOOK: query: select * from hive13_dp1 order by k1, k2 limit 5
 PREHOOK: type: QUERY
 PREHOOK: Input: default@hive13_dp1
 PREHOOK: Input: default@hive13_dp1@day=day
 #### A masked pattern was here ####
-POSTHOOK: query: select * from hive13_dp1 limit 5
+POSTHOOK: query: select * from hive13_dp1 order by k1, k2 limit 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@hive13_dp1
 POSTHOOK: Input: default@hive13_dp1@day=day
 #### A masked pattern was here ####
 0	3	day
-10	1	day
-100	2	day
-103	2	day
-104	2	day
+2	1	day
+4	1	day
+5	3	day
+8	1	day
 PREHOOK: query: explain insert overwrite table `hive13_dp1` partition(`day`)
 select
     key k1,
@@ -1745,21 +1749,21 @@ POSTHOOK: Input: default@src
 POSTHOOK: Output: default@hive13_dp1@day=day
 POSTHOOK: Lineage: hive13_dp1 PARTITION(day=day).k1 EXPRESSION [(src)src.FieldSchema(name:key, type:string, comment:default), ]
 POSTHOOK: Lineage: hive13_dp1 PARTITION(day=day).k2 EXPRESSION [(src)src.FieldSchema(name:value, type:string, comment:default), ]
-PREHOOK: query: select * from hive13_dp1 limit 5
+PREHOOK: query: select * from hive13_dp1 order by k1, k2 limit 5
 PREHOOK: type: QUERY
 PREHOOK: Input: default@hive13_dp1
 PREHOOK: Input: default@hive13_dp1@day=day
 #### A masked pattern was here ####
-POSTHOOK: query: select * from hive13_dp1 limit 5
+POSTHOOK: query: select * from hive13_dp1 order by k1, k2 limit 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@hive13_dp1
 POSTHOOK: Input: default@hive13_dp1@day=day
 #### A masked pattern was here ####
 0	3	day
-10	1	day
-100	2	day
-103	2	day
-104	2	day
+2	1	day
+4	1	day
+5	3	day
+8	1	day
 PREHOOK: query: drop table hive13_dp1
 PREHOOK: type: DROPTABLE
 PREHOOK: Input: default@hive13_dp1

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/filter_join_breaktask2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/filter_join_breaktask2.q.out b/ql/src/test/results/clientpositive/filter_join_breaktask2.q.out
index 6a2396e..af85af9 100644
--- a/ql/src/test/results/clientpositive/filter_join_breaktask2.q.out
+++ b/ql/src/test/results/clientpositive/filter_join_breaktask2.q.out
@@ -1,9 +1,13 @@
-PREHOOK: query: create table T1(c1 string, c2 string, c3 string, c4 string, c5 string, c6 string, c7 string) 
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+create table T1(c1 string, c2 string, c3 string, c4 string, c5 string, c6 string, c7 string) 
 partitioned by (ds string)
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@T1
-POSTHOOK: query: create table T1(c1 string, c2 string, c3 string, c4 string, c5 string, c6 string, c7 string) 
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+create table T1(c1 string, c2 string, c3 string, c4 string, c5 string, c6 string, c7 string) 
 partitioned by (ds string)
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/insert_into1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/insert_into1.q.out b/ql/src/test/results/clientpositive/insert_into1.q.out
index 9e5f3bb..2b5cbca 100644
--- a/ql/src/test/results/clientpositive/insert_into1.q.out
+++ b/ql/src/test/results/clientpositive/insert_into1.q.out
@@ -1,6 +1,10 @@
-PREHOOK: query: DROP TABLE insert_into1
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+DROP TABLE insert_into1
 PREHOOK: type: DROPTABLE
-POSTHOOK: query: DROP TABLE insert_into1
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+DROP TABLE insert_into1
 POSTHOOK: type: DROPTABLE
 PREHOOK: query: CREATE TABLE insert_into1 (key int, value string)
 PREHOOK: type: CREATETABLE
@@ -10,9 +14,9 @@ POSTHOOK: query: CREATE TABLE insert_into1 (key int, value string)
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@insert_into1
-PREHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * from src LIMIT 100
+PREHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * from src ORDER BY key LIMIT 100
 PREHOOK: type: QUERY
-POSTHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * from src LIMIT 100
+POSTHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * from src ORDER BY key LIMIT 100
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -30,18 +34,16 @@ STAGE PLANS:
               expressions: key (type: string), value (type: string)
               outputColumnNames: _col0, _col1
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Limit
-                Number of rows: 100
-                Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
-                  Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string), _col1 (type: string)
+              Reduce Output Operator
+                key expressions: _col0 (type: string)
+                sort order: +
+                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col1 (type: string)
       Reduce Operator Tree:
         Select Operator
-          expressions: VALUE._col0 (type: string), VALUE._col1 (type: string)
+          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 100
             Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
@@ -71,11 +73,11 @@ STAGE PLANS:
   Stage: Stage-2
     Stats-Aggr Operator
 
-PREHOOK: query: INSERT INTO TABLE insert_into1 SELECT * from src LIMIT 100
+PREHOOK: query: INSERT INTO TABLE insert_into1 SELECT * from src ORDER BY key LIMIT 100
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: default@insert_into1
-POSTHOOK: query: INSERT INTO TABLE insert_into1 SELECT * from src LIMIT 100
+POSTHOOK: query: INSERT INTO TABLE insert_into1 SELECT * from src ORDER BY key LIMIT 100
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: default@insert_into1
@@ -93,7 +95,7 @@ POSTHOOK: query: SELECT SUM(HASH(c)) FROM (
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@insert_into1
 #### A masked pattern was here ####
-10226524244
+-1142373758
 PREHOOK: query: explain 
 select count(*) from insert_into1
 PREHOOK: type: QUERY
@@ -119,9 +121,9 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@insert_into1
 #### A masked pattern was here ####
 100
-PREHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * FROM src LIMIT 100
+PREHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 100
 PREHOOK: type: QUERY
-POSTHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * FROM src LIMIT 100
+POSTHOOK: query: EXPLAIN INSERT INTO TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 100
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -139,18 +141,16 @@ STAGE PLANS:
               expressions: key (type: string), value (type: string)
               outputColumnNames: _col0, _col1
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Limit
-                Number of rows: 100
-                Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
-                  Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string), _col1 (type: string)
+              Reduce Output Operator
+                key expressions: _col0 (type: string)
+                sort order: +
+                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col1 (type: string)
       Reduce Operator Tree:
         Select Operator
-          expressions: VALUE._col0 (type: string), VALUE._col1 (type: string)
+          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 100
             Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
@@ -180,11 +180,11 @@ STAGE PLANS:
   Stage: Stage-2
     Stats-Aggr Operator
 
-PREHOOK: query: INSERT INTO TABLE insert_into1 SELECT * FROM src LIMIT 100
+PREHOOK: query: INSERT INTO TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 100
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: default@insert_into1
-POSTHOOK: query: INSERT INTO TABLE insert_into1 SELECT * FROM src LIMIT 100
+POSTHOOK: query: INSERT INTO TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 100
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: default@insert_into1
@@ -202,7 +202,7 @@ POSTHOOK: query: SELECT SUM(HASH(c)) FROM (
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@insert_into1
 #### A masked pattern was here ####
-20453048488
+-2284747516
 PREHOOK: query: explain
 SELECT COUNT(*) FROM insert_into1
 PREHOOK: type: QUERY
@@ -228,9 +228,9 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@insert_into1
 #### A masked pattern was here ####
 200
-PREHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src LIMIT 10
+PREHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 10
 PREHOOK: type: QUERY
-POSTHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src LIMIT 10
+POSTHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 10
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -248,18 +248,16 @@ STAGE PLANS:
               expressions: key (type: string), value (type: string)
               outputColumnNames: _col0, _col1
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Limit
-                Number of rows: 10
-                Statistics: Num rows: 10 Data size: 100 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
-                  Statistics: Num rows: 10 Data size: 100 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string), _col1 (type: string)
+              Reduce Output Operator
+                key expressions: _col0 (type: string)
+                sort order: +
+                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col1 (type: string)
       Reduce Operator Tree:
         Select Operator
-          expressions: VALUE._col0 (type: string), VALUE._col1 (type: string)
+          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 10 Data size: 100 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 10
             Statistics: Num rows: 10 Data size: 100 Basic stats: COMPLETE Column stats: NONE
@@ -289,11 +287,11 @@ STAGE PLANS:
   Stage: Stage-2
     Stats-Aggr Operator
 
-PREHOOK: query: INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src LIMIT 10
+PREHOOK: query: INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 10
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: default@insert_into1
-POSTHOOK: query: INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src LIMIT 10
+POSTHOOK: query: INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: default@insert_into1
@@ -311,7 +309,7 @@ POSTHOOK: query: SELECT SUM(HASH(c)) FROM (
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@insert_into1
 #### A masked pattern was here ####
--826625916
+-2693537120
 PREHOOK: query: explain
 SELECT COUNT(*) FROM insert_into1
 PREHOOK: type: QUERY

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/insert_into2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/insert_into2.q.out b/ql/src/test/results/clientpositive/insert_into2.q.out
index acbedb5..cc7e135 100644
--- a/ql/src/test/results/clientpositive/insert_into2.q.out
+++ b/ql/src/test/results/clientpositive/insert_into2.q.out
@@ -13,10 +13,10 @@ POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@insert_into2
 PREHOOK: query: EXPLAIN INSERT INTO TABLE insert_into2 PARTITION (ds='1') 
-  SELECT * FROM src LIMIT 100
+  SELECT * FROM src order by key LIMIT 100
 PREHOOK: type: QUERY
 POSTHOOK: query: EXPLAIN INSERT INTO TABLE insert_into2 PARTITION (ds='1') 
-  SELECT * FROM src LIMIT 100
+  SELECT * FROM src order by key LIMIT 100
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -34,18 +34,16 @@ STAGE PLANS:
               expressions: key (type: string), value (type: string)
               outputColumnNames: _col0, _col1
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Limit
-                Number of rows: 100
-                Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
-                  Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string), _col1 (type: string)
+              Reduce Output Operator
+                key expressions: _col0 (type: string)
+                sort order: +
+                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col1 (type: string)
       Reduce Operator Tree:
         Select Operator
-          expressions: VALUE._col0 (type: string), VALUE._col1 (type: string)
+          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 100
             Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
@@ -77,11 +75,11 @@ STAGE PLANS:
   Stage: Stage-2
     Stats-Aggr Operator
 
-PREHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src limit 100
+PREHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src order by key limit 100
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: default@insert_into2@ds=1
-POSTHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src limit 100
+POSTHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src order by key limit 100
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: default@insert_into2@ds=1
@@ -112,11 +110,11 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@insert_into2
 #### A masked pattern was here ####
 100
-PREHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src limit 100
+PREHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src order by key limit 100
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: default@insert_into2@ds=1
-POSTHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src limit 100
+POSTHOOK: query: INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src order by key limit 100
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: default@insert_into2@ds=1
@@ -161,12 +159,12 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@insert_into2
 POSTHOOK: Input: default@insert_into2@ds=1
 #### A masked pattern was here ####
--24159954504
+-39568181484
 PREHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 100
+  SELECT * FROM src order by key LIMIT 100
 PREHOOK: type: QUERY
 POSTHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 100
+  SELECT * FROM src order by key LIMIT 100
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -184,18 +182,16 @@ STAGE PLANS:
               expressions: key (type: string), value (type: string)
               outputColumnNames: _col0, _col1
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Limit
-                Number of rows: 100
-                Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
-                  Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string), _col1 (type: string)
+              Reduce Output Operator
+                key expressions: _col0 (type: string)
+                sort order: +
+                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col1 (type: string)
       Reduce Operator Tree:
         Select Operator
-          expressions: VALUE._col0 (type: string), VALUE._col1 (type: string)
+          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 100
             Statistics: Num rows: 100 Data size: 1000 Basic stats: COMPLETE Column stats: NONE
@@ -228,12 +224,12 @@ STAGE PLANS:
     Stats-Aggr Operator
 
 PREHOOK: query: INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 100
+  SELECT * FROM src order by key LIMIT 100
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: default@insert_into2@ds=2
 POSTHOOK: query: INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 100
+  SELECT * FROM src order by key LIMIT 100
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: default@insert_into2@ds=2
@@ -255,7 +251,7 @@ POSTHOOK: Input: default@insert_into2
 POSTHOOK: Input: default@insert_into2@ds=1
 POSTHOOK: Input: default@insert_into2@ds=2
 #### A masked pattern was here ####
--36239931656
+-59352272126
 PREHOOK: query: explain
 SELECT COUNT(*) FROM insert_into2 WHERE ds='2'
 PREHOOK: type: QUERY
@@ -282,10 +278,10 @@ POSTHOOK: Input: default@insert_into2
 #### A masked pattern was here ####
 100
 PREHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 50
+  SELECT * FROM src order by key LIMIT 50
 PREHOOK: type: QUERY
 POSTHOOK: query: EXPLAIN INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 50
+  SELECT * FROM src order by key LIMIT 50
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -303,18 +299,16 @@ STAGE PLANS:
               expressions: key (type: string), value (type: string)
               outputColumnNames: _col0, _col1
               Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
-              Limit
-                Number of rows: 50
-                Statistics: Num rows: 50 Data size: 500 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  sort order: 
-                  Statistics: Num rows: 50 Data size: 500 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col0 (type: string), _col1 (type: string)
+              Reduce Output Operator
+                key expressions: _col0 (type: string)
+                sort order: +
+                Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
+                value expressions: _col1 (type: string)
       Reduce Operator Tree:
         Select Operator
-          expressions: VALUE._col0 (type: string), VALUE._col1 (type: string)
+          expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
           outputColumnNames: _col0, _col1
-          Statistics: Num rows: 50 Data size: 500 Basic stats: COMPLETE Column stats: NONE
+          Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE Column stats: NONE
           Limit
             Number of rows: 50
             Statistics: Num rows: 50 Data size: 500 Basic stats: COMPLETE Column stats: NONE
@@ -347,12 +341,12 @@ STAGE PLANS:
     Stats-Aggr Operator
 
 PREHOOK: query: INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 50
+  SELECT * FROM src order by key LIMIT 50
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: default@insert_into2@ds=2
 POSTHOOK: query: INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 50
+  SELECT * FROM src order by key LIMIT 50
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: default@insert_into2@ds=2
@@ -374,7 +368,7 @@ POSTHOOK: Input: default@insert_into2
 POSTHOOK: Input: default@insert_into2@ds=1
 POSTHOOK: Input: default@insert_into2@ds=2
 #### A masked pattern was here ####
--27100860056
+-33609711132
 PREHOOK: query: explain
 SELECT COUNT(*) FROM insert_into2 WHERE ds='2'
 PREHOOK: type: QUERY

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/insert_nonacid_from_acid.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/insert_nonacid_from_acid.q.out b/ql/src/test/results/clientpositive/insert_nonacid_from_acid.q.out
index 8d36ae4..1f613c4 100644
--- a/ql/src/test/results/clientpositive/insert_nonacid_from_acid.q.out
+++ b/ql/src/test/results/clientpositive/insert_nonacid_from_acid.q.out
@@ -1,9 +1,13 @@
-PREHOOK: query: -- This test checks that selecting from an acid table and inserting into a non-acid table works.
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+-- This test checks that selecting from an acid table and inserting into a non-acid table works.
 create table sample_06(name varchar(50), age int, gpa decimal(3, 2)) clustered by (age) into 2 buckets stored as orc TBLPROPERTIES ("transactional"="true")
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@sample_06
-POSTHOOK: query: -- This test checks that selecting from an acid table and inserting into a non-acid table works.
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+-- This test checks that selecting from an acid table and inserting into a non-acid table works.
 create table sample_06(name varchar(50), age int, gpa decimal(3, 2)) clustered by (age) into 2 buckets stored as orc TBLPROPERTIES ("transactional"="true")
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
@@ -27,11 +31,11 @@ POSTHOOK: query: select * from sample_06 where gpa = 3.00
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@sample_06
 #### A masked pattern was here ####
-eee	32	3
-ccc	32	3
+aaa	35	3
 bbb	32	3
+ccc	32	3
 ddd	35	3
-aaa	35	3
+eee	32	3
 PREHOOK: query: create table tab1 (name varchar(50), age int, gpa decimal(3, 2))
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
@@ -59,8 +63,8 @@ POSTHOOK: query: select * from tab1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@tab1
 #### A masked pattern was here ####
-eee	32	3
-ccc	32	3
+aaa	35	3
 bbb	32	3
+ccc	32	3
 ddd	35	3
-aaa	35	3
+eee	32	3

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/join_merge_multi_expressions.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/join_merge_multi_expressions.q.out b/ql/src/test/results/clientpositive/join_merge_multi_expressions.q.out
index 0bd2a16..b73643e 100644
--- a/ql/src/test/results/clientpositive/join_merge_multi_expressions.q.out
+++ b/ql/src/test/results/clientpositive/join_merge_multi_expressions.q.out
@@ -1,7 +1,9 @@
-PREHOOK: query: explain
+PREHOOK: query: -- SORT_QUERY_RESULTS
+explain
 select count(*) from srcpart a join srcpart b on a.key = b.key and a.hr = b.hr join srcpart c on a.hr = c.hr and a.key = c.key
 PREHOOK: type: QUERY
-POSTHOOK: query: explain
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+explain
 select count(*) from srcpart a join srcpart b on a.key = b.key and a.hr = b.hr join srcpart c on a.hr = c.hr and a.key = c.key
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/join_nullsafe.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/join_nullsafe.q.out b/ql/src/test/results/clientpositive/join_nullsafe.q.out
index 27ceae5..b6557a2 100644
--- a/ql/src/test/results/clientpositive/join_nullsafe.q.out
+++ b/ql/src/test/results/clientpositive/join_nullsafe.q.out
@@ -78,11 +78,13 @@ STAGE PLANS:
       Processor Tree:
         ListSink
 
-PREHOOK: query: select * from myinput1 a join myinput1 b on a.key<=>b.value
+PREHOOK: query: -- SORT_QUERY_RESULTS
+select * from myinput1 a join myinput1 b on a.key<=>b.value
 PREHOOK: type: QUERY
 PREHOOK: Input: default@myinput1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from myinput1 a join myinput1 b on a.key<=>b.value
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+select * from myinput1 a join myinput1 b on a.key<=>b.value
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@myinput1
 #### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/orc_merge1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/orc_merge1.q.out b/ql/src/test/results/clientpositive/orc_merge1.q.out
index 2927791..3f047da 100644
--- a/ql/src/test/results/clientpositive/orc_merge1.q.out
+++ b/ql/src/test/results/clientpositive/orc_merge1.q.out
@@ -1,6 +1,10 @@
-PREHOOK: query: DROP TABLE orcfile_merge1
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+DROP TABLE orcfile_merge1
 PREHOOK: type: DROPTABLE
-POSTHOOK: query: DROP TABLE orcfile_merge1
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+DROP TABLE orcfile_merge1
 POSTHOOK: type: DROPTABLE
 PREHOOK: query: DROP TABLE orcfile_merge1b
 PREHOOK: type: DROPTABLE

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/partition_date2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/partition_date2.q.out b/ql/src/test/results/clientpositive/partition_date2.q.out
index bf3a59d..3bd1f49 100644
--- a/ql/src/test/results/clientpositive/partition_date2.q.out
+++ b/ql/src/test/results/clientpositive/partition_date2.q.out
@@ -1,6 +1,10 @@
-PREHOOK: query: drop table partition_date2_1
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+drop table partition_date2_1
 PREHOOK: type: DROPTABLE
-POSTHOOK: query: drop table partition_date2_1
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+drop table partition_date2_1
 POSTHOOK: type: DROPTABLE
 PREHOOK: query: create table partition_date2_1 (key string, value string) partitioned by (dt date, region int)
 PREHOOK: type: CREATETABLE

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/script_env_var1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/script_env_var1.q.out b/ql/src/test/results/clientpositive/script_env_var1.q.out
index 5ab1c20..cd39eb8 100644
--- a/ql/src/test/results/clientpositive/script_env_var1.q.out
+++ b/ql/src/test/results/clientpositive/script_env_var1.q.out
@@ -1,16 +1,16 @@
 PREHOOK: query: -- Verifies that script operator ID environment variables have unique values
 -- in each instance of the script operator.
 SELECT count(1) FROM
-( SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1)x UNION ALL
-  SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1)y ) a GROUP BY key
+( SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src order by key LIMIT 1)x UNION ALL
+  SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src order by key LIMIT 1)y ) a GROUP BY key
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 #### A masked pattern was here ####
 POSTHOOK: query: -- Verifies that script operator ID environment variables have unique values
 -- in each instance of the script operator.
 SELECT count(1) FROM
-( SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1)x UNION ALL
-  SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src LIMIT 1)y ) a GROUP BY key
+( SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src order by key LIMIT 1)x UNION ALL
+  SELECT * FROM (SELECT TRANSFORM('echo $HIVE_SCRIPT_OPERATOR_ID') USING 'sh' AS key FROM src order by key LIMIT 1)y ) a GROUP BY key
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/selectDistinctStar.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/selectDistinctStar.q.out b/ql/src/test/results/clientpositive/selectDistinctStar.q.out
index 4c8564e..8867b8d 100644
--- a/ql/src/test/results/clientpositive/selectDistinctStar.q.out
+++ b/ql/src/test/results/clientpositive/selectDistinctStar.q.out
@@ -1,6 +1,10 @@
-PREHOOK: query: explain select distinct src.* from src
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+explain select distinct src.* from src
 PREHOOK: type: QUERY
-POSTHOOK: query: explain select distinct src.* from src
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+explain select distinct src.* from src
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -1399,6 +1403,13 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Input: default@src1
 #### A masked pattern was here ####
+	
+	val_165
+	val_193
+	val_265
+	val_27
+	val_409
+	val_484
 0	val_0
 10	val_10
 100	val_100
@@ -1416,6 +1427,7 @@ POSTHOOK: Input: default@src1
 120	val_120
 125	val_125
 126	val_126
+128	
 128	val_128
 129	val_129
 131	val_131
@@ -1427,9 +1439,11 @@ POSTHOOK: Input: default@src1
 143	val_143
 145	val_145
 146	val_146
+146	val_146
 149	val_149
 15	val_15
 150	val_150
+150	val_150
 152	val_152
 153	val_153
 155	val_155
@@ -1482,6 +1496,7 @@ POSTHOOK: Input: default@src1
 208	val_208
 209	val_209
 213	val_213
+213	val_213
 214	val_214
 216	val_216
 217	val_217
@@ -1490,6 +1505,7 @@ POSTHOOK: Input: default@src1
 221	val_221
 222	val_222
 223	val_223
+224	
 224	val_224
 226	val_226
 228	val_228
@@ -1499,6 +1515,7 @@ POSTHOOK: Input: default@src1
 235	val_235
 237	val_237
 238	val_238
+238	val_238
 239	val_239
 24	val_24
 241	val_241
@@ -1509,6 +1526,7 @@ POSTHOOK: Input: default@src1
 249	val_249
 252	val_252
 255	val_255
+255	val_255
 256	val_256
 257	val_257
 258	val_258
@@ -1521,10 +1539,12 @@ POSTHOOK: Input: default@src1
 27	val_27
 272	val_272
 273	val_273
+273	val_273
 274	val_274
 275	val_275
 277	val_277
 278	val_278
+278	val_278
 28	val_28
 280	val_280
 281	val_281
@@ -1549,6 +1569,7 @@ POSTHOOK: Input: default@src1
 309	val_309
 310	val_310
 311	val_311
+311	val_311
 315	val_315
 316	val_316
 317	val_317
@@ -1583,6 +1604,7 @@ POSTHOOK: Input: default@src1
 366	val_366
 367	val_367
 368	val_368
+369	
 369	val_369
 37	val_37
 373	val_373
@@ -1605,10 +1627,12 @@ POSTHOOK: Input: default@src1
 4	val_4
 400	val_400
 401	val_401
+401	val_401
 402	val_402
 403	val_403
 404	val_404
 406	val_406
+406	val_406
 407	val_407
 409	val_409
 41	val_41
@@ -1685,6 +1709,7 @@ POSTHOOK: Input: default@src1
 64	val_64
 65	val_65
 66	val_66
+66	val_66
 67	val_67
 69	val_69
 70	val_70
@@ -1708,27 +1733,6 @@ POSTHOOK: Input: default@src1
 96	val_96
 97	val_97
 98	val_98
-	
-	val_165
-	val_193
-	val_265
-	val_27
-	val_409
-	val_484
-128	
-146	val_146
-150	val_150
-213	val_213
-224	
-238	val_238
-255	val_255
-273	val_273
-278	val_278
-311	val_311
-369	
-401	val_401
-406	val_406
-66	val_66
 98	val_98
 PREHOOK: query: select distinct * from src join src1 on src.key=src1.key
 PREHOOK: type: QUERY
@@ -3830,6 +3834,13 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Input: default@src1
 #### A masked pattern was here ####
+	
+	val_165
+	val_193
+	val_265
+	val_27
+	val_409
+	val_484
 0	val_0
 10	val_10
 100	val_100
@@ -3847,6 +3858,7 @@ POSTHOOK: Input: default@src1
 120	val_120
 125	val_125
 126	val_126
+128	
 128	val_128
 129	val_129
 131	val_131
@@ -3858,9 +3870,11 @@ POSTHOOK: Input: default@src1
 143	val_143
 145	val_145
 146	val_146
+146	val_146
 149	val_149
 15	val_15
 150	val_150
+150	val_150
 152	val_152
 153	val_153
 155	val_155
@@ -3913,6 +3927,7 @@ POSTHOOK: Input: default@src1
 208	val_208
 209	val_209
 213	val_213
+213	val_213
 214	val_214
 216	val_216
 217	val_217
@@ -3921,6 +3936,7 @@ POSTHOOK: Input: default@src1
 221	val_221
 222	val_222
 223	val_223
+224	
 224	val_224
 226	val_226
 228	val_228
@@ -3930,6 +3946,7 @@ POSTHOOK: Input: default@src1
 235	val_235
 237	val_237
 238	val_238
+238	val_238
 239	val_239
 24	val_24
 241	val_241
@@ -3940,6 +3957,7 @@ POSTHOOK: Input: default@src1
 249	val_249
 252	val_252
 255	val_255
+255	val_255
 256	val_256
 257	val_257
 258	val_258
@@ -3952,10 +3970,12 @@ POSTHOOK: Input: default@src1
 27	val_27
 272	val_272
 273	val_273
+273	val_273
 274	val_274
 275	val_275
 277	val_277
 278	val_278
+278	val_278
 28	val_28
 280	val_280
 281	val_281
@@ -3980,6 +4000,7 @@ POSTHOOK: Input: default@src1
 309	val_309
 310	val_310
 311	val_311
+311	val_311
 315	val_315
 316	val_316
 317	val_317
@@ -4014,6 +4035,7 @@ POSTHOOK: Input: default@src1
 366	val_366
 367	val_367
 368	val_368
+369	
 369	val_369
 37	val_37
 373	val_373
@@ -4036,10 +4058,12 @@ POSTHOOK: Input: default@src1
 4	val_4
 400	val_400
 401	val_401
+401	val_401
 402	val_402
 403	val_403
 404	val_404
 406	val_406
+406	val_406
 407	val_407
 409	val_409
 41	val_41
@@ -4116,6 +4140,7 @@ POSTHOOK: Input: default@src1
 64	val_64
 65	val_65
 66	val_66
+66	val_66
 67	val_67
 69	val_69
 70	val_70
@@ -4139,27 +4164,6 @@ POSTHOOK: Input: default@src1
 96	val_96
 97	val_97
 98	val_98
-	
-	val_165
-	val_193
-	val_265
-	val_27
-	val_409
-	val_484
-128	
-146	val_146
-150	val_150
-213	val_213
-224	
-238	val_238
-255	val_255
-273	val_273
-278	val_278
-311	val_311
-369	
-401	val_401
-406	val_406
-66	val_66
 98	val_98
 PREHOOK: query: select distinct * from src join src1 on src.key=src1.key
 PREHOOK: type: QUERY

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/skewjoin.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/skewjoin.q.out b/ql/src/test/results/clientpositive/skewjoin.q.out
index c6f76af..1b56d5f 100644
--- a/ql/src/test/results/clientpositive/skewjoin.q.out
+++ b/ql/src/test/results/clientpositive/skewjoin.q.out
@@ -1,8 +1,12 @@
-PREHOOK: query: CREATE TABLE T1(key STRING, val STRING) STORED AS TEXTFILE
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+CREATE TABLE T1(key STRING, val STRING) STORED AS TEXTFILE
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@T1
-POSTHOOK: query: CREATE TABLE T1(key STRING, val STRING) STORED AS TEXTFILE
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+CREATE TABLE T1(key STRING, val STRING) STORED AS TEXTFILE
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@T1

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/spark/auto_join0.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/auto_join0.q.out b/ql/src/test/results/clientpositive/spark/auto_join0.q.out
index c3979f4..d4a2301 100644
--- a/ql/src/test/results/clientpositive/spark/auto_join0.q.out
+++ b/ql/src/test/results/clientpositive/spark/auto_join0.q.out
@@ -1,23 +1,27 @@
-Warning: Map Join MAPJOIN[20][bigTable=?] in task 'Stage-1:MAPRED' is a cross product
-PREHOOK: query: explain 
+Warning: Map Join MAPJOIN[24][bigTable=?] in task 'Stage-1:MAPRED' is a cross product
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+explain 
 select sum(hash(a.k1,a.v1,a.k2, a.v2))
 from (
 SELECT src1.key as k1, src1.value as v1, 
        src2.key as k2, src2.value as v2 FROM 
-  (SELECT * FROM src WHERE src.key < 10) src1 
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src1
     JOIN 
-  (SELECT * FROM src WHERE src.key < 10) src2
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src2
   SORT BY k1, v1, k2, v2
 ) a
 PREHOOK: type: QUERY
-POSTHOOK: query: explain 
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+explain 
 select sum(hash(a.k1,a.v1,a.k2, a.v2))
 from (
 SELECT src1.key as k1, src1.value as v1, 
        src2.key as k2, src2.value as v2 FROM 
-  (SELECT * FROM src WHERE src.key < 10) src1 
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src1
     JOIN 
-  (SELECT * FROM src WHERE src.key < 10) src2
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src2
   SORT BY k1, v1, k2, v2
 ) a
 POSTHOOK: type: QUERY
@@ -29,9 +33,11 @@ STAGE DEPENDENCIES:
 STAGE PLANS:
   Stage: Stage-2
     Spark
+      Edges:
+        Reducer 6 <- Map 5 (SORT, 1)
 #### A masked pattern was here ####
       Vertices:
-        Map 4 
+        Map 5 
             Map Operator Tree:
                 TableScan
                   alias: src
@@ -43,18 +49,29 @@ STAGE PLANS:
                       expressions: key (type: string), value (type: string)
                       outputColumnNames: _col0, _col1
                       Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
-                      Spark HashTable Sink Operator
-                        keys:
-                          0 
-                          1 
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string), _col1 (type: string)
+                        sort order: ++
+                        Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
+        Reducer 6 
             Local Work:
               Map Reduce Local Work
+            Reduce Operator Tree:
+              Select Operator
+                expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: string)
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
+                Spark HashTable Sink Operator
+                  keys:
+                    0 
+                    1 
 
   Stage: Stage-1
     Spark
       Edges:
-        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 2)
-        Reducer 3 <- Reducer 2 (GROUP, 1)
+        Reducer 2 <- Map 1 (SORT, 1)
+        Reducer 3 <- Reducer 2 (PARTITION-LEVEL SORT, 2)
+        Reducer 4 <- Reducer 3 (GROUP, 1)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -69,23 +86,33 @@ STAGE PLANS:
                       expressions: key (type: string), value (type: string)
                       outputColumnNames: _col0, _col1
                       Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
-                      Map Join Operator
-                        condition map:
-                             Inner Join 0 to 1
-                        keys:
-                          0 
-                          1 
-                        outputColumnNames: _col0, _col1, _col2, _col3
-                        input vertices:
-                          1 Map 4
-                        Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE Column stats: NONE
-                        Reduce Output Operator
-                          key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string)
-                          sort order: ++++
-                          Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE Column stats: NONE
+                      Reduce Output Operator
+                        key expressions: _col0 (type: string), _col1 (type: string)
+                        sort order: ++
+                        Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
+        Reducer 2 
             Local Work:
               Map Reduce Local Work
-        Reducer 2 
+            Reduce Operator Tree:
+              Select Operator
+                expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: string)
+                outputColumnNames: _col0, _col1
+                Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE Column stats: NONE
+                Map Join Operator
+                  condition map:
+                       Inner Join 0 to 1
+                  keys:
+                    0 
+                    1 
+                  outputColumnNames: _col0, _col1, _col2, _col3
+                  input vertices:
+                    1 Reducer 6
+                  Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE Column stats: NONE
+                  Reduce Output Operator
+                    key expressions: _col0 (type: string), _col1 (type: string), _col2 (type: string), _col3 (type: string)
+                    sort order: ++++
+                    Statistics: Num rows: 182 Data size: 1939 Basic stats: COMPLETE Column stats: NONE
+        Reducer 3 
             Reduce Operator Tree:
               Select Operator
                 expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 (type: string), KEY.reducesinkkey2 (type: string), KEY.reducesinkkey3 (type: string)
@@ -100,7 +127,7 @@ STAGE PLANS:
                     sort order: 
                     Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
                     value expressions: _col0 (type: bigint)
-        Reducer 3 
+        Reducer 4 
             Reduce Operator Tree:
               Group By Operator
                 aggregations: sum(VALUE._col0)
@@ -121,14 +148,14 @@ STAGE PLANS:
       Processor Tree:
         ListSink
 
-Warning: Map Join MAPJOIN[20][bigTable=?] in task 'Stage-1:MAPRED' is a cross product
+Warning: Map Join MAPJOIN[24][bigTable=?] in task 'Stage-1:MAPRED' is a cross product
 PREHOOK: query: select sum(hash(a.k1,a.v1,a.k2, a.v2))
 from (
 SELECT src1.key as k1, src1.value as v1, 
        src2.key as k2, src2.value as v2 FROM 
-  (SELECT * FROM src WHERE src.key < 10) src1 
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src1
     JOIN 
-  (SELECT * FROM src WHERE src.key < 10) src2
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src2
   SORT BY k1, v1, k2, v2
 ) a
 PREHOOK: type: QUERY
@@ -138,9 +165,9 @@ POSTHOOK: query: select sum(hash(a.k1,a.v1,a.k2, a.v2))
 from (
 SELECT src1.key as k1, src1.value as v1, 
        src2.key as k2, src2.value as v2 FROM 
-  (SELECT * FROM src WHERE src.key < 10) src1 
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src1
     JOIN 
-  (SELECT * FROM src WHERE src.key < 10) src2
+  (SELECT * FROM src WHERE src.key < 10 order by src.key, src.value) src2
   SORT BY k1, v1, k2, v2
 ) a
 POSTHOOK: type: QUERY

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/spark/auto_join1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/auto_join1.q.out b/ql/src/test/results/clientpositive/spark/auto_join1.q.out
index b640b9d..d9215f8 100644
--- a/ql/src/test/results/clientpositive/spark/auto_join1.q.out
+++ b/ql/src/test/results/clientpositive/spark/auto_join1.q.out
@@ -1,8 +1,12 @@
-PREHOOK: query: CREATE TABLE dest_j1(key INT, value STRING) STORED AS TEXTFILE
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+CREATE TABLE dest_j1(key INT, value STRING) STORED AS TEXTFILE
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@dest_j1
-POSTHOOK: query: CREATE TABLE dest_j1(key INT, value STRING) STORED AS TEXTFILE
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+CREATE TABLE dest_j1(key INT, value STRING) STORED AS TEXTFILE
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@dest_j1

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/spark/auto_sortmerge_join_5.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/auto_sortmerge_join_5.q.out b/ql/src/test/results/clientpositive/spark/auto_sortmerge_join_5.q.out
index 3eceb0b..e3a5710 100644
--- a/ql/src/test/results/clientpositive/spark/auto_sortmerge_join_5.q.out
+++ b/ql/src/test/results/clientpositive/spark/auto_sortmerge_join_5.q.out
@@ -1,9 +1,15 @@
 PREHOOK: query: -- small no part, 4 bucket & big no part, 2 bucket
+
+-- SORT_QUERY_RESULTS
+
 CREATE TABLE bucket_small (key string, value string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@bucket_small
 POSTHOOK: query: -- small no part, 4 bucket & big no part, 2 bucket
+
+-- SORT_QUERY_RESULTS
+
 CREATE TABLE bucket_small (key string, value string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/spark/cbo_gby.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/cbo_gby.q.out b/ql/src/test/results/clientpositive/spark/cbo_gby.q.out
index 9ca8a88..04597a7 100644
--- a/ql/src/test/results/clientpositive/spark/cbo_gby.q.out
+++ b/ql/src/test/results/clientpositive/spark/cbo_gby.q.out
@@ -1,20 +1,24 @@
-PREHOOK: query: -- 6. Test Select + TS + Join + Fil + GB + GB Having
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+-- 6. Test Select + TS + Join + Fil + GB + GB Having
 select key, (c_int+1)+2 as x, sum(c_int) from cbo_t1 group by c_float, cbo_t1.c_int, key
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-POSTHOOK: query: -- 6. Test Select + TS + Join + Fil + GB + GB Having
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+-- 6. Test Select + TS + Join + Fil + GB + GB Having
 select key, (c_int+1)+2 as x, sum(c_int) from cbo_t1 group by c_float, cbo_t1.c_int, key
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-1	4	12
- 1 	4	2
-NULL	NULL	NULL
  1	4	2
+ 1 	4	2
+1	4	12
 1 	4	2
+NULL	NULL	NULL
 PREHOOK: query: select x, y, count(*) from (select key, (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key) R group by y, x
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -25,9 +29,9 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
+5.0	12	1
 5.0	2	3
 NULL	NULL	1
-5.0	12	1
 PREHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0) group by c_float, cbo_t1.c_int, key order by a) cbo_t1 join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key order by q/10 desc, r asc) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c order by cbo_t3.c_int+c desc, c
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -62,8 +66,8 @@ POSTHOOK: Input: default@cbo_t2
 POSTHOOK: Input: default@cbo_t2@dt=2014
 POSTHOOK: Input: default@cbo_t3
 #### A masked pattern was here ####
-1	2	6
 1	12	6
+1	2	6
 PREHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by b+c, a desc) cbo_t1 right outer join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0) cbo_t2 on cbo_t1.a=p right outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 2) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -80,8 +84,8 @@ POSTHOOK: Input: default@cbo_t2
 POSTHOOK: Input: default@cbo_t2@dt=2014
 POSTHOOK: Input: default@cbo_t3
 #### A masked pattern was here ####
-1	2	6
 1	12	6
+1	2	6
 PREHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by c+a desc) cbo_t1 full outer join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by p+q desc, r asc) cbo_t2 on cbo_t1.a=p full outer join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c having cbo_t3.c_int > 0 and (c_int >=1 or c >= 1) and (c_int + c) >= 0 order by cbo_t3.c_int
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -98,8 +102,8 @@ POSTHOOK: Input: default@cbo_t2
 POSTHOOK: Input: default@cbo_t2@dt=2014
 POSTHOOK: Input: default@cbo_t3
 #### A masked pattern was here ####
-1	2	6
 1	12	6
+1	2	6
 PREHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0) cbo_t1 join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key having cbo_t2.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1.a=key where (b + cbo_t2.q >= 0) and (b > 0 or c_int >= 0) group by cbo_t3.c_int, c
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -116,5 +120,5 @@ POSTHOOK: Input: default@cbo_t2
 POSTHOOK: Input: default@cbo_t2@dt=2014
 POSTHOOK: Input: default@cbo_t3
 #### A masked pattern was here ####
-1	2	6
 1	12	6
+1	2	6

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/spark/cbo_udf_udaf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/cbo_udf_udaf.q.out b/ql/src/test/results/clientpositive/spark/cbo_udf_udaf.q.out
index ded043f..156d02f 100644
--- a/ql/src/test/results/clientpositive/spark/cbo_udf_udaf.q.out
+++ b/ql/src/test/results/clientpositive/spark/cbo_udf_udaf.q.out
@@ -1,10 +1,14 @@
-PREHOOK: query: -- 8. Test UDF/UDAF
+PREHOOK: query: -- SORT_QUERY_RESULTS
+
+-- 8. Test UDF/UDAF
 select count(*), count(c_int), sum(c_int), avg(c_int), max(c_int), min(c_int) from cbo_t1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-POSTHOOK: query: -- 8. Test UDF/UDAF
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+
+-- 8. Test UDF/UDAF
 select count(*), count(c_int), sum(c_int), avg(c_int), max(c_int), min(c_int) from cbo_t1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
@@ -21,8 +25,8 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-2	0	NULL	NULL	NULL	NULL	3	6
 18	18	18	1.0	1	1	2	36
+2	0	NULL	NULL	NULL	NULL	3	6
 PREHOOK: query: select * from (select count(*) as a, count(distinct c_int) as b, sum(c_int) as c, avg(c_int) as d, max(c_int) as e, min(c_int) as f from cbo_t1) cbo_t1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -44,8 +48,8 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-2	0	NULL	NULL	NULL	NULL	3	6
 18	1	18	1.0	1	1	2	36
+2	0	NULL	NULL	NULL	NULL	3	6
 PREHOOK: query: select f,a,e,b from (select count(*) as a, count(c_int) as b, sum(c_int) as c, avg(c_int) as d, max(c_int) as e, min(c_int) as f from cbo_t1) cbo_t1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
@@ -78,11 +82,11 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-NULL	0	NULL
-1 	2	1.0
- 1 	2	1.0
  1	2	1.0
+ 1 	2	1.0
 1	12	1.0
+1 	2	1.0
+NULL	0	NULL
 PREHOOK: query: select count(distinct c_int) as a, avg(c_float) from cbo_t1 group by c_float order by a
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1


Mime
View raw message