hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prasan...@apache.org
Subject [3/3] hive git commit: HIVE-14503: Remove explicit order by in qfiles for union tests (Prasanth Jayachandran reviewed by Siddharth Seth, Hari)
Date Sat, 20 Aug 2016 01:38:30 GMT
HIVE-14503: Remove explicit order by in qfiles for union tests (Prasanth Jayachandran reviewed by Siddharth Seth, Hari)


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

Branch: refs/heads/master
Commit: d14673a087370d28383eedbe20d09f0375bea7e7
Parents: 59a9511
Author: Prasanth Jayachandran <prasanthj@apache.org>
Authored: Fri Aug 19 18:38:14 2016 -0700
Committer: Prasanth Jayachandran <prasanthj@apache.org>
Committed: Fri Aug 19 18:38:14 2016 -0700

----------------------------------------------------------------------
 ql/src/test/queries/clientpositive/union32.q    |   3 +-
 ql/src/test/queries/clientpositive/union34.q    |   9 +-
 ql/src/test/queries/clientpositive/union36.q    |   5 +-
 .../queries/clientpositive/unionDistinct_1.q    |  17 +-
 .../queries/clientpositive/union_remove_1.q     |   3 +-
 .../queries/clientpositive/union_remove_10.q    |   3 +-
 .../queries/clientpositive/union_remove_11.q    |   3 +-
 .../queries/clientpositive/union_remove_12.q    |   3 +-
 .../queries/clientpositive/union_remove_13.q    |   3 +-
 .../queries/clientpositive/union_remove_14.q    |   3 +-
 .../queries/clientpositive/union_remove_15.q    |   5 +-
 .../queries/clientpositive/union_remove_16.q    |   5 +-
 .../queries/clientpositive/union_remove_17.q    |   5 +-
 .../queries/clientpositive/union_remove_18.q    |   7 +-
 .../queries/clientpositive/union_remove_19.q    |   3 +-
 .../queries/clientpositive/union_remove_2.q     |   3 +-
 .../queries/clientpositive/union_remove_20.q    |   3 +-
 .../queries/clientpositive/union_remove_21.q    |   3 +-
 .../queries/clientpositive/union_remove_22.q    |   2 +-
 .../queries/clientpositive/union_remove_23.q    |   3 +-
 .../queries/clientpositive/union_remove_24.q    |   3 +-
 .../queries/clientpositive/union_remove_25.q    |   3 +-
 .../queries/clientpositive/union_remove_26.q    |   2 +-
 .../queries/clientpositive/union_remove_3.q     |   3 +-
 .../queries/clientpositive/union_remove_4.q     |   3 +-
 .../queries/clientpositive/union_remove_5.q     |   3 +-
 .../queries/clientpositive/union_remove_6.q     |   5 +-
 .../clientpositive/union_remove_6_subq.q        |   4 +-
 .../queries/clientpositive/union_remove_7.q     |   3 +-
 .../queries/clientpositive/union_remove_8.q     |   3 +-
 .../queries/clientpositive/union_remove_9.q     |   3 +-
 .../test/queries/clientpositive/union_script.q  |   5 +-
 .../queries/clientpositive/union_type_chk.q     |   6 +-
 ql/src/test/queries/clientpositive/union_view.q |   5 +-
 .../results/clientpositive/spark/union32.q.out  |  37 ++---
 .../results/clientpositive/spark/union34.q.out  | 115 ++++++--------
 .../clientpositive/spark/union_remove_1.q.out   |  10 +-
 .../clientpositive/spark/union_remove_10.q.out  |  10 +-
 .../clientpositive/spark/union_remove_11.q.out  |  10 +-
 .../clientpositive/spark/union_remove_12.q.out  |  10 +-
 .../clientpositive/spark/union_remove_13.q.out  |  12 +-
 .../clientpositive/spark/union_remove_14.q.out  |  10 +-
 .../clientpositive/spark/union_remove_15.q.out  |  14 +-
 .../clientpositive/spark/union_remove_16.q.out  |  14 +-
 .../clientpositive/spark/union_remove_17.q.out  |  14 +-
 .../clientpositive/spark/union_remove_18.q.out  |  18 ++-
 .../clientpositive/spark/union_remove_19.q.out  |  10 +-
 .../clientpositive/spark/union_remove_2.q.out   |  10 +-
 .../clientpositive/spark/union_remove_20.q.out  |  10 +-
 .../clientpositive/spark/union_remove_21.q.out  |  10 +-
 .../clientpositive/spark/union_remove_22.q.out  |   4 +-
 .../clientpositive/spark/union_remove_23.q.out  |  10 +-
 .../clientpositive/spark/union_remove_24.q.out  |  10 +-
 .../clientpositive/spark/union_remove_25.q.out  |  10 +-
 .../clientpositive/spark/union_remove_3.q.out   |  10 +-
 .../clientpositive/spark/union_remove_4.q.out   |  10 +-
 .../clientpositive/spark/union_remove_5.q.out   |  10 +-
 .../clientpositive/spark/union_remove_6.q.out   |  14 +-
 .../spark/union_remove_6_subq.q.out             |   8 +-
 .../clientpositive/spark/union_remove_7.q.out   |  10 +-
 .../clientpositive/spark/union_remove_8.q.out   |  10 +-
 .../clientpositive/spark/union_remove_9.q.out   |  10 +-
 .../clientpositive/spark/union_script.q.out     |  14 +-
 .../clientpositive/spark/union_view.q.out       |  63 ++++----
 .../clientpositive/tez/unionDistinct_1.q.out    | 154 ++++++-------------
 .../clientpositive/tez/union_type_chk.q.out     |  18 ++-
 .../test/results/clientpositive/union32.q.out   |  32 ++--
 .../test/results/clientpositive/union34.q.out   | 106 ++++++-------
 .../test/results/clientpositive/union36.q.out   |  18 ++-
 .../clientpositive/unionDistinct_1.q.out        | 132 +++-------------
 .../results/clientpositive/union_remove_1.q.out |  10 +-
 .../clientpositive/union_remove_10.q.out        |  10 +-
 .../clientpositive/union_remove_11.q.out        |  10 +-
 .../clientpositive/union_remove_12.q.out        |  10 +-
 .../clientpositive/union_remove_13.q.out        |  12 +-
 .../clientpositive/union_remove_14.q.out        |  10 +-
 .../clientpositive/union_remove_15.q.out        |  14 +-
 .../clientpositive/union_remove_16.q.out        |  14 +-
 .../clientpositive/union_remove_17.q.out        |  14 +-
 .../clientpositive/union_remove_18.q.out        |  18 ++-
 .../clientpositive/union_remove_19.q.out        |  10 +-
 .../results/clientpositive/union_remove_2.q.out |  10 +-
 .../clientpositive/union_remove_20.q.out        |  10 +-
 .../clientpositive/union_remove_21.q.out        |  10 +-
 .../clientpositive/union_remove_22.q.out        |   4 +-
 .../clientpositive/union_remove_23.q.out        |  10 +-
 .../clientpositive/union_remove_24.q.out        |  10 +-
 .../clientpositive/union_remove_25.q.out        |  10 +-
 .../results/clientpositive/union_remove_3.q.out |  10 +-
 .../results/clientpositive/union_remove_4.q.out |  10 +-
 .../results/clientpositive/union_remove_5.q.out |  10 +-
 .../results/clientpositive/union_remove_6.q.out |  14 +-
 .../clientpositive/union_remove_6_subq.q.out    |   8 +-
 .../results/clientpositive/union_remove_7.q.out |  10 +-
 .../results/clientpositive/union_remove_8.q.out |  10 +-
 .../results/clientpositive/union_remove_9.q.out |  10 +-
 .../results/clientpositive/union_script.q.out   |  14 +-
 .../results/clientpositive/union_type_chk.q.out |  18 ++-
 .../results/clientpositive/union_view.q.out     |  54 +++----
 99 files changed, 700 insertions(+), 773 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union32.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union32.q b/ql/src/test/queries/clientpositive/union32.q
index f47f0af..b18d484 100644
--- a/ql/src/test/queries/clientpositive/union32.q
+++ b/ql/src/test/queries/clientpositive/union32.q
@@ -12,8 +12,7 @@ EXPLAIN
 SELECT * FROM 
 (SELECT CAST(key AS DOUBLE) AS key FROM t1
 UNION ALL
-SELECT CAST(key AS BIGINT) AS key FROM t2) a
-ORDER BY key;
+SELECT CAST(key AS BIGINT) AS key FROM t2) a;
 
 SELECT * FROM 
 (SELECT CAST(key AS DOUBLE) AS key FROM t1

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union34.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union34.q b/ql/src/test/queries/clientpositive/union34.q
index 2ab16de..dbefc40 100644
--- a/ql/src/test/queries/clientpositive/union34.q
+++ b/ql/src/test/queries/clientpositive/union34.q
@@ -1,4 +1,5 @@
 set hive.mapred.mode=nonstrict;
+-- SORT_QUERY_RESULTS
 create table src10_1 (key string, value string);
 create table src10_2 (key string, value string);
 create table src10_3 (key string, value string);
@@ -18,13 +19,13 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;
 
 SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;
 
 set hive.auto.convert.join=false;
 -- When we do not convert the Join of sub1 and sub0 into a MapJoin,
@@ -36,10 +37,10 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;
 
 SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union36.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union36.q b/ql/src/test/queries/clientpositive/union36.q
index c38e7b1..b79ff0f 100644
--- a/ql/src/test/queries/clientpositive/union36.q
+++ b/ql/src/test/queries/clientpositive/union36.q
@@ -1,9 +1,10 @@
 set hive.mapred.mode=nonstrict;
 set hive.cbo.enable=false;
 
-select (x/sum(x) over())  as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select '100000000' x from (select * from src limit 2) s3)u order by y;
+-- SORT_QUERY_RESULTS
+select (x/sum(x) over())  as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select '100000000' x from (select * from src limit 2) s3)u;
 
-select (x/sum(x) over()) as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select cast (null as string) x from (select * from src limit 2) s3)u order by y;
+select (x/sum(x) over()) as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select cast (null as string) x from (select * from src limit 2) s3)u;
 
 
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/unionDistinct_1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/unionDistinct_1.q b/ql/src/test/queries/clientpositive/unionDistinct_1.q
index 0d53a96..5c52d9b 100644
--- a/ql/src/test/queries/clientpositive/unionDistinct_1.q
+++ b/ql/src/test/queries/clientpositive/unionDistinct_1.q
@@ -386,16 +386,14 @@ from (
   select transform(key, value) using 'cat' as (key2, value2)
   from src
   UNION DISTINCT 
-  select key as key2, value as value2 from src) s
-order by s.key2, s.value2;
+  select key as key2, value as value2 from src) s;
 
 select s.key2, s.value2
 from (
   select transform(key, value) using 'cat' as (key2, value2)
   from src
   UNION DISTINCT 
-  select key as key2, value as value2 from src) s
-order by s.key2, s.value2;
+  select key as key2, value as value2 from src) s;
 
 -- union24.q
 
@@ -874,8 +872,7 @@ EXPLAIN
 SELECT * FROM 
 (SELECT CAST(key AS DOUBLE) AS key FROM t1
 UNION DISTINCT
-SELECT CAST(key AS BIGINT) AS key FROM t2) a
-ORDER BY key;
+SELECT CAST(key AS BIGINT) AS key FROM t2) a;
 
 SELECT * FROM 
 (SELECT CAST(key AS DOUBLE) AS key FROM t1
@@ -1013,13 +1010,13 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION DISTINCT
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;
 
 SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION DISTINCT
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;
 
 set hive.auto.convert.join=false;
 -- When we do not convert the Join of sub1 and sub0 into a MapJoin,
@@ -1031,13 +1028,13 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION DISTINCT
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;
 
 SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION DISTINCT
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION DISTINCT SELECT * FROM src10_4 ) alias0
-) alias1 order by key;
+) alias1;
 -- union4.q
 
  

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_1.q b/ql/src/test/queries/clientpositive/union_remove_1.q
index 702f71a..0a69068 100644
--- a/ql/src/test/queries/clientpositive/union_remove_1.q
+++ b/ql/src/test/queries/clientpositive/union_remove_1.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -42,4 +43,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_10.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_10.q b/ql/src/test/queries/clientpositive/union_remove_10.q
index 508f354..7892e15 100644
--- a/ql/src/test/queries/clientpositive/union_remove_10.q
+++ b/ql/src/test/queries/clientpositive/union_remove_10.q
@@ -8,6 +8,7 @@ set hive.merge.mapredfiles=true;
 set hive.merge.smallfiles.avgsize=1;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a nested union where one of the sub-queries requires a map-reduce
@@ -55,4 +56,4 @@ select * FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_11.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_11.q b/ql/src/test/queries/clientpositive/union_remove_11.q
index bdfbf66..fd41648 100644
--- a/ql/src/test/queries/clientpositive/union_remove_11.q
+++ b/ql/src/test/queries/clientpositive/union_remove_11.q
@@ -8,6 +8,7 @@ set hive.merge.mapredfiles=true;
 set hive.merge.smallfiles.avgsize=1;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a nested union where also contains map only sub-queries),
@@ -55,4 +56,4 @@ select * FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_12.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_12.q b/ql/src/test/queries/clientpositive/union_remove_12.q
index f6436f5..b665666 100644
--- a/ql/src/test/queries/clientpositive/union_remove_12.q
+++ b/ql/src/test/queries/clientpositive/union_remove_12.q
@@ -9,6 +9,7 @@ set hive.merge.mapredfiles=true;
 set hive.merge.smallfiles.avgsize=1;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one is a map-join query), followed by select star and a file sink.
@@ -49,4 +50,4 @@ FROM inputTbl1 a join inputTbl1 b on a.key=b.key
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_13.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_13.q b/ql/src/test/queries/clientpositive/union_remove_13.q
index b02451b..11077fd 100644
--- a/ql/src/test/queries/clientpositive/union_remove_13.q
+++ b/ql/src/test/queries/clientpositive/union_remove_13.q
@@ -9,6 +9,7 @@ set hive.merge.mapredfiles=true;
 set hive.merge.smallfiles.avgsize=1;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a mapred query, and the
 -- other one is a map-join query), followed by select star and a file sink.
@@ -49,4 +50,4 @@ FROM inputTbl1 a join inputTbl1 b on a.key=b.key
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_14.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_14.q b/ql/src/test/queries/clientpositive/union_remove_14.q
index bec6226..b559b35 100644
--- a/ql/src/test/queries/clientpositive/union_remove_14.q
+++ b/ql/src/test/queries/clientpositive/union_remove_14.q
@@ -9,6 +9,7 @@ set hive.auto.convert.join=true;
 set hive.merge.smallfiles.avgsize=1;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a join, which should be performed as a map-join query at runtime),
@@ -50,4 +51,4 @@ FROM inputTbl1 a join inputTbl1 b on a.key=b.key
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_15.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_15.q b/ql/src/test/queries/clientpositive/union_remove_15.q
index e384739..43c7834 100644
--- a/ql/src/test/queries/clientpositive/union_remove_15.q
+++ b/ql/src/test/queries/clientpositive/union_remove_15.q
@@ -10,6 +10,7 @@ set hive.exec.dynamic.partition.mode=nonstrict;
 set hive.exec.dynamic.partition=true;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
@@ -50,5 +51,5 @@ desc formatted outputTbl1;
 show partitions outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 where ds = '1' order by key, `values`;
-select * from outputTbl1 where ds = '2' order by key, `values`;
+select * from outputTbl1 where ds = '1';
+select * from outputTbl1 where ds = '2';

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_16.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_16.q b/ql/src/test/queries/clientpositive/union_remove_16.q
index 41305bf..eca8aeb 100644
--- a/ql/src/test/queries/clientpositive/union_remove_16.q
+++ b/ql/src/test/queries/clientpositive/union_remove_16.q
@@ -11,6 +11,7 @@ set mapred.input.dir.recursive=true;
 set hive.exec.dynamic.partition.mode=nonstrict;
 set hive.exec.dynamic.partition=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
@@ -49,5 +50,5 @@ desc formatted outputTbl1;
 show partitions outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 where ds = '1' order by key, `values`;
-select * from outputTbl1 where ds = '2' order by key, `values`;
+select * from outputTbl1 where ds = '1';
+select * from outputTbl1 where ds = '2';

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_17.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_17.q b/ql/src/test/queries/clientpositive/union_remove_17.q
index 8f91d03..59a3a9c 100644
--- a/ql/src/test/queries/clientpositive/union_remove_17.q
+++ b/ql/src/test/queries/clientpositive/union_remove_17.q
@@ -10,6 +10,7 @@ set hive.exec.dynamic.partition.mode=nonstrict;
 set hive.exec.dynamic.partition=true;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
@@ -46,5 +47,5 @@ desc formatted outputTbl1;
 show partitions outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 where ds = '1' order by key, `values`;
-select * from outputTbl1 where ds = '2' order by key, `values`;
+select * from outputTbl1 where ds = '1';
+select * from outputTbl1 where ds = '2';

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_18.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_18.q b/ql/src/test/queries/clientpositive/union_remove_18.q
index ad38742..98ee7d0 100644
--- a/ql/src/test/queries/clientpositive/union_remove_18.q
+++ b/ql/src/test/queries/clientpositive/union_remove_18.q
@@ -10,6 +10,7 @@ set hive.exec.dynamic.partition.mode=nonstrict;
 set hive.exec.dynamic.partition=true;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -49,6 +50,6 @@ desc formatted outputTbl1;
 show partitions outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 where ds = '11' order by key, `values`;
-select * from outputTbl1 where ds = '18' order by key, `values`;
-select * from outputTbl1 where ds is not null order by key, `values`, ds;
+select * from outputTbl1 where ds = '11';
+select * from outputTbl1 where ds = '18';
+select * from outputTbl1 where ds is not null;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_19.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_19.q b/ql/src/test/queries/clientpositive/union_remove_19.q
index 34f8b5a..9e47254 100644
--- a/ql/src/test/queries/clientpositive/union_remove_19.q
+++ b/ql/src/test/queries/clientpositive/union_remove_19.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -90,4 +91,4 @@ FROM (
 ) b where b.key >= 7;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_2.q b/ql/src/test/queries/clientpositive/union_remove_2.q
index 274608c..2ebc1ad 100644
--- a/ql/src/test/queries/clientpositive/union_remove_2.q
+++ b/ql/src/test/queries/clientpositive/union_remove_2.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 3 subqueries is performed (exactly one of which requires a map-reduce job)
 -- followed by select star and a file sink.
@@ -47,5 +48,5 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_20.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_20.q b/ql/src/test/queries/clientpositive/union_remove_20.q
index 93a49f3..700ee4d 100644
--- a/ql/src/test/queries/clientpositive/union_remove_20.q
+++ b/ql/src/test/queries/clientpositive/union_remove_20.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select and a file sink
 -- However, the order of the columns in the select list is different. So, union cannot
@@ -43,4 +44,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_21.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_21.q b/ql/src/test/queries/clientpositive/union_remove_21.q
index fa8ff27..1b1472e 100644
--- a/ql/src/test/queries/clientpositive/union_remove_21.q
+++ b/ql/src/test/queries/clientpositive/union_remove_21.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select and a file sink
 -- However, all the columns are not selected. So, union cannot
@@ -43,4 +44,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_22.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_22.q b/ql/src/test/queries/clientpositive/union_remove_22.q
index 0e97cae..d4d3cbc 100644
--- a/ql/src/test/queries/clientpositive/union_remove_22.q
+++ b/ql/src/test/queries/clientpositive/union_remove_22.q
@@ -63,4 +63,4 @@ FROM (
 ) a;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_23.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_23.q b/ql/src/test/queries/clientpositive/union_remove_23.q
index 436719d..98ae503 100644
--- a/ql/src/test/queries/clientpositive/union_remove_23.q
+++ b/ql/src/test/queries/clientpositive/union_remove_23.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -45,4 +46,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_24.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_24.q b/ql/src/test/queries/clientpositive/union_remove_24.q
index 3a1e225..7ed80d1 100644
--- a/ql/src/test/queries/clientpositive/union_remove_24.q
+++ b/ql/src/test/queries/clientpositive/union_remove_24.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -41,4 +42,4 @@ SELECT * FROM
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_25.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_25.q b/ql/src/test/queries/clientpositive/union_remove_25.q
index d70adb9..78fa9aa 100644
--- a/ql/src/test/queries/clientpositive/union_remove_25.q
+++ b/ql/src/test/queries/clientpositive/union_remove_25.q
@@ -8,6 +8,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -45,7 +46,7 @@ FROM (
 desc formatted outputTbl1 partition(ds='2004');
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;
 
 explain 
 insert overwrite table outputTbl2 partition(ds)

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_26.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_26.q b/ql/src/test/queries/clientpositive/union_remove_26.q
index d35d4e2..4e77d73 100644
--- a/ql/src/test/queries/clientpositive/union_remove_26.q
+++ b/ql/src/test/queries/clientpositive/union_remove_26.q
@@ -108,4 +108,4 @@ select count(*) from (
   UNION ALL
   SELECT count(1) as rowcnt, min(val) as ms, max(val) as mx from inputTbl2
   UNION ALL
-  SELECT count(1) as rowcnt, min(val) as ms, max(val) as mx from inputTbl3) t;
\ No newline at end of file
+  SELECT count(1) as rowcnt, min(val) as ms, max(val) as mx from inputTbl3) t;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_3.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_3.q b/ql/src/test/queries/clientpositive/union_remove_3.q
index 2e6e3e6..b0f63fc 100644
--- a/ql/src/test/queries/clientpositive/union_remove_3.q
+++ b/ql/src/test/queries/clientpositive/union_remove_3.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->remove->filesink optimization
 -- Union of 3 subqueries is performed (all of which are map-only queries)
 -- followed by select star and a file sink.
@@ -47,5 +48,5 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_4.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_4.q b/ql/src/test/queries/clientpositive/union_remove_4.q
index a08bcc1..9ee6282 100644
--- a/ql/src/test/queries/clientpositive/union_remove_4.q
+++ b/ql/src/test/queries/clientpositive/union_remove_4.q
@@ -8,6 +8,7 @@ set hive.merge.mapredfiles=true;
 set mapred.input.dir.recursive=true;
 set hive.merge.smallfiles.avgsize=1;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -43,4 +44,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_5.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_5.q b/ql/src/test/queries/clientpositive/union_remove_5.q
index 4ac3edf..5d3c482 100644
--- a/ql/src/test/queries/clientpositive/union_remove_5.q
+++ b/ql/src/test/queries/clientpositive/union_remove_5.q
@@ -8,6 +8,7 @@ set hive.merge.mapredfiles=true;
 set hive.merge.smallfiles.avgsize=1;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 3 subqueries is performed (exactly one of which requires a map-reduce job)
 -- followed by select star and a file sink.
@@ -49,4 +50,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_6.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_6.q b/ql/src/test/queries/clientpositive/union_remove_6.q
index f37f409..23eb760 100644
--- a/ql/src/test/queries/clientpositive/union_remove_6.q
+++ b/ql/src/test/queries/clientpositive/union_remove_6.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (all of which are mapred queries)
 -- followed by select star and a file sink in 2 output tables.
@@ -38,5 +39,5 @@ insert overwrite table outputTbl1 select *
 insert overwrite table outputTbl2 select *;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
-select * from outputTbl2 order by key, `values`;;
+select * from outputTbl1;
+select * from outputTbl2;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_6_subq.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_6_subq.q b/ql/src/test/queries/clientpositive/union_remove_6_subq.q
index 6853728..3607a52 100644
--- a/ql/src/test/queries/clientpositive/union_remove_6_subq.q
+++ b/ql/src/test/queries/clientpositive/union_remove_6_subq.q
@@ -43,8 +43,8 @@ insert overwrite table outputTbl1 select *
 insert overwrite table outputTbl2 select *;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
-select * from outputTbl2 order by key, `values`;
+select * from outputTbl1;
+select * from outputTbl2;
 
 -- The following queries guarantee the correctness.
 explain

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_7.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_7.q b/ql/src/test/queries/clientpositive/union_remove_7.q
index cd6a75a..5e0d14b 100644
--- a/ql/src/test/queries/clientpositive/union_remove_7.q
+++ b/ql/src/test/queries/clientpositive/union_remove_7.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -44,4 +45,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_8.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_8.q b/ql/src/test/queries/clientpositive/union_remove_8.q
index 93aabe6..1e049ba 100644
--- a/ql/src/test/queries/clientpositive/union_remove_8.q
+++ b/ql/src/test/queries/clientpositive/union_remove_8.q
@@ -7,6 +7,7 @@ set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 3 subqueries is performed (exactly one of which requires a map-reduce job)
 -- followed by select star and a file sink.
@@ -49,4 +50,4 @@ FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_remove_9.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_remove_9.q b/ql/src/test/queries/clientpositive/union_remove_9.q
index 1bb8d6d..b819560 100644
--- a/ql/src/test/queries/clientpositive/union_remove_9.q
+++ b/ql/src/test/queries/clientpositive/union_remove_9.q
@@ -8,6 +8,7 @@ set hive.merge.mapredfiles=true;
 set hive.merge.smallfiles.avgsize=1;
 set mapred.input.dir.recursive=true;
 
+-- SORT_QUERY_RESULTS
 -- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which contains a union and is map-only),
 -- and the other one is a map-reduce query followed by select star and a file sink.
@@ -53,4 +54,4 @@ select * FROM (
 desc formatted outputTbl1;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-select * from outputTbl1 order by key, `values`;
+select * from outputTbl1;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_script.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_script.q b/ql/src/test/queries/clientpositive/union_script.q
index 7687104..e5b160f 100644
--- a/ql/src/test/queries/clientpositive/union_script.q
+++ b/ql/src/test/queries/clientpositive/union_script.q
@@ -1,8 +1,9 @@
 set hive.mapred.mode=nonstrict;
+-- SORT_QUERY_RESULTS
 select * from (
-  select transform(key) using 'cat' as cola from src)s order by cola;
+  select transform(key) using 'cat' as cola from src)s;
 
 select * from (
   select transform(key) using 'cat' as cola from src
   union all
-  select transform(key) using 'cat' as cola from src) s order by cola;
+  select transform(key) using 'cat' as cola from src) s;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_type_chk.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_type_chk.q b/ql/src/test/queries/clientpositive/union_type_chk.q
index a25aeda..ff2e7cf 100644
--- a/ql/src/test/queries/clientpositive/union_type_chk.q
+++ b/ql/src/test/queries/clientpositive/union_type_chk.q
@@ -1,7 +1,7 @@
 set hive.mapred.mode=nonstrict;
 set hive.cbo.enable=false;
-set hive.mapred.mode=nonstrict;
 
-select (x/sum(x) over())  as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select '100000000' x from (select * from src limit 2) s3)u order by y;
+-- SORT_QUERY_RESULTS
+select (x/sum(x) over())  as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select '100000000' x from (select * from src limit 2) s3)u;
 
-select (x/sum(x) over()) as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select cast (null as string) x from (select * from src limit 2) s3)u order by y;
+select (x/sum(x) over()) as y from(select cast(1 as decimal(10,0))  as x from (select * from src limit 2)s1 union all select cast(1 as decimal(10,0)) x from (select * from src limit 2) s2 union all select cast (null as string) x from (select * from src limit 2) s3)u;

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/queries/clientpositive/union_view.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/union_view.q b/ql/src/test/queries/clientpositive/union_view.q
index fa39450..c4f63e6 100644
--- a/ql/src/test/queries/clientpositive/union_view.q
+++ b/ql/src/test/queries/clientpositive/union_view.q
@@ -63,12 +63,13 @@ SELECT key, value, ds FROM src_union_3
 EXPLAIN SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds ='1';
 EXPLAIN SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds ='2';
 EXPLAIN SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds ='3';
-EXPLAIN SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds IS NOT NULL order by ds;
+EXPLAIN SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds IS NOT NULL;
 
 SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds ='1';
 SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds ='2';
 SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds ='3';
-SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds IS NOT NULL order by ds;
+-- SORT_BEFORE_DIFF
+SELECT key, value, ds FROM src_union_view WHERE key=86 AND ds IS NOT NULL;
 
 EXPLAIN SELECT count(1) from src_union_view WHERE ds ='1';
 EXPLAIN SELECT count(1) from src_union_view WHERE ds ='2';

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union32.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union32.q.out b/ql/src/test/results/clientpositive/spark/union32.q.out
index 09fb01e..16cb243 100644
--- a/ql/src/test/results/clientpositive/spark/union32.q.out
+++ b/ql/src/test/results/clientpositive/spark/union32.q.out
@@ -38,7 +38,6 @@ SELECT * FROM
 (SELECT CAST(key AS DOUBLE) AS key FROM t1
 UNION ALL
 SELECT CAST(key AS BIGINT) AS key FROM t2) a
-ORDER BY key
 PREHOOK: type: QUERY
 POSTHOOK: query: -- Test simple union with double
 EXPLAIN
@@ -46,7 +45,6 @@ SELECT * FROM
 (SELECT CAST(key AS DOUBLE) AS key FROM t1
 UNION ALL
 SELECT CAST(key AS BIGINT) AS key FROM t2) a
-ORDER BY key
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -55,8 +53,6 @@ STAGE DEPENDENCIES:
 STAGE PLANS:
   Stage: Stage-1
     Spark
-      Edges:
-        Reducer 2 <- Map 1 (SORT, 1), Map 3 (SORT, 1)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -68,11 +64,14 @@ STAGE PLANS:
                     expressions: UDFToDouble(key) (type: double)
                     outputColumnNames: _col0
                     Statistics: Num rows: 10 Data size: 70 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col0 (type: double)
-                      sort order: +
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 20 Data size: 140 Basic stats: COMPLETE Column stats: NONE
-        Map 3 
+                      table:
+                          input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                          output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                          serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Map 2 
             Map Operator Tree:
                 TableScan
                   alias: t2
@@ -81,23 +80,13 @@ STAGE PLANS:
                     expressions: UDFToDouble(UDFToLong(key)) (type: double)
                     outputColumnNames: _col0
                     Statistics: Num rows: 10 Data size: 70 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col0 (type: double)
-                      sort order: +
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 20 Data size: 140 Basic stats: COMPLETE Column stats: NONE
-        Reducer 2 
-            Reduce Operator Tree:
-              Select Operator
-                expressions: KEY.reducesinkkey0 (type: double)
-                outputColumnNames: _col0
-                Statistics: Num rows: 20 Data size: 140 Basic stats: COMPLETE Column stats: NONE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 20 Data size: 140 Basic stats: COMPLETE Column stats: NONE
-                  table:
-                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+                      table:
+                          input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                          output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                          serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
 
   Stage: Stage-0
     Fetch Operator

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union34.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union34.q.out b/ql/src/test/results/clientpositive/spark/union34.q.out
index 1a50c3c..c49c436 100644
--- a/ql/src/test/results/clientpositive/spark/union34.q.out
+++ b/ql/src/test/results/clientpositive/spark/union34.q.out
@@ -1,8 +1,10 @@
-PREHOOK: query: create table src10_1 (key string, value string)
+PREHOOK: query: -- SORT_QUERY_RESULTS
+create table src10_1 (key string, value string)
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@src10_1
-POSTHOOK: query: create table src10_1 (key string, value string)
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+create table src10_1 (key string, value string)
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@src10_1
@@ -67,7 +69,7 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 PREHOOK: type: QUERY
 POSTHOOK: query: -- When we convert the Join of sub1 and sub0 into a MapJoin,
 -- we can use a single MR job to evaluate this entire query.
@@ -76,7 +78,7 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-2 is a root stage
@@ -88,7 +90,7 @@ STAGE PLANS:
     Spark
 #### A masked pattern was here ####
       Vertices:
-        Map 3 
+        Map 2 
             Map Operator Tree:
                 TableScan
                   alias: src10_2
@@ -109,8 +111,6 @@ STAGE PLANS:
 
   Stage: Stage-1
     Spark
-      Edges:
-        Reducer 2 <- Map 1 (SORT, 1), Map 4 (SORT, 1), Map 5 (SORT, 1)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -133,16 +133,18 @@ STAGE PLANS:
                           1 _col0 (type: string)
                         outputColumnNames: _col0, _col1
                         input vertices:
-                          1 Map 3
+                          1 Map 2
                         Statistics: Num rows: 11 Data size: 114 Basic stats: COMPLETE Column stats: NONE
-                        Reduce Output Operator
-                          key expressions: _col0 (type: string)
-                          sort order: +
+                        File Output Operator
+                          compressed: false
                           Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                          value expressions: _col1 (type: string)
+                          table:
+                              input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                              output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                              serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
             Local Work:
               Map Reduce Local Work
-        Map 4 
+        Map 3 
             Map Operator Tree:
                 TableScan
                   alias: src10_3
@@ -151,12 +153,14 @@ STAGE PLANS:
                     expressions: key (type: string), value (type: string)
                     outputColumnNames: _col0, _col1
                     Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col0 (type: string)
-                      sort order: +
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col1 (type: string)
-        Map 5 
+                      table:
+                          input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                          output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                          serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Map 4 
             Map Operator Tree:
                 TableScan
                   alias: src10_4
@@ -165,24 +169,13 @@ STAGE PLANS:
                     expressions: key (type: string), value (type: string)
                     outputColumnNames: _col0, _col1
                     Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col0 (type: string)
-                      sort order: +
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col1 (type: string)
-        Reducer 2 
-            Reduce Operator Tree:
-              Select Operator
-                expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                File Output Operator
-                  compressed: false
-                  Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                  table:
-                      input format: org.apache.hadoop.mapred.SequenceFileInputFormat
-                      output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
-                      serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+                      table:
+                          input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                          output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                          serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
 
   Stage: Stage-0
     Fetch Operator
@@ -194,7 +187,7 @@ PREHOOK: query: SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src10_1
 PREHOOK: Input: default@src10_2
@@ -205,7 +198,7 @@ POSTHOOK: query: SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src10_1
 POSTHOOK: Input: default@src10_2
@@ -251,7 +244,7 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 PREHOOK: type: QUERY
 POSTHOOK: query: -- When we do not convert the Join of sub1 and sub0 into a MapJoin,
 -- we need to use two MR jobs to evaluate this query.
@@ -262,7 +255,7 @@ SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 POSTHOOK: type: QUERY
 STAGE DEPENDENCIES:
   Stage-1 is a root stage
@@ -272,8 +265,7 @@ STAGE PLANS:
   Stage: Stage-1
     Spark
       Edges:
-        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 2), Map 4 (PARTITION-LEVEL SORT, 2)
-        Reducer 3 <- Map 5 (SORT, 1), Map 6 (SORT, 1), Reducer 2 (SORT, 1)
+        Reducer 2 <- Map 1 (PARTITION-LEVEL SORT, 2), Map 3 (PARTITION-LEVEL SORT, 2)
 #### A masked pattern was here ####
       Vertices:
         Map 1 
@@ -294,7 +286,7 @@ STAGE PLANS:
                         Map-reduce partition columns: _col0 (type: string)
                         Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
                         value expressions: _col1 (type: string)
-        Map 4 
+        Map 3 
             Map Operator Tree:
                 TableScan
                   alias: src10_2
@@ -311,7 +303,7 @@ STAGE PLANS:
                         sort order: +
                         Map-reduce partition columns: _col0 (type: string)
                         Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
-        Map 5 
+        Map 4 
             Map Operator Tree:
                 TableScan
                   alias: src10_3
@@ -320,12 +312,14 @@ STAGE PLANS:
                     expressions: key (type: string), value (type: string)
                     outputColumnNames: _col0, _col1
                     Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col0 (type: string)
-                      sort order: +
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col1 (type: string)
-        Map 6 
+                      table:
+                          input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                          output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                          serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
+        Map 5 
             Map Operator Tree:
                 TableScan
                   alias: src10_4
@@ -334,11 +328,13 @@ STAGE PLANS:
                     expressions: key (type: string), value (type: string)
                     outputColumnNames: _col0, _col1
                     Statistics: Num rows: 10 Data size: 104 Basic stats: COMPLETE Column stats: NONE
-                    Reduce Output Operator
-                      key expressions: _col0 (type: string)
-                      sort order: +
+                    File Output Operator
+                      compressed: false
                       Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                      value expressions: _col1 (type: string)
+                      table:
+                          input format: org.apache.hadoop.mapred.SequenceFileInputFormat
+                          output format: org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat
+                          serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
         Reducer 2 
             Reduce Operator Tree:
               Join Operator
@@ -346,17 +342,6 @@ STAGE PLANS:
                      Inner Join 0 to 1
                 outputColumnNames: _col0, _col1
                 Statistics: Num rows: 11 Data size: 114 Basic stats: COMPLETE Column stats: NONE
-                Reduce Output Operator
-                  key expressions: _col0 (type: string)
-                  sort order: +
-                  Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
-                  value expressions: _col1 (type: string)
-        Reducer 3 
-            Reduce Operator Tree:
-              Select Operator
-                expressions: KEY.reducesinkkey0 (type: string), VALUE._col0 (type: string)
-                outputColumnNames: _col0, _col1
-                Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
                 File Output Operator
                   compressed: false
                   Statistics: Num rows: 31 Data size: 322 Basic stats: COMPLETE Column stats: NONE
@@ -375,7 +360,7 @@ PREHOOK: query: SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@src10_1
 PREHOOK: Input: default@src10_2
@@ -386,7 +371,7 @@ POSTHOOK: query: SELECT * FROM (
   SELECT sub1.key,sub1.value FROM (SELECT * FROM src10_1) sub1 JOIN (SELECT * FROM src10_2) sub0 ON (sub0.key = sub1.key)
   UNION ALL
   SELECT key,value FROM (SELECT * FROM (SELECT * FROM src10_3) sub2 UNION ALL SELECT * FROM src10_4 ) alias0
-) alias1 order by key
+) alias1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src10_1
 POSTHOOK: Input: default@src10_2

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_1.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_1.q.out b/ql/src/test/results/clientpositive/spark/union_remove_1.q.out
index 6d88345..ff18e4a 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_1.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_1.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
 -- again to process the union. The union can be removed completely.
@@ -12,7 +13,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
 -- again to process the union. The union can be removed completely.
@@ -190,11 +192,11 @@ Bucket Columns:     	[]
 Sort Columns:       	[]                  	 
 Storage Desc Params:	 	 
 	serialization.format	1                   
-PREHOOK: query: select * from outputTbl1 order by key, `values`
+PREHOOK: query: select * from outputTbl1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 order by key, `values`
+POSTHOOK: query: select * from outputTbl1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_10.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_10.q.out b/ql/src/test/results/clientpositive/spark/union_remove_10.q.out
index 7b4b0c4..ded8b40 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_10.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_10.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a nested union where one of the sub-queries requires a map-reduce
 -- job), followed by select star and a file sink.
@@ -16,7 +17,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a nested union where one of the sub-queries requires a map-reduce
 -- job), followed by select star and a file sink.
@@ -273,11 +275,11 @@ Bucket Columns:     	[]
 Sort Columns:       	[]                  	 
 Storage Desc Params:	 	 
 	serialization.format	1                   
-PREHOOK: query: select * from outputTbl1 order by key, `values`
+PREHOOK: query: select * from outputTbl1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 order by key, `values`
+POSTHOOK: query: select * from outputTbl1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_11.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_11.q.out b/ql/src/test/results/clientpositive/spark/union_remove_11.q.out
index 5d77d06..0fe1340 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_11.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_11.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a nested union where also contains map only sub-queries),
 -- followed by select star and a file sink.
@@ -16,7 +17,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a nested union where also contains map only sub-queries),
 -- followed by select star and a file sink.
@@ -263,11 +265,11 @@ Bucket Columns:     	[]
 Sort Columns:       	[]                  	 
 Storage Desc Params:	 	 
 	serialization.format	1                   
-PREHOOK: query: select * from outputTbl1 order by key, `values`
+PREHOOK: query: select * from outputTbl1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 order by key, `values`
+POSTHOOK: query: select * from outputTbl1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_12.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_12.q.out b/ql/src/test/results/clientpositive/spark/union_remove_12.q.out
index 6a7fe69..7487cd3 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_12.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_12.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one is a map-join query), followed by select star and a file sink.
 -- The union optimization is applied, and the union is removed.
@@ -15,7 +16,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one is a map-join query), followed by select star and a file sink.
 -- The union optimization is applied, and the union is removed.
@@ -271,11 +273,11 @@ Bucket Columns:     	[]
 Sort Columns:       	[]                  	 
 Storage Desc Params:	 	 
 	serialization.format	1                   
-PREHOOK: query: select * from outputTbl1 order by key, `values`
+PREHOOK: query: select * from outputTbl1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 order by key, `values`
+POSTHOOK: query: select * from outputTbl1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_13.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_13.q.out b/ql/src/test/results/clientpositive/spark/union_remove_13.q.out
index 2d031f9..550c24b 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_13.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_13.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a mapred query, and the
 -- other one is a map-join query), followed by select star and a file sink.
 -- The union selectstar optimization should be performed, and the union should be removed.
@@ -15,7 +16,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a mapred query, and the
 -- other one is a map-join query), followed by select star and a file sink.
 -- The union selectstar optimization should be performed, and the union should be removed.
@@ -297,11 +299,11 @@ Bucket Columns:     	[]
 Sort Columns:       	[]                  	 
 Storage Desc Params:	 	 
 	serialization.format	1                   
-PREHOOK: query: select * from outputTbl1 order by key, `values`
+PREHOOK: query: select * from outputTbl1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 order by key, `values`
+POSTHOOK: query: select * from outputTbl1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
@@ -313,8 +315,8 @@ POSTHOOK: Input: default@outputtbl1
 3	13
 7	1
 7	17
-8	2
 8	18
 8	18
+8	2
 8	28
 8	28

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_14.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_14.q.out b/ql/src/test/results/clientpositive/spark/union_remove_14.q.out
index 0be3d86..9002223 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_14.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_14.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a join, which should be performed as a map-join query at runtime),
 -- followed by select star and a file sink.
@@ -16,7 +17,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 subqueries is performed (one of which is a map-only query, and the
 -- other one contains a join, which should be performed as a map-join query at runtime),
 -- followed by select star and a file sink.
@@ -273,11 +275,11 @@ Bucket Columns:     	[]
 Sort Columns:       	[]                  	 
 Storage Desc Params:	 	 
 	serialization.format	1                   
-PREHOOK: query: select * from outputTbl1 order by key, `values`
+PREHOOK: query: select * from outputTbl1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 order by key, `values`
+POSTHOOK: query: select * from outputTbl1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_15.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_15.q.out b/ql/src/test/results/clientpositive/spark/union_remove_15.q.out
index c0ad4e6..c4d1542 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_15.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_15.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -15,7 +16,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -220,12 +222,12 @@ POSTHOOK: type: SHOWPARTITIONS
 POSTHOOK: Input: default@outputtbl1
 ds=1
 ds=2
-PREHOOK: query: select * from outputTbl1 where ds = '1' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '1' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=1
@@ -235,12 +237,12 @@ POSTHOOK: Input: default@outputtbl1@ds=1
 3	1	1
 7	1	1
 8	2	1
-PREHOOK: query: select * from outputTbl1 where ds = '2' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '2'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=2
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '2' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '2'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=2

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_16.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_16.q.out b/ql/src/test/results/clientpositive/spark/union_remove_16.q.out
index d02109a..961291b 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_16.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_16.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -14,7 +15,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
 -- There is no need to write the temporary results of the sub-queries, and then read them 
@@ -260,12 +262,12 @@ POSTHOOK: type: SHOWPARTITIONS
 POSTHOOK: Input: default@outputtbl1
 ds=1
 ds=2
-PREHOOK: query: select * from outputTbl1 where ds = '1' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '1' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=1
@@ -275,12 +277,12 @@ POSTHOOK: Input: default@outputtbl1@ds=1
 3	1	1
 7	1	1
 8	2	1
-PREHOOK: query: select * from outputTbl1 where ds = '2' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '2'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=2
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '2' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '2'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=2

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_17.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_17.q.out b/ql/src/test/results/clientpositive/spark/union_remove_17.q.out
index c8047a9..baed263 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_17.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_17.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
 -- There is no need for this optimization, since the query is a map-only query.
@@ -12,7 +13,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- and the results are written to a table using dynamic partitions.
 -- There is no need for this optimization, since the query is a map-only query.
@@ -192,12 +194,12 @@ POSTHOOK: type: SHOWPARTITIONS
 POSTHOOK: Input: default@outputtbl1
 ds=1
 ds=2
-PREHOOK: query: select * from outputTbl1 where ds = '1' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '1' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=1
@@ -208,12 +210,12 @@ POSTHOOK: Input: default@outputtbl1@ds=1
 7	1	1
 8	1	1
 8	1	1
-PREHOOK: query: select * from outputTbl1 where ds = '2' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '2'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=2
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '2' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '2'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=2

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_18.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_18.q.out b/ql/src/test/results/clientpositive/spark/union_remove_18.q.out
index 6a6de92..535d085 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_18.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_18.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
 -- again to process the union. The union can be removed completely.
@@ -14,7 +15,8 @@ create table inputTbl1(key string, ds string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
 -- again to process the union. The union can be removed completely.
@@ -234,31 +236,31 @@ ds=13
 ds=17
 ds=18
 ds=28
-PREHOOK: query: select * from outputTbl1 where ds = '11' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '11'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=11
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '11' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '11'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=11
 #### A masked pattern was here ####
 1	1	11
 1	1	11
-PREHOOK: query: select * from outputTbl1 where ds = '18' order by key, `values`
+PREHOOK: query: select * from outputTbl1 where ds = '18'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=18
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds = '18' order by key, `values`
+POSTHOOK: query: select * from outputTbl1 where ds = '18'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=18
 #### A masked pattern was here ####
 8	1	18
 8	1	18
-PREHOOK: query: select * from outputTbl1 where ds is not null order by key, `values`, ds
+PREHOOK: query: select * from outputTbl1 where ds is not null
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 PREHOOK: Input: default@outputtbl1@ds=11
@@ -268,7 +270,7 @@ PREHOOK: Input: default@outputtbl1@ds=17
 PREHOOK: Input: default@outputtbl1@ds=18
 PREHOOK: Input: default@outputtbl1@ds=28
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 where ds is not null order by key, `values`, ds
+POSTHOOK: query: select * from outputTbl1 where ds is not null
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 POSTHOOK: Input: default@outputtbl1@ds=11

http://git-wip-us.apache.org/repos/asf/hive/blob/d14673a0/ql/src/test/results/clientpositive/spark/union_remove_19.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/spark/union_remove_19.q.out b/ql/src/test/results/clientpositive/spark/union_remove_19.q.out
index 59063a7..8c06c64 100644
--- a/ql/src/test/results/clientpositive/spark/union_remove_19.q.out
+++ b/ql/src/test/results/clientpositive/spark/union_remove_19.q.out
@@ -1,4 +1,5 @@
-PREHOOK: query: -- This is to test the union->selectstar->filesink optimization
+PREHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
 -- again to process the union. The union can be removed completely.
@@ -14,7 +15,8 @@ create table inputTbl1(key string, val string) stored as textfile
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@inputTbl1
-POSTHOOK: query: -- This is to test the union->selectstar->filesink optimization
+POSTHOOK: query: -- SORT_QUERY_RESULTS
+-- This is to test the union->selectstar->filesink optimization
 -- Union of 2 map-reduce subqueries is performed followed by select star and a file sink
 -- There is no need to write the temporary results of the sub-queries, and then read them 
 -- again to process the union. The union can be removed completely.
@@ -484,11 +486,11 @@ POSTHOOK: Input: default@inputtbl1
 POSTHOOK: Output: default@outputtbl1
 POSTHOOK: Lineage: outputtbl1.key EXPRESSION [(inputtbl1)inputtbl1.FieldSchema(name:key, type:string, comment:null), ]
 POSTHOOK: Lineage: outputtbl1.values EXPRESSION [(inputtbl1)inputtbl1.null, ]
-PREHOOK: query: select * from outputTbl1 order by key, `values`
+PREHOOK: query: select * from outputTbl1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####
-POSTHOOK: query: select * from outputTbl1 order by key, `values`
+POSTHOOK: query: select * from outputTbl1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@outputtbl1
 #### A masked pattern was here ####


Mime
View raw message