HIVE-10563 : MiniTezCliDriver tests ordering issues (Hari Subramaniyan via 
Sushanth Sowmyan) (branch-1.2 patch)


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

Branch: refs/heads/branch-1.2
Commit: 6fdd9cdd16d05a53dc1d796fa28539dcbd15e3ae
Parents: 03be35e
Author: Sushanth Sowmyan <khorg...@gmail.com>
Authored: Fri May 29 15:13:10 2015 -0700
Committer: Sushanth Sowmyan <khorg...@gmail.com>
Committed: Fri May 29 15:42:27 2015 -0700

----------------------------------------------------------------------
 .../queries/clientpositive/alter_merge_2_orc.q  |    6 +-
 ql/src/test/queries/clientpositive/auto_join0.q |   11 +-
 ql/src/test/queries/clientpositive/auto_join1.q |    2 +
 .../clientpositive/auto_sortmerge_join_5.q      |    3 +
 ql/src/test/queries/clientpositive/cbo_gby.q    |    3 +
 .../test/queries/clientpositive/cbo_udf_udaf.q  |    2 +
 .../test/queries/clientpositive/cbo_windowing.q |    2 +
 .../clientpositive/cross_product_check_1.q      |    9 +-
 .../clientpositive/cross_product_check_2.q      |    6 +-
 ql/src/test/queries/clientpositive/ctas.q       |    1 +
 .../clientpositive/dynpart_sort_optimization2.q |    7 +-
 .../test/queries/clientpositive/explainuser_2.q |    7 +-
 .../clientpositive/filter_join_breaktask2.q     |    2 +
 .../test/queries/clientpositive/insert_into1.q  |   15 +-
 .../test/queries/clientpositive/insert_into2.q  |   14 +-
 .../clientpositive/insert_nonacid_from_acid.q   |    2 +
 .../join_merge_multi_expressions.q              |    1 +
 .../test/queries/clientpositive/join_nullsafe.q |    2 +
 .../queries/clientpositive/mapjoin_decimal.q    |    6 +-
 ql/src/test/queries/clientpositive/mrr.q        |    2 +
 ql/src/test/queries/clientpositive/orc_merge1.q |    2 +
 .../queries/clientpositive/partition_date2.q    |    2 +
 .../queries/clientpositive/script_env_var1.q    |    4 +-
 .../queries/clientpositive/selectDistinctStar.q |    2 +
 ql/src/test/queries/clientpositive/skewjoin.q   |   11 +-
 .../queries/clientpositive/subquery_exists.q    |    1 +
 ql/src/test/queries/clientpositive/temp_table.q |    6 +-
 ql/src/test/queries/clientpositive/tez_dml.q    |    2 +
 .../test/queries/clientpositive/tez_join_hash.q |    2 +
 .../queries/clientpositive/tez_joins_explain.q  |    1 -
 .../queries/clientpositive/tez_multi_union.q    |    1 +
 .../clientpositive/tez_schema_evolution.q       |   12 +-
 .../clientpositive/update_all_partitioned.q     |    4 +-
 .../clientpositive/update_where_partitioned.q   |    4 +-
 .../queries/clientpositive/vector_data_types.q  |   12 +-
 .../clientpositive/vector_null_projection.q     |    2 +
 .../queries/clientpositive/vector_outer_join1.q |    8 +-
 .../queries/clientpositive/vector_outer_join2.q |    8 +-
 .../queries/clientpositive/vector_outer_join3.q |    8 +-
 .../clientpositive/vectorization_part_project.q |    4 +-
 .../clientpositive/vectorized_distinct_gby.q    |    2 +-
 .../queries/clientpositive/vectorized_mapjoin.q |    2 +
 .../clientpositive/vectorized_nested_mapjoin.q  |    2 +
 .../clientpositive/vectorized_rcfile_columnar.q |    2 +-
 .../clientpositive/vectorized_shufflejoin.q     |   10 +-
 .../clientpositive/vectorized_timestamp_funcs.q |    5 +-
 .../clientpositive/alter_merge_2_orc.q.out      |   16 +-
 .../results/clientpositive/auto_join0.q.out     |  235 +-
 .../results/clientpositive/auto_join1.q.out     |    8 +-
 .../clientpositive/auto_sortmerge_join_5.q.out  |    6 +
 .../test/results/clientpositive/cbo_gby.q.out   |   18 +-
 .../results/clientpositive/cbo_udf_udaf.q.out   |   18 +-
 .../results/clientpositive/cbo_windowing.q.out  |   66 +-
 .../clientpositive/cross_product_check_1.q.out  |   20 +-
 .../clientpositive/cross_product_check_2.q.out  |   72 +-
 ql/src/test/results/clientpositive/ctas.q.out   |    2 +
 .../dynpart_sort_optimization2.q.out            |  166 +-
 .../clientpositive/filter_join_breaktask2.q.out |    8 +-
 .../results/clientpositive/insert_into1.q.out   |   86 +-
 .../results/clientpositive/insert_into2.q.out   |   82 +-
 .../insert_nonacid_from_acid.q.out              |   20 +-
 .../join_merge_multi_expressions.q.out          |    6 +-
 .../results/clientpositive/join_nullsafe.q.out  |    6 +-
 .../results/clientpositive/orc_merge1.q.out     |    8 +-
 .../clientpositive/partition_date2.q.out        |    8 +-
 .../clientpositive/script_env_var1.q.out        |    8 +-
 .../clientpositive/selectDistinctStar.q.out     |   92 +-
 .../test/results/clientpositive/skewjoin.q.out  |    8 +-
 .../clientpositive/spark/auto_join0.q.out       |   97 +-
 .../clientpositive/spark/auto_join1.q.out       |    8 +-
 .../spark/auto_sortmerge_join_5.q.out           |    6 +
 .../results/clientpositive/spark/cbo_gby.q.out  |   24 +-
 .../clientpositive/spark/cbo_udf_udaf.q.out     |   18 +-
 .../spark/cross_product_check_1.q.out           |   20 +-
 .../spark/cross_product_check_2.q.out           |   68 +-
 .../results/clientpositive/spark/ctas.q.out     |    2 +
 .../spark/filter_join_breaktask2.q.out          |    8 +-
 .../clientpositive/spark/insert_into1.q.out     |   92 +-
 .../clientpositive/spark/insert_into2.q.out     |   88 +-
 .../spark/join_merge_multi_expressions.q.out    |    6 +-
 .../clientpositive/spark/join_nullsafe.q.out    |    6 +-
 .../clientpositive/spark/mapjoin_decimal.q.out  |   41 +-
 .../clientpositive/spark/script_env_var1.q.out  |    8 +-
 .../results/clientpositive/spark/skewjoin.q.out |    8 +-
 .../clientpositive/spark/subquery_exists.q.out  |    2 +
 .../clientpositive/spark/temp_table.q.out       |   84 +-
 .../spark/tez_joins_explain.q.out               |    2 -
 .../spark/vector_data_types.q.out               |  116 +-
 .../spark/vectorization_part_project.q.out      |   40 +-
 .../spark/vectorized_mapjoin.q.out              |    8 +-
 .../spark/vectorized_nested_mapjoin.q.out       |    8 +-
 .../spark/vectorized_rcfile_columnar.q.out      |   24 +-
 .../spark/vectorized_shufflejoin.q.out          |   37 +-
 .../spark/vectorized_timestamp_funcs.q.out      |  292 +--
 .../clientpositive/subquery_exists.q.out        |    2 +
 .../results/clientpositive/temp_table.q.out     |   78 +-
 .../clientpositive/tez/alter_merge_2_orc.q.out  |   16 +-
 .../results/clientpositive/tez/auto_join0.q.out |   91 +-
 .../results/clientpositive/tez/auto_join1.q.out |    8 +-
 .../tez/auto_sortmerge_join_5.q.out             |    6 +
 .../results/clientpositive/tez/cbo_gby.q.out    |   18 +-
 .../clientpositive/tez/cbo_udf_udaf.q.out       |   18 +-
 .../clientpositive/tez/cbo_windowing.q.out      |   66 +-
 .../tez/cross_product_check_1.q.out             |   20 +-
 .../tez/cross_product_check_2.q.out             |   88 +-
 .../test/results/clientpositive/tez/ctas.q.out  |    2 +
 .../tez/dynpart_sort_optimization2.q.out        |  166 +-
 .../clientpositive/tez/explainuser_2.q.out      |    8 +-
 .../tez/filter_join_breaktask2.q.out            |    8 +-
 .../clientpositive/tez/insert_into1.q.out       |   86 +-
 .../clientpositive/tez/insert_into2.q.out       |   82 +-
 .../clientpositive/tez/join_nullsafe.q.out      |    6 +-
 .../clientpositive/tez/mapjoin_decimal.q.out    |   42 +-
 .../test/results/clientpositive/tez/mrr.q.out   | 2052 +++++++++---------
 .../results/clientpositive/tez/orc_merge1.q.out |    8 +-
 .../clientpositive/tez/script_env_var1.q.out    |    8 +-
 .../clientpositive/tez/selectDistinctStar.q.out |   92 +-
 .../results/clientpositive/tez/skewjoin.q.out   |    8 +-
 .../clientpositive/tez/subquery_exists.q.out    |    2 +
 .../results/clientpositive/tez/temp_table.q.out |   81 +-
 .../results/clientpositive/tez/tez_dml.q.out    | 2008 ++++++++---------
 .../clientpositive/tez/tez_join_hash.q.out      |  286 +--
 .../clientpositive/tez/tez_joins_explain.q.out  |    2 -
 .../clientpositive/tez/tez_multi_union.q.out    | 1002 ++++-----
 .../tez/tez_schema_evolution.q.out              |   96 +-
 .../tez/update_all_partitioned.q.out            |   14 +-
 .../tez/update_where_partitioned.q.out          |   20 +-
 .../clientpositive/tez/vector_data_types.q.out  |  116 +-
 .../tez/vector_null_projection.q.out            |    8 +-
 .../clientpositive/tez/vector_outer_join1.q.out |  236 +-
 .../clientpositive/tez/vector_outer_join2.q.out |   40 +-
 .../clientpositive/tez/vector_outer_join3.q.out |   82 +-
 .../tez/vectorization_part_project.q.out        |   40 +-
 .../tez/vectorized_distinct_gby.q.out           |    4 +-
 .../clientpositive/tez/vectorized_mapjoin.q.out |    8 +-
 .../tez/vectorized_nested_mapjoin.q.out         |    8 +-
 .../tez/vectorized_rcfile_columnar.q.out        |   24 +-
 .../tez/vectorized_shufflejoin.q.out            |   37 +-
 .../tez/vectorized_timestamp_funcs.q.out        |  292 +--
 .../clientpositive/update_all_partitioned.q.out |   14 +-
 .../update_where_partitioned.q.out              |   20 +-
 .../clientpositive/vector_data_types.q.out      |  116 +-
 .../clientpositive/vector_null_projection.q.out |    8 +-
 .../clientpositive/vector_outer_join1.q.out     |  228 +-
 .../clientpositive/vector_outer_join2.q.out     |   36 +-
 .../clientpositive/vector_outer_join3.q.out     |   70 +-
 .../vectorization_part_project.q.out            |   40 +-
 .../vectorized_distinct_gby.q.out               |    4 +-
 .../clientpositive/vectorized_mapjoin.q.out     |    8 +-
 .../vectorized_nested_mapjoin.q.out             |    8 +-
 .../vectorized_rcfile_columnar.q.out            |   24 +-
 .../clientpositive/vectorized_shufflejoin.q.out |   44 +-
 .../vectorized_timestamp_funcs.q.out            |  292 +--
 153 files changed, 5516 insertions(+), 5075 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/alter_merge_2_orc.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/alter_merge_2_orc.q 
b/ql/src/test/queries/clientpositive/alter_merge_2_orc.q
index 580b535..990ae6b 100644
--- a/ql/src/test/queries/clientpositive/alter_merge_2_orc.q
+++ b/ql/src/test/queries/clientpositive/alter_merge_2_orc.q
@@ -3,9 +3,9 @@ create table src_orc_merge_test_part(key int, value string) 
partitioned by (ds s
 alter table src_orc_merge_test_part add partition (ds='2012-01-03', 
ts='2012-01-03+14:46:31');
 desc extended src_orc_merge_test_part partition (ds='2012-01-03', 
ts='2012-01-03+14:46:31');
 
-insert overwrite table src_orc_merge_test_part partition(ds='2012-01-03', 
ts='2012-01-03+14:46:31') select * from src;
-insert into table src_orc_merge_test_part partition(ds='2012-01-03', 
ts='2012-01-03+14:46:31') select * from src limit 100;
-insert into table src_orc_merge_test_part partition(ds='2012-01-03', 
ts='2012-01-03+14:46:31') select * from src limit 10;
+insert overwrite table src_orc_merge_test_part partition(ds='2012-01-03', 
ts='2012-01-03+14:46:31') select * from src order by key, value;
+insert into table src_orc_merge_test_part partition(ds='2012-01-03', 
ts='2012-01-03+14:46:31') select * from src order by key, value limit 100;
+insert into table src_orc_merge_test_part partition(ds='2012-01-03', 
ts='2012-01-03+14:46:31') select * from src order by key, value limit 10;
 
 select count(1) from src_orc_merge_test_part where ds='2012-01-03' and 
ts='2012-01-03+14:46:31';
 select sum(hash(key)), sum(hash(value)) from src_orc_merge_test_part where 
ds='2012-01-03' and ts='2012-01-03+14:46:31';

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/auto_join0.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_join0.q 
b/ql/src/test/queries/clientpositive/auto_join0.q
index 84731db..008f9e3 100644
--- a/ql/src/test/queries/clientpositive/auto_join0.q
+++ b/ql/src/test/queries/clientpositive/auto_join0.q
@@ -1,14 +1,15 @@
-
 set hive.auto.convert.join = true;
 
+-- 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;
 
@@ -16,8 +17,8 @@ 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;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/auto_join1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_join1.q 
b/ql/src/test/queries/clientpositive/auto_join1.q
index 2062a28..7414005 100644
--- a/ql/src/test/queries/clientpositive/auto_join1.q
+++ b/ql/src/test/queries/clientpositive/auto_join1.q
@@ -1,5 +1,7 @@
 set hive.auto.convert.join =true;
 
+-- SORT_QUERY_RESULTS
+
 CREATE TABLE dest_j1(key INT, value STRING) STORED AS TEXTFILE;
 
 explain

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/auto_sortmerge_join_5.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_5.q 
b/ql/src/test/queries/clientpositive/auto_sortmerge_join_5.q
index 98d6df9..75c930c 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_5.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_5.q
@@ -1,4 +1,7 @@
 -- 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;
 load data local inpath '../../data/files/smallsrcsortbucket1outof4.txt' INTO 
TABLE bucket_small;
 load data local inpath '../../data/files/smallsrcsortbucket2outof4.txt' INTO 
TABLE bucket_small;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/cbo_gby.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cbo_gby.q 
b/ql/src/test/queries/clientpositive/cbo_gby.q
index e0eed08..73c8c6a 100644
--- a/ql/src/test/queries/clientpositive/cbo_gby.q
+++ b/ql/src/test/queries/clientpositive/cbo_gby.q
@@ -4,8 +4,11 @@ set hive.exec.check.crossproducts=false;
 set hive.stats.fetch.column.stats=true;
 set hive.auto.convert.join=false;
 
+-- 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;
+
 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;
 
 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;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/cbo_udf_udaf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cbo_udf_udaf.q 
b/ql/src/test/queries/clientpositive/cbo_udf_udaf.q
index 093bcc9..16d9bb9 100644
--- a/ql/src/test/queries/clientpositive/cbo_udf_udaf.q
+++ b/ql/src/test/queries/clientpositive/cbo_udf_udaf.q
@@ -4,6 +4,8 @@ set hive.exec.check.crossproducts=false;
 set hive.stats.fetch.column.stats=true;
 set hive.auto.convert.join=false;
 
+-- 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;
 select count(*), count(c_int) as a, sum(c_int), avg(c_int), max(c_int), 
min(c_int), case c_int when 0  then 1 when 1 then 2 else 3 end, sum(case c_int 
when 0  then 1 when 1 then 2 else 3 end) from cbo_t1 group by c_int order by a;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/cbo_windowing.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cbo_windowing.q 
b/ql/src/test/queries/clientpositive/cbo_windowing.q
index fb4fe56..4ccc891 100644
--- a/ql/src/test/queries/clientpositive/cbo_windowing.q
+++ b/ql/src/test/queries/clientpositive/cbo_windowing.q
@@ -5,6 +5,8 @@ set hive.stats.fetch.column.stats=true;
 set hive.auto.convert.join=false;
 
 -- 9. Test Windowing Functions
+-- SORT_QUERY_RESULTS
+
 select count(c_int) over() from cbo_t1;
 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;
 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;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/cross_product_check_1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cross_product_check_1.q 
b/ql/src/test/queries/clientpositive/cross_product_check_1.q
index fb38c94..17a8833 100644
--- a/ql/src/test/queries/clientpositive/cross_product_check_1.q
+++ b/ql/src/test/queries/clientpositive/cross_product_check_1.q
@@ -1,3 +1,4 @@
+-- SORT_QUERY_RESULTS
 
 create table A as
 select * from src;
@@ -14,13 +15,13 @@ explain select * from B d1 join B d2 on d1.key = d2.key 
join A;
 
 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;
-          
-explain select * from A join (select d1.key from B d1 join B d2 where 1 = 1 
group by d1.key) od1;
+
+explain select * from A join (select d1.key from B d1 join B d2 where 1 = 1  
group by d1.key) od1;
 
 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;
 
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/cross_product_check_2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cross_product_check_2.q 
b/ql/src/test/queries/clientpositive/cross_product_check_2.q
index 479d571..de6b7f2 100644
--- a/ql/src/test/queries/clientpositive/cross_product_check_2.q
+++ b/ql/src/test/queries/clientpositive/cross_product_check_2.q
@@ -1,8 +1,10 @@
+-- SORT_QUERY_RESULTS
+
 create table A as
 select * from src;
 
 create table B as
-select * from src
+select * from src order by key
 limit 10;
 
 set hive.auto.convert.join=true;
@@ -17,7 +19,7 @@ explain select * from A join
          (select d1.key 
           from B d1 join B d2 on d1.key = d2.key 
           where 1 = 1 group by d1.key) od1;
-          
+
 explain select * from A join (select d1.key from B d1 join B d2 where 1 = 1 
group by d1.key) od1;
 
 explain select * from 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/ctas.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/ctas.q 
b/ql/src/test/queries/clientpositive/ctas.q
index b6de233..3435d03 100644
--- a/ql/src/test/queries/clientpositive/ctas.q
+++ b/ql/src/test/queries/clientpositive/ctas.q
@@ -1,4 +1,5 @@
 -- EXCLUDE_HADOOP_MAJOR_VERSIONS( 0.20S)
+-- SORT_QUERY_RESULTS
 
 create table nzhang_Tmp(a int, b string);
 select * from nzhang_Tmp;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/dynpart_sort_optimization2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/dynpart_sort_optimization2.q 
b/ql/src/test/queries/clientpositive/dynpart_sort_optimization2.q
index 70c795d..58319e3 100644
--- a/ql/src/test/queries/clientpositive/dynpart_sort_optimization2.q
+++ b/ql/src/test/queries/clientpositive/dynpart_sort_optimization2.q
@@ -8,6 +8,8 @@ set hive.enforce.sorting=false;
 set hive.exec.submitviachild=true;
 set hive.exec.submit.local.task.via.child=true;
 
+-- SORT_QUERY_RESULTS
+
 drop table ss;
 drop table ss_orc;
 drop table ss_part;
@@ -223,7 +225,7 @@ select
     "day" `day`
 from src
 group by "day", key;
-select * from hive13_dp1 limit 5;
+select * from hive13_dp1 order by k1, k2 limit 5;
 
 set hive.optimize.sort.dynamic.partition=true;
 explain insert overwrite table `hive13_dp1` partition(`day`)
@@ -241,6 +243,7 @@ select
     "day" `day`
 from src
 group by "day", key;
-select * from hive13_dp1 limit 5;
+
+select * from hive13_dp1 order by k1, k2 limit 5;
 
 drop table hive13_dp1;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/explainuser_2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/explainuser_2.q 
b/ql/src/test/queries/clientpositive/explainuser_2.q
index 6e98fa0..560a086 100644
--- a/ql/src/test/queries/clientpositive/explainuser_2.q
+++ b/ql/src/test/queries/clientpositive/explainuser_2.q
@@ -1,6 +1,8 @@
 set hive.explain.user=true;
 set hive.metastore.aggregate.stats.cache.enabled=false;
 
+-- SORT_QUERY_RESULTS
+
 CREATE TABLE dest_j1(key STRING, value STRING, val2 STRING) STORED AS TEXTFILE;
 
 CREATE TABLE ss(k1 STRING,v1 STRING,k2 STRING,v2 STRING,k3 STRING,v3 STRING) 
STORED AS TEXTFILE;
@@ -81,7 +83,6 @@ SELECT x.key, z.value, y.value
 FROM src1 x JOIN src y ON (x.key = y.key) 
 JOIN (select * from src1 union select * from src)z ON (x.value = z.value);
 
-
 explain
 SELECT x.key, y.value
 FROM src1 x JOIN src y ON (x.key = y.key) 
@@ -100,7 +101,6 @@ set hive.auto.convert.join=true;
 set hive.auto.convert.join.noconditionaltask=true;
 set hive.auto.convert.join.noconditionaltask.size=10000;
 
-
 EXPLAIN
 SELECT x.key, z.value, y.value
 FROM src1 x JOIN src y ON (x.key = y.key) 
@@ -143,7 +143,6 @@ SELECT x.key, z.value, y.value
 FROM src1 x JOIN src y ON (x.key = y.key) 
 JOIN (select * from src1 union select * from src)z ON (x.value = z.value);
 
-
 explain
 SELECT x.key, y.value
 FROM src1 x JOIN src y ON (x.key = y.key) 
@@ -194,7 +193,6 @@ set hive.auto.convert.sortmerge.join = true;
 
 set hive.auto.convert.join.noconditionaltask.size=500;
 
-
 explain 
 select s1.key as key, s1.value as value from tab s1 join tab s3 on 
s1.key=s3.key;
 
@@ -213,7 +211,6 @@ UNION  ALL
 select s2.key as key, s2.value as value from tab s2
 ) a join tab_part b on (a.key = b.key);
 
-
 explain
 select count(*) from (select s1.key as key, s1.value as value from tab s1 join 
tab s3 on s1.key=s3.key join tab s2 on s1.value=s2.value
 UNION  ALL

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/filter_join_breaktask2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/filter_join_breaktask2.q 
b/ql/src/test/queries/clientpositive/filter_join_breaktask2.q
index 4c99f77..a7b3221 100644
--- a/ql/src/test/queries/clientpositive/filter_join_breaktask2.q
+++ b/ql/src/test/queries/clientpositive/filter_join_breaktask2.q
@@ -1,3 +1,5 @@
+-- SORT_QUERY_RESULTS
+
 create table T1(c1 string, c2 string, c3 string, c4 string, c5 string, c6 
string, c7 string) 
 partitioned by (ds string);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/insert_into1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/insert_into1.q 
b/ql/src/test/queries/clientpositive/insert_into1.q
index f19506a..7271a07 100644
--- a/ql/src/test/queries/clientpositive/insert_into1.q
+++ b/ql/src/test/queries/clientpositive/insert_into1.q
@@ -1,18 +1,21 @@
 set hive.compute.query.using.stats=true;
+
+-- SORT_QUERY_RESULTS
+
 DROP TABLE insert_into1;
 
 CREATE TABLE insert_into1 (key int, value string);
 
-EXPLAIN INSERT INTO TABLE insert_into1 SELECT * from src LIMIT 100;
-INSERT INTO TABLE insert_into1 SELECT * from src LIMIT 100;
+EXPLAIN INSERT INTO TABLE insert_into1 SELECT * from src ORDER BY key LIMIT 
100;
+INSERT INTO TABLE insert_into1 SELECT * from src ORDER BY key LIMIT 100;
 SELECT SUM(HASH(c)) FROM (
     SELECT TRANSFORM(*) USING 'tr \t _' AS (c) FROM insert_into1
 ) t;
 explain 
 select count(*) from insert_into1;
 select count(*) from insert_into1;
-EXPLAIN INSERT INTO TABLE insert_into1 SELECT * FROM src LIMIT 100;
-INSERT INTO TABLE insert_into1 SELECT * FROM src LIMIT 100;
+EXPLAIN INSERT INTO TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 
100;
+INSERT INTO TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 100;
 SELECT SUM(HASH(c)) FROM (
     SELECT TRANSFORM(*) USING 'tr \t _' AS (c) FROM insert_into1
 ) t;
@@ -21,8 +24,8 @@ explain
 SELECT COUNT(*) FROM insert_into1;
 select count(*) from insert_into1;
 
-EXPLAIN INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src LIMIT 10;
-INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src LIMIT 10;
+EXPLAIN INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src ORDER BY key 
LIMIT 10;
+INSERT OVERWRITE TABLE insert_into1 SELECT * FROM src ORDER BY key LIMIT 10;
 SELECT SUM(HASH(c)) FROM (
     SELECT TRANSFORM(*) USING 'tr \t _' AS (c) FROM insert_into1
 ) t;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/insert_into2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/insert_into2.q 
b/ql/src/test/queries/clientpositive/insert_into2.q
index 1cbe391..a53f7f4 100644
--- a/ql/src/test/queries/clientpositive/insert_into2.q
+++ b/ql/src/test/queries/clientpositive/insert_into2.q
@@ -4,12 +4,12 @@ CREATE TABLE insert_into2 (key int, value string)
   PARTITIONED BY (ds string);
 
 EXPLAIN INSERT INTO TABLE insert_into2 PARTITION (ds='1') 
-  SELECT * FROM src LIMIT 100;
-INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src limit 100;
+  SELECT * FROM src order by key LIMIT 100;
+INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src order by 
key limit 100;
 explain
 select count (*) from insert_into2 where ds = '1';
 select count (*) from insert_into2 where ds = '1';
-INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src limit 100;
+INSERT INTO TABLE insert_into2 PARTITION (ds='1') SELECT * FROM src order by 
key limit 100;
 explain
 SELECT COUNT(*) FROM insert_into2 WHERE ds='1';
 SELECT COUNT(*) FROM insert_into2 WHERE ds='1';
@@ -18,9 +18,9 @@ SELECT SUM(HASH(c)) FROM (
 ) t;
 
 EXPLAIN INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 100;
+  SELECT * FROM src order by key LIMIT 100;
 INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 100;
+  SELECT * FROM src order by key LIMIT 100;
 
 SELECT SUM(HASH(c)) FROM (
     SELECT TRANSFORM(*) USING 'tr \t _' AS (c) FROM insert_into2
@@ -30,9 +30,9 @@ SELECT COUNT(*) FROM insert_into2 WHERE ds='2';
 SELECT COUNT(*) FROM insert_into2 WHERE ds='2';
 
 EXPLAIN INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 50;
+  SELECT * FROM src order by key LIMIT 50;
 INSERT OVERWRITE TABLE insert_into2 PARTITION (ds='2')
-  SELECT * FROM src LIMIT 50;
+  SELECT * FROM src order by key LIMIT 50;
 SELECT SUM(HASH(c)) FROM (
     SELECT TRANSFORM(*) USING 'tr \t _' AS (c) FROM insert_into2
 ) t;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/insert_nonacid_from_acid.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/insert_nonacid_from_acid.q 
b/ql/src/test/queries/clientpositive/insert_nonacid_from_acid.q
index 1bb2ee3..639cb31 100644
--- a/ql/src/test/queries/clientpositive/insert_nonacid_from_acid.q
+++ b/ql/src/test/queries/clientpositive/insert_nonacid_from_acid.q
@@ -2,6 +2,8 @@ set hive.support.concurrency=true;
 set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
 set hive.enforce.bucketing=true;
 
+-- 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"); 
 insert into table sample_06 values ('aaa', 35, 3.00), ('bbb', 32, 3.00), 
('ccc', 32, 3.00), ('ddd', 35, 3.00), ('eee', 32, 3.00); 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/join_merge_multi_expressions.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/join_merge_multi_expressions.q 
b/ql/src/test/queries/clientpositive/join_merge_multi_expressions.q
index dcab313..7bbfbc7 100644
--- a/ql/src/test/queries/clientpositive/join_merge_multi_expressions.q
+++ b/ql/src/test/queries/clientpositive/join_merge_multi_expressions.q
@@ -1,3 +1,4 @@
+-- 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;
 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;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/join_nullsafe.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/join_nullsafe.q 
b/ql/src/test/queries/clientpositive/join_nullsafe.q
index 78a65d6..46bbadd 100644
--- a/ql/src/test/queries/clientpositive/join_nullsafe.q
+++ b/ql/src/test/queries/clientpositive/join_nullsafe.q
@@ -5,6 +5,7 @@ LOAD DATA LOCAL INPATH '../../data/files/in8.txt' INTO TABLE 
myinput1;
 
 -- merging
 explain select * from myinput1 a join myinput1 b on a.key<=>b.value;
+-- SORT_QUERY_RESULTS
 select * from myinput1 a join myinput1 b on a.key<=>b.value;
 
 explain select * from myinput1 a join myinput1 b on a.key<=>b.value join 
myinput1 c on a.key=c.key;
@@ -14,6 +15,7 @@ explain select * from myinput1 a join myinput1 b on 
a.key<=>b.value join myinput
 select * from myinput1 a join myinput1 b on a.key<=>b.value join myinput1 c on 
a.key<=>c.key;
 
 explain select * from myinput1 a join myinput1 b on a.key<=>b.value AND 
a.value=b.key join myinput1 c on a.key<=>c.key AND a.value=c.value;
+
 select * from myinput1 a join myinput1 b on a.key<=>b.value AND a.value=b.key 
join myinput1 c on a.key<=>c.key AND a.value=c.value;
 
 explain select * from myinput1 a join myinput1 b on a.key<=>b.value AND 
a.value<=>b.key join myinput1 c on a.key<=>c.key AND a.value<=>c.value;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/mapjoin_decimal.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/mapjoin_decimal.q 
b/ql/src/test/queries/clientpositive/mapjoin_decimal.q
index e0babb9..7299808 100644
--- a/ql/src/test/queries/clientpositive/mapjoin_decimal.q
+++ b/ql/src/test/queries/clientpositive/mapjoin_decimal.q
@@ -26,12 +26,12 @@ CREATE TABLE t2(dec decimal(4,0)) STORED AS ORC;
 INSERT INTO TABLE t2 select dec from over1k;
 
 explain
-select t1.dec, t2.dec from t1 join t2 on (t1.dec=t2.dec);
+select t1.dec, t2.dec from t1 join t2 on (t1.dec=t2.dec) order by t1.dec;
 
 set hive.mapjoin.optimized.hashtable=false;
 
-select t1.dec, t2.dec from t1 join t2 on (t1.dec=t2.dec);
+select t1.dec, t2.dec from t1 join t2 on (t1.dec=t2.dec) order by t1.dec;
 
 set hive.mapjoin.optimized.hashtable=true;
 
-select t1.dec, t2.dec from t1 join t2 on (t1.dec=t2.dec);
+select t1.dec, t2.dec from t1 join t2 on (t1.dec=t2.dec) order by t1.dec;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/mrr.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/mrr.q 
b/ql/src/test/queries/clientpositive/mrr.q
index a3007ff..bd379d2 100644
--- a/ql/src/test/queries/clientpositive/mrr.q
+++ b/ql/src/test/queries/clientpositive/mrr.q
@@ -1,4 +1,6 @@
 -- simple query with multiple reduce stages
+-- SORT_QUERY_RESULTS
+
 EXPLAIN SELECT key, count(value) as cnt FROM src GROUP BY key ORDER BY cnt;
 SELECT key, count(value) as cnt FROM src GROUP BY key ORDER BY cnt;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/orc_merge1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/orc_merge1.q 
b/ql/src/test/queries/clientpositive/orc_merge1.q
index 410ef0b..1c0bf41 100644
--- a/ql/src/test/queries/clientpositive/orc_merge1.q
+++ b/ql/src/test/queries/clientpositive/orc_merge1.q
@@ -10,6 +10,8 @@ set hive.merge.tezfiles=false;
 set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 
+-- SORT_QUERY_RESULTS
+
 DROP TABLE orcfile_merge1;
 DROP TABLE orcfile_merge1b;
 DROP TABLE orcfile_merge1c;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/partition_date2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/partition_date2.q 
b/ql/src/test/queries/clientpositive/partition_date2.q
index c932ed1..51ac2cd 100644
--- a/ql/src/test/queries/clientpositive/partition_date2.q
+++ b/ql/src/test/queries/clientpositive/partition_date2.q
@@ -1,3 +1,5 @@
+-- SORT_QUERY_RESULTS
+
 drop table partition_date2_1;
 
 create table partition_date2_1 (key string, value string) partitioned by (dt 
date, region int);

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/script_env_var1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/script_env_var1.q 
b/ql/src/test/queries/clientpositive/script_env_var1.q
index 0148905..77d9945 100644
--- a/ql/src/test/queries/clientpositive/script_env_var1.q
+++ b/ql/src/test/queries/clientpositive/script_env_var1.q
@@ -1,5 +1,5 @@
 -- 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;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/selectDistinctStar.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/selectDistinctStar.q 
b/ql/src/test/queries/clientpositive/selectDistinctStar.q
index e06f167..300d7e0 100644
--- a/ql/src/test/queries/clientpositive/selectDistinctStar.q
+++ b/ql/src/test/queries/clientpositive/selectDistinctStar.q
@@ -1,3 +1,5 @@
+-- SORT_QUERY_RESULTS
+
 explain select distinct src.* from src;
 
 select distinct src.* from src;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/skewjoin.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/skewjoin.q 
b/ql/src/test/queries/clientpositive/skewjoin.q
index 47535ea..6d43ea8 100644
--- a/ql/src/test/queries/clientpositive/skewjoin.q
+++ b/ql/src/test/queries/clientpositive/skewjoin.q
@@ -1,11 +1,7 @@
 set hive.optimize.skewjoin = true;
 set hive.skewjoin.key = 2;
 
-
-
-
-
-
+-- SORT_QUERY_RESULTS
 
 CREATE TABLE T1(key STRING, val STRING) STORED AS TEXTFILE;
 CREATE TABLE T2(key STRING, val STRING) STORED AS TEXTFILE;
@@ -18,7 +14,6 @@ LOAD DATA LOCAL INPATH '../../data/files/T2.txt' INTO TABLE 
T2;
 LOAD DATA LOCAL INPATH '../../data/files/T3.txt' INTO TABLE T3;
 LOAD DATA LOCAL INPATH '../../data/files/T1.txt' INTO TABLE T4;
 
-
 EXPLAIN
 FROM src src1 JOIN src src2 ON (src1.key = src2.key)
 INSERT OVERWRITE TABLE dest_j1 SELECT src1.key, src2.value;
@@ -28,7 +23,6 @@ INSERT OVERWRITE TABLE dest_j1 SELECT src1.key, src2.value;
 
 SELECT sum(hash(key)), sum(hash(value)) FROM dest_j1;
 
-
 EXPLAIN
 SELECT /*+ STREAMTABLE(a) */ *
 FROM T1 a JOIN T2 b ON a.key = b.key
@@ -51,7 +45,6 @@ FROM T1 a JOIN T2 b ON a.key = b.key
           JOIN T3 c ON b.key = c.key
           JOIN T4 d ON c.key = d.key;
 
-
 EXPLAIN FROM T1 a JOIN src c ON c.key+1=a.key SELECT /*+ STREAMTABLE(a) */ 
sum(hash(a.key)), sum(hash(a.val)), sum(hash(c.key));
 FROM T1 a JOIN src c ON c.key+1=a.key SELECT /*+ STREAMTABLE(a) */ 
sum(hash(a.key)), sum(hash(a.val)), sum(hash(c.key));
 
@@ -69,7 +62,6 @@ JOIN
 ON (x.key = Y.key)
 SELECT sum(hash(Y.key)), sum(hash(Y.value));
 
-
 EXPLAIN FROM 
 (SELECT src.* FROM src) x
 JOIN 
@@ -84,7 +76,6 @@ JOIN
 ON (x.key = Y.key and substring(x.value, 5)=substring(y.value, 5)+1)
 SELECT sum(hash(Y.key)), sum(hash(Y.value));
 
-
 EXPLAIN
 SELECT sum(hash(src1.c1)), sum(hash(src2.c4)) 
 FROM

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/subquery_exists.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/subquery_exists.q 
b/ql/src/test/queries/clientpositive/subquery_exists.q
index b16584e..103663e 100644
--- a/ql/src/test/queries/clientpositive/subquery_exists.q
+++ b/ql/src/test/queries/clientpositive/subquery_exists.q
@@ -1,6 +1,7 @@
 -- SORT_QUERY_RESULTS
 
 -- no agg, corr
+-- SORT_QUERY_RESULTS
 explain
 select * 
 from src b 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/temp_table.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/temp_table.q 
b/ql/src/test/queries/clientpositive/temp_table.q
index 9667070..ac0acb1 100644
--- a/ql/src/test/queries/clientpositive/temp_table.q
+++ b/ql/src/test/queries/clientpositive/temp_table.q
@@ -7,8 +7,8 @@ CREATE TEMPORARY TABLE bar AS SELECT * FROM src WHERE key % 2 = 
1;
 DESCRIBE foo;
 DESCRIBE bar;
 
-explain select * from foo limit 10;
-select * from foo limit 10;
+explain select * from foo order by key limit 10;
+select * from foo order by key limit 10;
 
 explain select * from (select * from foo union all select * from bar) u order 
by key limit 10;
 select * from (select * from foo union all select * from bar) u order by key 
limit 10;
@@ -22,7 +22,7 @@ select * from bay;
 
 INSERT OVERWRITE TABLE bay SELECT * FROM src ORDER BY key;
 
-select * from bay limit 10;
+select * from bay order by key limit 10;
 
 SHOW TABLES;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/tez_dml.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/tez_dml.q 
b/ql/src/test/queries/clientpositive/tez_dml.q
index 87d251f..d8480cc 100644
--- a/ql/src/test/queries/clientpositive/tez_dml.q
+++ b/ql/src/test/queries/clientpositive/tez_dml.q
@@ -1,6 +1,8 @@
 set hive.exec.dynamic.partition.mode=nonstrict;
 
 -- CTAS
+-- SORT_QUERY_RESULTS
+
 EXPLAIN CREATE TABLE tmp_src AS SELECT * FROM (SELECT value, count(value) AS 
cnt FROM src GROUP BY value) f1 ORDER BY cnt;
 CREATE TABLE tmp_src AS SELECT * FROM (SELECT value, count(value) AS cnt FROM 
src GROUP BY value) f1 ORDER BY cnt;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/tez_join_hash.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/tez_join_hash.q 
b/ql/src/test/queries/clientpositive/tez_join_hash.q
index 67d89f8..73cd53e 100644
--- a/ql/src/test/queries/clientpositive/tez_join_hash.q
+++ b/ql/src/test/queries/clientpositive/tez_join_hash.q
@@ -1,3 +1,5 @@
+-- SORT_QUERY_RESULTS
+
 create table orc_src (key string, value string) STORED AS ORC;
 insert into table orc_src select * from src;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/tez_joins_explain.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/tez_joins_explain.q 
b/ql/src/test/queries/clientpositive/tez_joins_explain.q
index 7d3b8f6..4b6b0ca 100644
--- a/ql/src/test/queries/clientpositive/tez_joins_explain.q
+++ b/ql/src/test/queries/clientpositive/tez_joins_explain.q
@@ -1,5 +1,4 @@
 -- SORT_QUERY_RESULTS
-
 explain
 select * from (select b.key, b.value from src1 a left outer join src b on 
(a.key = b.key) order by b.key) x right outer join src c on (x.value = c.value) 
order by x.key;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/tez_multi_union.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/tez_multi_union.q 
b/ql/src/test/queries/clientpositive/tez_multi_union.q
index 28fdfea..9dd3c8d 100644
--- a/ql/src/test/queries/clientpositive/tez_multi_union.q
+++ b/ql/src/test/queries/clientpositive/tez_multi_union.q
@@ -1,3 +1,4 @@
+-- SORT_QUERY_RESULTS
 select key from
 (
 select key from src

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/tez_schema_evolution.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/tez_schema_evolution.q 
b/ql/src/test/queries/clientpositive/tez_schema_evolution.q
index 2f1c73f..632878a 100644
--- a/ql/src/test/queries/clientpositive/tez_schema_evolution.q
+++ b/ql/src/test/queries/clientpositive/tez_schema_evolution.q
@@ -1,14 +1,16 @@
+-- SORT_QUERY_RESULTS
+
 create table test (key int, value string) partitioned by (p int) stored as 
textfile;
 
-insert into table test partition (p=1) select * from src limit 10;
+insert into table test partition (p=1) select * from src order by key limit 10;
 
 alter table test set fileformat orc;
 
-insert into table test partition (p=2) select * from src limit 10;
+insert into table test partition (p=2) select * from src order by key limit 10;
 
 describe test;
 
-select * from test where p=1 and key > 0;
-select * from test where p=2 and key > 0;
-select * from test where key > 0;
+select * from test where p=1 and key > 0 order by key;
+select * from test where p=2 and key > 0 order by key;
+select * from test where key > 0 order by key;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/update_all_partitioned.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/update_all_partitioned.q 
b/ql/src/test/queries/clientpositive/update_all_partitioned.q
index b407985..e191d0a 100644
--- a/ql/src/test/queries/clientpositive/update_all_partitioned.q
+++ b/ql/src/test/queries/clientpositive/update_all_partitioned.q
@@ -4,8 +4,8 @@ set hive.enforce.bucketing=true;
 
 create table acid_uap(a int, b varchar(128)) partitioned by (ds string) 
clustered by (a) into 2 buckets stored as orc TBLPROPERTIES 
('transactional'='true');
 
-insert into table acid_uap partition (ds='today') select cint, cast(cstring1 
as varchar(128)) from alltypesorc where cint is not null and cint < 0 order by 
cint limit 10;
-insert into table acid_uap partition (ds='tomorrow') select cint, 
cast(cstring1 as varchar(128)) from alltypesorc where cint is not null and cint 
> 10 order by cint limit 10;
+insert into table acid_uap partition (ds='today') select cint, cast(cstring1 
as varchar(128)) as cs from alltypesorc where cint is not null and cint < 0 
order by cint, cs limit 10;
+insert into table acid_uap partition (ds='tomorrow') select cint, 
cast(cstring1 as varchar(128)) as cs from alltypesorc where cint is not null 
and cint > 10 order by cint, cs limit 10;
 
 select a,b,ds from acid_uap order by a,b;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/update_where_partitioned.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/update_where_partitioned.q 
b/ql/src/test/queries/clientpositive/update_where_partitioned.q
index 858cebb..157712f 100644
--- a/ql/src/test/queries/clientpositive/update_where_partitioned.q
+++ b/ql/src/test/queries/clientpositive/update_where_partitioned.q
@@ -4,8 +4,8 @@ set hive.enforce.bucketing=true;
 
 create table acid_uwp(a int, b varchar(128)) partitioned by (ds string) 
clustered by (a) into 2 buckets stored as orc TBLPROPERTIES 
('transactional'='true');
 
-insert into table acid_uwp partition (ds='today') select cint, cast(cstring1 
as varchar(128)) from alltypesorc where cint is not null and cint < 0 order by 
cint limit 10;
-insert into table acid_uwp partition (ds='tomorrow') select cint, 
cast(cstring1 as varchar(128)) from alltypesorc where cint is not null and cint 
> 100 order by cint limit 10;
+insert into table acid_uwp partition (ds='today') select cint, cast(cstring1 
as varchar(128)) as cs from alltypesorc where cint is not null and cint < 0 
order by cint, cs limit 10;
+insert into table acid_uwp partition (ds='tomorrow') select cint, 
cast(cstring1 as varchar(128)) as cs from alltypesorc where cint is not null 
and cint > 100 order by cint, cs limit 10;
 
 select a,b,ds from acid_uwp order by a, ds, b;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vector_data_types.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vector_data_types.q 
b/ql/src/test/queries/clientpositive/vector_data_types.q
index 61356fa..c7a9c4c 100644
--- a/ql/src/test/queries/clientpositive/vector_data_types.q
+++ b/ql/src/test/queries/clientpositive/vector_data_types.q
@@ -36,18 +36,18 @@ INSERT INTO TABLE over1korc SELECT * FROM over1k;
 
 SET hive.vectorized.execution.enabled=false;
 
-EXPLAIN SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY 
i LIMIT 20;
+EXPLAIN SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY 
t, si, i LIMIT 20;
 
-SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY i LIMIT 
20;
+SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY t, si, i 
LIMIT 20;
 
 SELECT SUM(HASH(*))
-FROM (SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY i) 
as q;
+FROM (SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY t, 
si, i) as q;
 
 SET hive.vectorized.execution.enabled=true;
 
-EXPLAIN select t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY 
i LIMIT 20;
+EXPLAIN select t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY 
t, si, i LIMIT 20;
 
-SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY i LIMIT 
20;
+SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY t, si, i 
LIMIT 20;
 
 SELECT SUM(HASH(*))
-FROM (SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY i) 
as q;
\ No newline at end of file
+FROM (SELECT t, si, i, b, f, d, bo, s, ts, dec, bin FROM over1korc ORDER BY t, 
si, i) as q;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vector_null_projection.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vector_null_projection.q 
b/ql/src/test/queries/clientpositive/vector_null_projection.q
index 765e45f..bab496e 100644
--- a/ql/src/test/queries/clientpositive/vector_null_projection.q
+++ b/ql/src/test/queries/clientpositive/vector_null_projection.q
@@ -1,6 +1,8 @@
 SET hive.vectorized.execution.enabled=true;
 set hive.fetch.task.conversion=none;
 
+-- SORT_QUERY_RESULTS
+
 create table a(s string) stored as orc;
 create table b(s string) stored as orc;
 insert into table a values('aaa');

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vector_outer_join1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vector_outer_join1.q 
b/ql/src/test/queries/clientpositive/vector_outer_join1.q
index a352cd7..5a1aa0b 100644
--- a/ql/src/test/queries/clientpositive/vector_outer_join1.q
+++ b/ql/src/test/queries/clientpositive/vector_outer_join1.q
@@ -1,10 +1,10 @@
 SET hive.vectorized.execution.enabled=true;
 SET hive.auto.convert.join=true;
 
-create table small_alltypesorc1a as select * from alltypesorc where cint is 
not null and ctinyint is not null limit 5;
-create table small_alltypesorc2a as select * from alltypesorc where cint is 
null and ctinyint is not null limit 5;
-create table small_alltypesorc3a as select * from alltypesorc where cint is 
not null and ctinyint is null limit 5;
-create table small_alltypesorc4a as select * from alltypesorc where cint is 
null and ctinyint is null limit 5;
+create table small_alltypesorc1a as select * from alltypesorc where cint is 
not null and ctinyint is not null order by cint, ctinyint limit 5;
+create table small_alltypesorc2a as select * from alltypesorc where cint is 
null and ctinyint is not null order by cint, ctinyint limit 5;
+create table small_alltypesorc3a as select * from alltypesorc where cint is 
not null and ctinyint is null order by cint, ctinyint limit 5;
+create table small_alltypesorc4a as select * from alltypesorc where cint is 
null and ctinyint is null order by cint, ctinyint limit 5;
 
 create table small_alltypesorc_a stored as orc as select * from 
 (select * from (select * from small_alltypesorc1a) sq1

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vector_outer_join2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vector_outer_join2.q 
b/ql/src/test/queries/clientpositive/vector_outer_join2.q
index 76aa2fd..b3503fd 100644
--- a/ql/src/test/queries/clientpositive/vector_outer_join2.q
+++ b/ql/src/test/queries/clientpositive/vector_outer_join2.q
@@ -2,10 +2,10 @@ SET hive.vectorized.execution.enabled=true;
 SET hive.auto.convert.join=true;
 SET hive.vectorized.execution.mapjoin.native.enabled=true;
 
-create table small_alltypesorc1a as select * from alltypesorc where cint is 
not null and ctinyint is not null limit 5;
-create table small_alltypesorc2a as select * from alltypesorc where cint is 
null and ctinyint is not null limit 5;
-create table small_alltypesorc3a as select * from alltypesorc where cint is 
not null and ctinyint is null limit 5;
-create table small_alltypesorc4a as select * from alltypesorc where cint is 
null and ctinyint is null limit 5;
+create table small_alltypesorc1a as select * from alltypesorc where cint is 
not null and ctinyint is not null order by cint, ctinyint limit 5;
+create table small_alltypesorc2a as select * from alltypesorc where cint is 
null and ctinyint is not null order by cint, ctinyint limit 5;
+create table small_alltypesorc3a as select * from alltypesorc where cint is 
not null and ctinyint is null order by cint, ctinyint limit 5;
+create table small_alltypesorc4a as select * from alltypesorc where cint is 
null and ctinyint is null order by cint, ctinyint limit 5;
 
 create table small_alltypesorc_a stored as orc as select * from 
 (select * from (select * from small_alltypesorc1a) sq1

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vector_outer_join3.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vector_outer_join3.q 
b/ql/src/test/queries/clientpositive/vector_outer_join3.q
index 81161cf..a612ab0 100644
--- a/ql/src/test/queries/clientpositive/vector_outer_join3.q
+++ b/ql/src/test/queries/clientpositive/vector_outer_join3.q
@@ -2,10 +2,10 @@ SET hive.vectorized.execution.enabled=true;
 SET hive.auto.convert.join=true;
 SET hive.vectorized.execution.mapjoin.native.enabled=true;
 
-create table small_alltypesorc1a as select * from alltypesorc where cint is 
not null and ctinyint is not null limit 5;
-create table small_alltypesorc2a as select * from alltypesorc where cint is 
null and ctinyint is not null limit 5;
-create table small_alltypesorc3a as select * from alltypesorc where cint is 
not null and ctinyint is null limit 5;
-create table small_alltypesorc4a as select * from alltypesorc where cint is 
null and ctinyint is null limit 5;
+create table small_alltypesorc1a as select * from alltypesorc where cint is 
not null and ctinyint is not null order by cint, ctinyint limit 5;
+create table small_alltypesorc2a as select * from alltypesorc where cint is 
null and ctinyint is not null order by cint, ctinyint limit 5;
+create table small_alltypesorc3a as select * from alltypesorc where cint is 
not null and ctinyint is null order by cint, ctinyint limit 5;
+create table small_alltypesorc4a as select * from alltypesorc where cint is 
null and ctinyint is null order by cint, ctinyint limit 5;
 
 create table small_alltypesorc_a stored as orc as select * from 
 (select * from (select * from small_alltypesorc1a) sq1

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vectorization_part_project.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorization_part_project.q 
b/ql/src/test/queries/clientpositive/vectorization_part_project.q
index c68ce56..e925ea8 100644
--- a/ql/src/test/queries/clientpositive/vectorization_part_project.q
+++ b/ql/src/test/queries/clientpositive/vectorization_part_project.q
@@ -1,7 +1,7 @@
 SET hive.vectorized.execution.enabled=true;
 CREATE TABLE alltypesorc_part(ctinyint tinyint, csmallint smallint, cint int, 
cbigint bigint, cfloat float, cdouble double, cstring1 string, cstring2 string, 
ctimestamp1 timestamp, ctimestamp2 timestamp, cboolean1 boolean, cboolean2 
boolean) partitioned by (ds string) STORED AS ORC;
-insert overwrite table alltypesorc_part partition (ds='2011') select * from 
alltypesorc limit 100;
-insert overwrite table alltypesorc_part partition (ds='2012') select * from 
alltypesorc limit 100;
+insert overwrite table alltypesorc_part partition (ds='2011') select * from 
alltypesorc order by ctinyint, cint, cbigint limit 100;
+insert overwrite table alltypesorc_part partition (ds='2012') select * from 
alltypesorc order by ctinyint, cint, cbigint limit 100;
 
 explain select (cdouble+2) c1 from alltypesorc_part order by c1 limit 10;
 select (cdouble+2) c1 from alltypesorc_part order by c1 limit 10;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vectorized_distinct_gby.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorized_distinct_gby.q 
b/ql/src/test/queries/clientpositive/vectorized_distinct_gby.q
index 6e62200..2553e9f 100644
--- a/ql/src/test/queries/clientpositive/vectorized_distinct_gby.q
+++ b/ql/src/test/queries/clientpositive/vectorized_distinct_gby.q
@@ -3,7 +3,7 @@ SET hive.vectorized.execution.enabled=true;
 SET hive.map.groupby.sorted=true;
 
 create table dtest(a int, b int) clustered by (a) sorted by (a) into 1 buckets 
stored as orc;
-insert into table dtest select c,b from (select array(300,300,300,300,300) as 
a, 1 as b from src limit 1) y lateral view  explode(a) t1 as c;
+insert into table dtest select c,b from (select array(300,300,300,300,300) as 
a, 1 as b from src order by a limit 1) y lateral view  explode(a) t1 as c;
 
 explain select sum(distinct a), count(distinct a) from dtest;
 select sum(distinct a), count(distinct a) from dtest;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vectorized_mapjoin.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorized_mapjoin.q 
b/ql/src/test/queries/clientpositive/vectorized_mapjoin.q
index e5e15ab..10277e5 100644
--- a/ql/src/test/queries/clientpositive/vectorized_mapjoin.q
+++ b/ql/src/test/queries/clientpositive/vectorized_mapjoin.q
@@ -3,6 +3,8 @@ SET hive.auto.convert.join=true;
 SET hive.auto.convert.join.noconditionaltask=true;
 SET hive.auto.convert.join.noconditionaltask.size=1000000000;
 
+-- SORT_QUERY_RESULTS
+
 EXPLAIN SELECT COUNT(t1.cint), MAX(t2.cint), MIN(t1.cint), AVG(t1.cint+t2.cint)
   FROM alltypesorc t1
   JOIN alltypesorc t2 ON t1.cint = t2.cint;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vectorized_nested_mapjoin.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorized_nested_mapjoin.q 
b/ql/src/test/queries/clientpositive/vectorized_nested_mapjoin.q
index e7e4b33..ebf5902 100644
--- a/ql/src/test/queries/clientpositive/vectorized_nested_mapjoin.q
+++ b/ql/src/test/queries/clientpositive/vectorized_nested_mapjoin.q
@@ -3,6 +3,8 @@ SET hive.auto.convert.join=true;
 SET hive.auto.convert.join.noconditionaltask=true;
 SET hive.auto.convert.join.noconditionaltask.size=1000000000;
 
+-- SORT_QUERY_RESULTS
+
 explain select sum(t1.td) from (select  v1.csmallint as tsi, v1.cdouble as td 
from alltypesorc v1, alltypesorc v2 where v1.ctinyint=v2.ctinyint) t1 join 
alltypesorc v3 on t1.tsi=v3.csmallint;
 
 select sum(t1.td) from (select  v1.csmallint as tsi, v1.cdouble as td from 
alltypesorc v1, alltypesorc v2 where v1.ctinyint=v2.ctinyint) t1 join 
alltypesorc v3 on t1.tsi=v3.csmallint;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vectorized_rcfile_columnar.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorized_rcfile_columnar.q 
b/ql/src/test/queries/clientpositive/vectorized_rcfile_columnar.q
index 488d2f3..dc124b1 100644
--- a/ql/src/test/queries/clientpositive/vectorized_rcfile_columnar.q
+++ b/ql/src/test/queries/clientpositive/vectorized_rcfile_columnar.q
@@ -9,7 +9,7 @@ STORED AS
   OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.RCFileOutputFormat';
 
 FROM src
-INSERT OVERWRITE TABLE columnTable SELECT src.key, src.value LIMIT 10;
+INSERT OVERWRITE TABLE columnTable SELECT src.key, src.value ORDER BY src.key, 
src.value LIMIT 10;
 describe columnTable;
 
 SET hive.vectorized.execution.enabled=true;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vectorized_shufflejoin.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorized_shufflejoin.q 
b/ql/src/test/queries/clientpositive/vectorized_shufflejoin.q
index 6b60aa0..c9851d2 100644
--- a/ql/src/test/queries/clientpositive/vectorized_shufflejoin.q
+++ b/ql/src/test/queries/clientpositive/vectorized_shufflejoin.q
@@ -1,10 +1,12 @@
 SET hive.vectorized.execution.enabled=true;
 SET hive.auto.convert.join=false;
 
-EXPLAIN SELECT COUNT(t1.cint), MAX(t2.cint), MIN(t1.cint), AVG(t1.cint+t2.cint)
+-- SORT_QUERY_RESULTS
+
+EXPLAIN SELECT COUNT(t1.cint) AS CNT, MAX(t2.cint) , MIN(t1.cint), 
AVG(t1.cint+t2.cint)
   FROM alltypesorc t1
-  JOIN alltypesorc t2 ON t1.cint = t2.cint;
+  JOIN alltypesorc t2 ON t1.cint = t2.cint order by CNT;
 
-SELECT COUNT(t1.cint), MAX(t2.cint), MIN(t1.cint), AVG(t1.cint+t2.cint)
+SELECT COUNT(t1.cint), MAX(t2.cint) AS CNT, MIN(t1.cint), AVG(t1.cint+t2.cint)
   FROM alltypesorc t1
-  JOIN alltypesorc t2 ON t1.cint = t2.cint;  
\ No newline at end of file
+  JOIN alltypesorc t2 ON t1.cint = t2.cint order by CNT;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/queries/clientpositive/vectorized_timestamp_funcs.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/vectorized_timestamp_funcs.q 
b/ql/src/test/queries/clientpositive/vectorized_timestamp_funcs.q
index 8a2d5aa..8b4702e 100644
--- a/ql/src/test/queries/clientpositive/vectorized_timestamp_funcs.q
+++ b/ql/src/test/queries/clientpositive/vectorized_timestamp_funcs.q
@@ -7,9 +7,10 @@ CREATE TABLE alltypesorc_string(ctimestamp1 timestamp, 
stimestamp1 string) STORE
 
 INSERT OVERWRITE TABLE alltypesorc_string
 SELECT
-  to_utc_timestamp(ctimestamp1, 'America/Los_Angeles'),
-  CAST(to_utc_timestamp(ctimestamp1, 'America/Los_Angeles') AS STRING)
+  to_utc_timestamp(ctimestamp1, 'America/Los_Angeles') AS toutc,
+  CAST(to_utc_timestamp(ctimestamp1, 'America/Los_Angeles') AS STRING) as cst
 FROM alltypesorc
+ORDER BY toutc, cst
 LIMIT 40;
 
 SET hive.vectorized.execution.enabled = true;

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/alter_merge_2_orc.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/alter_merge_2_orc.q.out 
b/ql/src/test/results/clientpositive/alter_merge_2_orc.q.out
index 1ccae8e..7e30942 100644
--- a/ql/src/test/results/clientpositive/alter_merge_2_orc.q.out
+++ b/ql/src/test/results/clientpositive/alter_merge_2_orc.q.out
@@ -31,31 +31,31 @@ ds                          string
 ts                     string                                      
                 
 #### A masked pattern was here ####
-PREHOOK: query: insert overwrite table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src
+PREHOOK: query: insert overwrite table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src order by 
key, value
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
-POSTHOOK: query: insert overwrite table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src
+POSTHOOK: query: insert overwrite table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src order by 
key, value
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
 POSTHOOK: Lineage: src_orc_merge_test_part 
PARTITION(ds=2012-01-03,ts=2012-01-03+14:46:31).key EXPRESSION 
[(src)src.FieldSchema(name:key, type:string, comment:default), ]
 POSTHOOK: Lineage: src_orc_merge_test_part 
PARTITION(ds=2012-01-03,ts=2012-01-03+14:46:31).value SIMPLE 
[(src)src.FieldSchema(name:value, type:string, comment:default), ]
-PREHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src limit 100
+PREHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src order by 
key, value limit 100
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
-POSTHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src limit 100
+POSTHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src order by 
key, value limit 100
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
 POSTHOOK: Lineage: src_orc_merge_test_part 
PARTITION(ds=2012-01-03,ts=2012-01-03+14:46:31).key EXPRESSION 
[(src)src.FieldSchema(name:key, type:string, comment:default), ]
 POSTHOOK: Lineage: src_orc_merge_test_part 
PARTITION(ds=2012-01-03,ts=2012-01-03+14:46:31).value SIMPLE 
[(src)src.FieldSchema(name:value, type:string, comment:default), ]
-PREHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src limit 10
+PREHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src order by 
key, value limit 10
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src
 PREHOOK: Output: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
-POSTHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src limit 10
+POSTHOOK: query: insert into table src_orc_merge_test_part 
partition(ds='2012-01-03', ts='2012-01-03+14:46:31') select * from src order by 
key, value limit 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 POSTHOOK: Output: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
@@ -82,7 +82,7 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src_orc_merge_test_part
 POSTHOOK: Input: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
 #### A masked pattern was here ####
-159653 47778930280
+143807 50348357904
 PREHOOK: query: alter table src_orc_merge_test_part partition 
(ds='2012-01-03', ts='2012-01-03+14:46:31') concatenate
 PREHOOK: type: ALTER_PARTITION_MERGE
 PREHOOK: Input: default@src_orc_merge_test_part
@@ -112,7 +112,7 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src_orc_merge_test_part
 POSTHOOK: Input: 
default@src_orc_merge_test_part@ds=2012-01-03/ts=2012-01-03+14%3A46%3A31
 #### A masked pattern was here ####
-159653 47778930280
+143807 50348357904
 PREHOOK: query: drop table src_orc_merge_test_part
 PREHOOK: type: DROPTABLE
 PREHOOK: Input: default@src_orc_merge_test_part

http://git-wip-us.apache.org/repos/asf/hive/blob/6fdd9cdd/ql/src/test/results/clientpositive/auto_join0.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/auto_join0.q.out 
b/ql/src/test/results/clientpositive/auto_join0.q.out
index b0118ce..10859b8 100644
--- a/ql/src/test/results/clientpositive/auto_join0.q.out
+++ b/ql/src/test/results/clientpositive/auto_join0.q.out
@@ -1,41 +1,49 @@
-Warning: Map Join MAPJOIN[24][bigTable=?] in task 'Stage-2:MAPRED' is a cross 
product
-PREHOOK: query: explain 
+Warning: Map Join MAPJOIN[45][bigTable=?] in task 'Stage-7:MAPRED' is a cross 
product
+Warning: Map Join MAPJOIN[38][bigTable=?] in task 'Stage-6:MAPRED' is a cross 
product
+Warning: Shuffle Join JOIN[12][tables = [src1, src2]] in Stage 
'Stage-2: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
 STAGE DEPENDENCIES:
-  Stage-6 is a root stage
-  Stage-2 depends on stages: Stage-6
-  Stage-3 depends on stages: Stage-2
-  Stage-0 depends on stages: Stage-3
+  Stage-1 is a root stage
+  Stage-8 depends on stages: Stage-1, Stage-5 , consists of Stage-9, Stage-10, 
Stage-2
+  Stage-9 has a backup stage: Stage-2
+  Stage-6 depends on stages: Stage-9
+  Stage-3 depends on stages: Stage-2, Stage-6, Stage-7
+  Stage-4 depends on stages: Stage-3
+  Stage-10 has a backup stage: Stage-2
+  Stage-7 depends on stages: Stage-10
+  Stage-2
+  Stage-5 is a root stage
+  Stage-0 depends on stages: Stage-4
 
 STAGE PLANS:
-  Stage: Stage-6
-    Map Reduce Local Work
-      Alias -> Map Local Tables:
-        a:src1:src 
-          Fetch Operator
-            limit: -1
-      Alias -> Map Local Operator Tree:
-        a:src1:src 
+  Stage: Stage-1
+    Map Reduce
+      Map Operator Tree:
           TableScan
             alias: src
             Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
@@ -46,38 +54,68 @@ 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
-                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
+      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
+          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
+  Stage: Stage-8
+    Conditional Operator
+
+  Stage: Stage-9
+    Map Reduce Local Work
+      Alias -> Map Local Tables:
+        a:$INTNAME1 
+          Fetch Operator
+            limit: -1
+      Alias -> Map Local Operator Tree:
+        a:$INTNAME1 
+          TableScan
+            HashTable Sink Operator
+              keys:
+                0 
+                1 
+
+  Stage: Stage-6
     Map Reduce
       Map Operator Tree:
           TableScan
-            alias: src
-            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
-            Filter Operator
-              predicate: (key < 10) (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
-                Map Join Operator
-                  condition map:
-                       Inner Join 0 to 1
-                  keys:
-                    0 
-                    1 
-                  outputColumnNames: _col0, _col1, _col2, _col3
-                  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
+            Map Join Operator
+              condition map:
+                   Inner Join 0 to 1
+              keys:
+                0 
+                1 
+              outputColumnNames: _col0, _col1, _col2, _col3
+              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
       Local Work:
         Map Reduce Local Work
+
+  Stage: Stage-3
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            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 Operator Tree:
         Select Operator
           expressions: KEY.reducesinkkey0 (type: string), KEY.reducesinkkey1 
(type: string), KEY.reducesinkkey2 (type: string), KEY.reducesinkkey3 (type: 
string)
@@ -95,7 +133,7 @@ STAGE PLANS:
                   output format: 
org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
                   serde: 
org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe
 
-  Stage: Stage-3
+  Stage: Stage-4
     Map Reduce
       Map Operator Tree:
           TableScan
@@ -117,20 +155,115 @@ STAGE PLANS:
                 output format: 
org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
                 serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
 
+  Stage: Stage-10
+    Map Reduce Local Work
+      Alias -> Map Local Tables:
+        a:$INTNAME 
+          Fetch Operator
+            limit: -1
+      Alias -> Map Local Operator Tree:
+        a:$INTNAME 
+          TableScan
+            HashTable Sink Operator
+              keys:
+                0 
+                1 
+
+  Stage: Stage-7
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            Map Join Operator
+              condition map:
+                   Inner Join 0 to 1
+              keys:
+                0 
+                1 
+              outputColumnNames: _col0, _col1, _col2, _col3
+              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
+      Local Work:
+        Map Reduce Local Work
+
+  Stage: Stage-2
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            Reduce Output Operator
+              sort order: 
+              Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE 
Column stats: NONE
+              value expressions: _col0 (type: string), _col1 (type: string)
+          TableScan
+            Reduce Output Operator
+              sort order: 
+              Statistics: Num rows: 166 Data size: 1763 Basic stats: COMPLETE 
Column stats: NONE
+              value expressions: _col0 (type: string), _col1 (type: string)
+      Reduce Operator Tree:
+        Join Operator
+          condition map:
+               Inner Join 0 to 1
+          keys:
+            0 
+            1 
+          outputColumnNames: _col0, _col1, _col2, _col3
+          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-5
+    Map Reduce
+      Map Operator Tree:
+          TableScan
+            alias: src
+            Statistics: Num rows: 500 Data size: 5312 Basic stats: COMPLETE 
Column stats: NONE
+            Filter Operator
+              predicate: (key < 10) (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: ++
+                  Statistics: Num rows: 166 Data size: 1763 Basic stats: 
COMPLETE Column stats: NONE
+      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
+          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
       Processor Tree:
         ListSink
 
-Warning: Map Join MAPJOIN[24][bigTable=?] in task 'Stage-2:MAPRED' is a cross 
product
+Warning: Map Join MAPJOIN[45][bigTable=?] in task 'Stage-7:MAPRED' is a cross 
product
+Warning: Map Join MAPJOIN[38][bigTable=?] in task 'Stage-6:MAPRED' is a cross 
product
+Warning: Shuffle Join JOIN[12][tables = [src1, src2]] in Stage 
'Stage-2: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
@@ -140,9 +273,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/auto_join1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/auto_join1.q.out 
b/ql/src/test/results/clientpositive/auto_join1.q.out
index 5fb0b6f..48ad641 100644
--- a/ql/src/test/results/clientpositive/auto_join1.q.out
+++ b/ql/src/test/results/clientpositive/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/auto_sortmerge_join_5.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/auto_sortmerge_join_5.q.out 
b/ql/src/test/results/clientpositive/auto_sortmerge_join_5.q.out
index 3c2951a..230158b 100644
--- a/ql/src/test/results/clientpositive/auto_sortmerge_join_5.q.out
+++ b/ql/src/test/results/clientpositive/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/cbo_gby.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cbo_gby.q.out 
b/ql/src/test/results/clientpositive/cbo_gby.q.out
index 3dc8914..04597a7 100644
--- a/ql/src/test/results/clientpositive/cbo_gby.q.out
+++ b/ql/src/test/results/clientpositive/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 ####
-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 ####
-NULL   NULL    1
-5.0    2       3
 5.0    12      1
+5.0    2       3
+NULL   NULL    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
@@ -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
@@ -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/cbo_udf_udaf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/cbo_udf_udaf.q.out 
b/ql/src/test/results/clientpositive/cbo_udf_udaf.q.out
index ded043f..156d02f 100644
--- a/ql/src/test/results/clientpositive/cbo_udf_udaf.q.out
+++ b/ql/src/test/results/clientpositive/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

Reply via email to