You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2018/05/21 20:25:24 UTC

[47/51] [abbrv] [partial] hive git commit: HIVE-19617: Rename test tables to avoid collisions during execution in batches (Jesus Camacho Rodriguez, reviewed by Gunther Hagleitner)

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_11.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_11.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_11.q
index f95d36c..7416eb0 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_11.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_11.q
@@ -4,26 +4,26 @@ set hive.strict.checks.bucketing=false;
 set hive.mapred.mode=nonstrict;
 -- small 1 part, 2 bucket & big 2 part, 4 bucket
 
-CREATE TABLE bucket_small (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (KEY) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-08');
+CREATE TABLE bucket_small_n11 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (KEY) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n11 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n11 partition(ds='2008-04-08');
 
-CREATE TABLE bucket_big (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY(KEY) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big partition(ds='2008-04-08');
+CREATE TABLE bucket_big_n11 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY(KEY) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big_n11 partition(ds='2008-04-09');
 
 set hive.auto.convert.join=true;
 -- disable hash joins
 set hive.auto.convert.join.noconditionaltask.size=10;
-explain extended select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key;
+select count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key;
 
 set hive.auto.convert.sortmerge.join=true;
 set hive.optimize.bucketmapjoin=true;
@@ -32,13 +32,13 @@ set hive.optimize.bucketmapjoin.sortedmerge=true;
 -- The tables are only bucketed and not sorted, the join should not be converted
 -- Currenly, a join is only converted to a sort-merge join without a hint, automatic conversion to
 -- bucketized mapjoin is not done
-explain extended select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key;
+select count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key;
 set hive.cbo.enable=false;
 -- The join is converted to a bucketed mapjoin with a mapjoin hint
-explain extended select /*+ mapjoin(a) */ count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select /*+ mapjoin(a) */ count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select /*+ mapjoin(a) */ count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key;
+select /*+ mapjoin(a) */ count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key;
 
 -- HIVE-7023
-explain extended select /*+ MAPJOIN(a,b) */ count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key JOIN bucket_big c ON a.key = c.key;
-select /*+ MAPJOIN(a,b) */ count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key JOIN bucket_big c ON a.key = c.key;
+explain extended select /*+ MAPJOIN(a,b) */ count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key JOIN bucket_big_n11 c ON a.key = c.key;
+select /*+ MAPJOIN(a,b) */ count(*) FROM bucket_small_n11 a JOIN bucket_big_n11 b ON a.key = b.key JOIN bucket_big_n11 c ON a.key = c.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_12.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_12.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_12.q
index 86ba6cf..d68efea 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_12.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_12.q
@@ -4,21 +4,21 @@ set hive.strict.checks.bucketing=false;
 set hive.mapred.mode=nonstrict;
 -- small 1 part, 2 bucket & big 2 part, 4 bucket
 
-CREATE TABLE bucket_small (key string, value string) partitioned by (ds string)
+CREATE TABLE bucket_small_n15 (key string, value string) partitioned by (ds string)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n15 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n15 partition(ds='2008-04-08');
 
-CREATE TABLE bucket_big (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big partition(ds='2008-04-08');
+CREATE TABLE bucket_big_n15 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big_n15 partition(ds='2008-04-09');
 
 set hive.auto.convert.join=true;
 set hive.auto.convert.sortmerge.join=true;
@@ -33,5 +33,5 @@ load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INT
 load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_medium partition(ds='2008-04-08');
 load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_medium partition(ds='2008-04-08');
 
-explain extended select count(*) FROM bucket_small a JOIN bucket_medium b ON a.key = b.key JOIN bucket_big c ON c.key = b.key JOIN bucket_medium d ON c.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_medium b ON a.key = b.key JOIN bucket_big c ON c.key = b.key JOIN bucket_medium d ON c.key = b.key;
+explain extended select count(*) FROM bucket_small_n15 a JOIN bucket_medium b ON a.key = b.key JOIN bucket_big_n15 c ON c.key = b.key JOIN bucket_medium d ON c.key = b.key;
+select count(*) FROM bucket_small_n15 a JOIN bucket_medium b ON a.key = b.key JOIN bucket_big_n15 c ON c.key = b.key JOIN bucket_medium d ON c.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_13.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_13.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_13.q
index 44d3452..bbd7afa 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_13.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_13.q
@@ -5,14 +5,14 @@ set hive.exec.reducers.max = 1;
 
 -- SORT_QUERY_RESULTS
 
-CREATE TABLE tbl1(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE tbl2(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl1_n2(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl2_n1(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
-insert overwrite table tbl1 select * from src where key < 10;
-insert overwrite table tbl2 select * from src where key < 10;
+insert overwrite table tbl1_n2 select * from src where key < 10;
+insert overwrite table tbl2_n1 select * from src where key < 10;
 
-CREATE TABLE dest1(k1 int, k2 int);
-CREATE TABLE dest2(k1 string, k2 string);
+CREATE TABLE dest1_n20(k1 int, k2 int);
+CREATE TABLE dest2_n4(k1 string, k2 string);
 
 set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
@@ -27,20 +27,20 @@ set hive.auto.convert.join.noconditionaltask.size=200;
 explain 
 from (
   SELECT a.key key1, a.value value1, b.key key2, b.value value2 
-  FROM tbl1 a JOIN tbl2 b 
+  FROM tbl1_n2 a JOIN tbl2_n1 b 
   ON a.key = b.key ) subq
-INSERT OVERWRITE TABLE dest1 select key1, key2
-INSERT OVERWRITE TABLE dest2 select value1, value2;
+INSERT OVERWRITE TABLE dest1_n20 select key1, key2
+INSERT OVERWRITE TABLE dest2_n4 select value1, value2;
 
 from (
   SELECT a.key key1, a.value value1, b.key key2, b.value value2 
-  FROM tbl1 a JOIN tbl2 b 
+  FROM tbl1_n2 a JOIN tbl2_n1 b 
   ON a.key = b.key ) subq
-INSERT OVERWRITE TABLE dest1 select key1, key2
-INSERT OVERWRITE TABLE dest2 select value1, value2;
+INSERT OVERWRITE TABLE dest1_n20 select key1, key2
+INSERT OVERWRITE TABLE dest2_n4 select value1, value2;
 
-select * from dest1;
-select * from dest2;
+select * from dest1_n20;
+select * from dest2_n4;
 
 set hive.auto.convert.join.noconditionaltask=true;
 set hive.mapjoin.hybridgrace.minwbsize=100;
@@ -50,37 +50,37 @@ set hive.mapjoin.hybridgrace.minnumpartitions=2;
 explain 
 from (
   SELECT a.key key1, a.value value1, b.key key2, b.value value2 
-  FROM tbl1 a JOIN tbl2 b 
+  FROM tbl1_n2 a JOIN tbl2_n1 b 
   ON a.key = b.key ) subq
-INSERT OVERWRITE TABLE dest1 select key1, key2
-INSERT OVERWRITE TABLE dest2 select value1, value2;
+INSERT OVERWRITE TABLE dest1_n20 select key1, key2
+INSERT OVERWRITE TABLE dest2_n4 select value1, value2;
 
 from (
   SELECT a.key key1, a.value value1, b.key key2, b.value value2 
-  FROM tbl1 a JOIN tbl2 b 
+  FROM tbl1_n2 a JOIN tbl2_n1 b 
   ON a.key = b.key ) subq
-INSERT OVERWRITE TABLE dest1 select key1, key2
-INSERT OVERWRITE TABLE dest2 select value1, value2;
+INSERT OVERWRITE TABLE dest1_n20 select key1, key2
+INSERT OVERWRITE TABLE dest2_n4 select value1, value2;
 
-select * from dest1;
-select * from dest2;
+select * from dest1_n20;
+select * from dest2_n4;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 -- A SMB join followed by a mutli-insert
 explain 
 from (
   SELECT a.key key1, a.value value1, b.key key2, b.value value2 
-  FROM tbl1 a JOIN tbl2 b 
+  FROM tbl1_n2 a JOIN tbl2_n1 b 
   ON a.key = b.key ) subq
-INSERT OVERWRITE TABLE dest1 select key1, key2
-INSERT OVERWRITE TABLE dest2 select value1, value2;
+INSERT OVERWRITE TABLE dest1_n20 select key1, key2
+INSERT OVERWRITE TABLE dest2_n4 select value1, value2;
 
 from (
   SELECT a.key key1, a.value value1, b.key key2, b.value value2 
-  FROM tbl1 a JOIN tbl2 b 
+  FROM tbl1_n2 a JOIN tbl2_n1 b 
   ON a.key = b.key ) subq
-INSERT OVERWRITE TABLE dest1 select key1, key2
-INSERT OVERWRITE TABLE dest2 select value1, value2;
+INSERT OVERWRITE TABLE dest1_n20 select key1, key2
+INSERT OVERWRITE TABLE dest2_n4 select value1, value2;
 
-select * from dest1;
-select * from dest2;
+select * from dest1_n20;
+select * from dest2_n4;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_14.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_14.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_14.q
index b7c361b..1e21c92 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_14.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_14.q
@@ -5,11 +5,11 @@ set hive.explain.user=false;
 
 set hive.exec.reducers.max = 1;
 
-CREATE TABLE tbl1(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE tbl2(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl1_n7(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl2_n6(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
-insert overwrite table tbl1 select * from src where key < 20;
-insert overwrite table tbl2 select * from src where key < 10;
+insert overwrite table tbl1_n7 select * from src where key < 20;
+insert overwrite table tbl2_n6 select * from src where key < 10;
 
 set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
@@ -21,14 +21,14 @@ set hive.auto.convert.join=true;
 -- disable hash joins
 set hive.auto.convert.join.noconditionaltask.size=10;
 
--- Since tbl1 is the bigger table, tbl1 Left Outer Join tbl2 can be performed
+-- Since tbl1_n7 is the bigger table, tbl1_n7 Left Outer Join tbl2_n6 can be performed
 explain
-select count(*) FROM tbl1 a LEFT OUTER JOIN tbl2 b ON a.key = b.key;
-select count(*) FROM tbl1 a LEFT OUTER JOIN tbl2 b ON a.key = b.key;
+select count(*) FROM tbl1_n7 a LEFT OUTER JOIN tbl2_n6 b ON a.key = b.key;
+select count(*) FROM tbl1_n7 a LEFT OUTER JOIN tbl2_n6 b ON a.key = b.key;
 
-insert overwrite table tbl2 select * from src where key < 200;
+insert overwrite table tbl2_n6 select * from src where key < 200;
 
--- Since tbl2 is the bigger table, tbl1 Right Outer Join tbl2 can be performed
+-- Since tbl2_n6 is the bigger table, tbl1_n7 Right Outer Join tbl2_n6 can be performed
 explain
-select count(*) FROM tbl1 a RIGHT OUTER JOIN tbl2 b ON a.key = b.key;
-select count(*) FROM tbl1 a RIGHT OUTER JOIN tbl2 b ON a.key = b.key;
+select count(*) FROM tbl1_n7 a RIGHT OUTER JOIN tbl2_n6 b ON a.key = b.key;
+select count(*) FROM tbl1_n7 a RIGHT OUTER JOIN tbl2_n6 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_15.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_15.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_15.q
index 4a2a2ea..b3dd8e5 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_15.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_15.q
@@ -5,11 +5,11 @@ set hive.explain.user=false;
 
 set hive.exec.reducers.max = 1;
 
-CREATE TABLE tbl1(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE tbl2(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl1_n11(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl2_n10(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
-insert overwrite table tbl1 select * from src where key < 20;
-insert overwrite table tbl2 select * from src where key < 10;
+insert overwrite table tbl1_n11 select * from src where key < 20;
+insert overwrite table tbl2_n10 select * from src where key < 10;
 
 set hive.merge.mapfiles=false;
 set hive.merge.mapredfiles=false;
@@ -22,7 +22,7 @@ set hive.auto.convert.join=true;
 set hive.auto.convert.join.noconditionaltask.size=10;
 
 explain
-select count(*) FROM tbl1 a LEFT OUTER JOIN tbl2 b ON a.key = b.key;
+select count(*) FROM tbl1_n11 a LEFT OUTER JOIN tbl2_n10 b ON a.key = b.key;
 
 explain
-select count(*) FROM tbl1 a RIGHT OUTER JOIN tbl2 b ON a.key = b.key;
+select count(*) FROM tbl1_n11 a RIGHT OUTER JOIN tbl2_n10 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_16.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_16.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_16.q
index 6d177aa..0a72ddf 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_16.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_16.q
@@ -12,14 +12,14 @@ set hive.optimize.bucketmapjoin.sortedmerge = true;
 
 -- SORT_QUERY_RESULTS
 
-CREATE TABLE stage_bucket_big
+CREATE TABLE stage_bucket_big_n17
 (
 key BIGINT,
 value STRING
 )
 PARTITIONED BY (file_tag STRING);
 
-CREATE TABLE bucket_big
+CREATE TABLE bucket_big_n17
 (
 key BIGINT,
 value STRING
@@ -28,14 +28,14 @@ PARTITIONED BY (day STRING, pri bigint)
 clustered by (key) sorted by (key) into 12 buckets
 stored as RCFile;
 
-CREATE TABLE stage_bucket_small
+CREATE TABLE stage_bucket_small_n17
 (
 key BIGINT,
 value string
 )
 PARTITIONED BY (file_tag STRING);
 
-CREATE TABLE bucket_small
+CREATE TABLE bucket_small_n17
 (
 key BIGINT,
 value string
@@ -44,32 +44,32 @@ PARTITIONED BY (pri bigint)
 clustered by (key) sorted by (key) into 12 buckets
 stored as RCFile;
 
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' overwrite into table stage_bucket_small partition (file_tag='1');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' overwrite into table stage_bucket_small partition (file_tag='2');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' overwrite into table stage_bucket_small_n17 partition (file_tag='1');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' overwrite into table stage_bucket_small_n17 partition (file_tag='2');
 
-insert overwrite table bucket_small partition(pri) 
+insert overwrite table bucket_small_n17 partition(pri) 
 select 
 key, 
 value, 
 file_tag as pri 
 from 
-stage_bucket_small 
+stage_bucket_small_n17 
 where file_tag between 1 and 2;
 
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' overwrite into table stage_bucket_big partition (file_tag='1');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' overwrite into table stage_bucket_big_n17 partition (file_tag='1');
 
-insert overwrite table bucket_big partition(day,pri)
+insert overwrite table bucket_big_n17 partition(day,pri)
  select key, value, 'day1' as day, 1 as pri
-   from stage_bucket_big
+   from stage_bucket_big_n17
    where file_tag='1';
 
 explain select a.key , a.value , b.value , 'day1' as day, 1 as pri
         from
         ( select key, value
-          from bucket_big where day='day1' ) a
+          from bucket_big_n17 where day='day1' ) a
           left outer join
           ( select key, value
-            from bucket_small
+            from bucket_small_n17
             where pri between 1 and 2 ) b
             on
           (a.key = b.key)
@@ -78,10 +78,10 @@ explain select a.key , a.value , b.value , 'day1' as day, 1 as pri
 select a.key , a.value , b.value , 'day1' as day, 1 as pri
 from
 ( select key, value
-  from bucket_big where day='day1' ) a
+  from bucket_big_n17 where day='day1' ) a
   left outer join
   ( select key, value
-  from bucket_small
+  from bucket_small_n17
   where pri between 1 and 2 ) b
 on
 (a.key = b.key) 
@@ -94,10 +94,10 @@ set hive.auto.convert.sortmerge.join=true;
 explain select a.key , a.value , b.value , 'day1' as day, 1 as pri
 from
 ( select key, value
-  from bucket_big where day='day1' ) a
+  from bucket_big_n17 where day='day1' ) a
 left outer join
 ( select key, value
-  from bucket_small
+  from bucket_small_n17
   where pri between 1 and 2 ) b
 on
 (a.key = b.key)
@@ -106,21 +106,21 @@ on
 select a.key , a.value , b.value , 'day1' as day, 1 as pri
 from
 ( select key, value
-  from bucket_big where day='day1' ) a
+  from bucket_big_n17 where day='day1' ) a
 left outer join
 ( select key, value
-  from bucket_small
+  from bucket_small_n17
   where pri between 1 and 2 ) b
 on
 (a.key = b.key)
 ;
 
-drop table bucket_big;
-drop table bucket_small;
+drop table bucket_big_n17;
+drop table bucket_small_n17;
 
 -- Test to make sure SMB is not kicked in when small table has more buckets than big table
 
-CREATE TABLE bucket_big
+CREATE TABLE bucket_big_n17
 (
 key BIGINT,
 value STRING
@@ -129,7 +129,7 @@ PARTITIONED BY (day STRING, pri bigint)
 clustered by (key) sorted by (key) into 12 buckets
 stored as RCFile;
 
-CREATE TABLE bucket_small
+CREATE TABLE bucket_small_n17
 (
 key BIGINT,
 value string
@@ -138,28 +138,28 @@ PARTITIONED BY (pri bigint)
 clustered by (key) sorted by (key) into 24 buckets
 stored as RCFile;
 
-insert overwrite table bucket_small partition(pri)
+insert overwrite table bucket_small_n17 partition(pri)
 select
 key,
 value,
 file_tag as pri
 from
-stage_bucket_small
+stage_bucket_small_n17
 where file_tag between 1 and 2;
 
-insert overwrite table bucket_big partition(day,pri)
+insert overwrite table bucket_big_n17 partition(day,pri)
 select key, value, 'day1' as day, 1 as pri
-from stage_bucket_big
+from stage_bucket_big_n17
 where file_tag='1';
 
 
 explain select a.key , a.value , b.value , 'day1' as day, 1 as pri
         from
         ( select key, value
-          from bucket_big where day='day1' ) a
+          from bucket_big_n17 where day='day1' ) a
         left outer join
         ( select key, value
-          from bucket_small
+          from bucket_small_n17
           where pri between 1 and 2 ) b
         on
         (a.key = b.key)
@@ -168,10 +168,10 @@ explain select a.key , a.value , b.value , 'day1' as day, 1 as pri
 select a.key , a.value , b.value , 'day1' as day, 1 as pri
 from
 ( select key, value
-  from bucket_big where day='day1' ) a
+  from bucket_big_n17 where day='day1' ) a
 left outer join
 ( select key, value
-  from bucket_small
+  from bucket_small_n17
   where pri between 1 and 2 ) b
 on
 (a.key = b.key)

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_2.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_2.q
index 0413b51..c6d5318 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_2.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_2.q
@@ -3,18 +3,18 @@ set hive.strict.checks.bucketing=false;
 
 set hive.mapred.mode=nonstrict;
 -- small 1 part, 4 bucket & big 2 part, 2 bucket
-CREATE TABLE bucket_small (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small partition(ds='2008-04-08');
+CREATE TABLE bucket_small_n3 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n3 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n3 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small_n3 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small_n3 partition(ds='2008-04-08');
 
-CREATE TABLE bucket_big (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-08');
+CREATE TABLE bucket_big_n3 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n3 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n3 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n3 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n3 partition(ds='2008-04-09');
 
 set hive.auto.convert.join=true;
 set hive.auto.convert.sortmerge.join=true;
@@ -26,13 +26,13 @@ set hive.auto.convert.sortmerge.join.bigtable.selection.policy = org.apache.hado
 set hive.auto.convert.join.noconditionaltask.size=10;
 
 -- Since the leftmost table is assumed as the big table, arrange the tables in the join accordingly
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n3 a JOIN bucket_small_n3 b ON a.key = b.key;
+select count(*) FROM bucket_big_n3 a JOIN bucket_small_n3 b ON a.key = b.key;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 set hive.mapjoin.localtask.max.memory.usage = 0.0001;
 set hive.mapjoin.check.memory.rows = 2;
 
 -- The mapjoin should fail resulting in the sort-merge join
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n3 a JOIN bucket_small_n3 b ON a.key = b.key;
+select count(*) FROM bucket_big_n3 a JOIN bucket_small_n3 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_3.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_3.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_3.q
index 7062b82..f41b097 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_3.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_3.q
@@ -3,18 +3,18 @@ set hive.strict.checks.bucketing=false;
 
 set hive.mapred.mode=nonstrict;
 -- small 2 part, 2 bucket & big 1 part, 4 bucket
-CREATE TABLE bucket_small (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-08');
+CREATE TABLE bucket_small_n9 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n9 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n9 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n9 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n9 partition(ds='2008-04-09');
 
-CREATE TABLE bucket_big (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big partition(ds='2008-04-08');
+CREATE TABLE bucket_big_n9 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n9 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n9 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big_n9 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big_n9 partition(ds='2008-04-08');
 
 set hive.auto.convert.join=true;
 set hive.auto.convert.sortmerge.join=true;
@@ -26,12 +26,12 @@ set hive.auto.convert.sortmerge.join.bigtable.selection.policy = org.apache.hado
 set hive.auto.convert.join.noconditionaltask.size=100;
 
 -- Since size is being used to find the big table, the order of the tables in the join does not matter
-explain extended select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select count(*) FROM bucket_small_n9 a JOIN bucket_big_n9 b ON a.key = b.key;
+select count(*) FROM bucket_small_n9 a JOIN bucket_big_n9 b ON a.key = b.key;
 
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n9 a JOIN bucket_small_n9 b ON a.key = b.key;
+select count(*) FROM bucket_big_n9 a JOIN bucket_small_n9 b ON a.key = b.key;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n9 a JOIN bucket_small_n9 b ON a.key = b.key;
+select count(*) FROM bucket_big_n9 a JOIN bucket_small_n9 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_4.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_4.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_4.q
index 1a23fca..e28e0ab 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_4.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_4.q
@@ -3,20 +3,20 @@ set hive.strict.checks.bucketing=false;
 
 set hive.mapred.mode=nonstrict;
 -- small 2 part, 4 bucket & big 1 part, 2 bucket
-CREATE TABLE bucket_small (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small partition(ds='2008-04-08');
+CREATE TABLE bucket_small_n12 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small_n12 partition(ds='2008-04-09');
 
-CREATE TABLE bucket_big (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-08');
+CREATE TABLE bucket_big_n12 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n12 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n12 partition(ds='2008-04-08');
 
 set hive.auto.convert.join=true;
 set hive.auto.convert.sortmerge.join=true;
@@ -28,12 +28,12 @@ set hive.auto.convert.sortmerge.join.bigtable.selection.policy = org.apache.hado
 set hive.auto.convert.join.noconditionaltask.size=200;
 
 -- Since size is being used to find the big table, the order of the tables in the join does not matter
-explain extended select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select count(*) FROM bucket_small_n12 a JOIN bucket_big_n12 b ON a.key = b.key;
+select count(*) FROM bucket_small_n12 a JOIN bucket_big_n12 b ON a.key = b.key;
 
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n12 a JOIN bucket_small_n12 b ON a.key = b.key;
+select count(*) FROM bucket_big_n12 a JOIN bucket_small_n12 b ON a.key = b.key;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n12 a JOIN bucket_small_n12 b ON a.key = b.key;
+select count(*) FROM bucket_big_n12 a JOIN bucket_small_n12 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/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 50303cf..9550e21 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_5.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_5.q
@@ -6,15 +6,15 @@ set hive.mapred.mode=nonstrict;
 
 -- 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/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small;
+CREATE TABLE bucket_small_n0 (key string, value string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n0;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n0;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small_n0;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small_n0;
 
-CREATE TABLE bucket_big (key string, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big;
+CREATE TABLE bucket_big_n0 (key string, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n0;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n0;
 
 set hive.auto.convert.sortmerge.join=true;
 set hive.optimize.bucketmapjoin = true;
@@ -25,13 +25,13 @@ set hive.auto.convert.sortmerge.join.bigtable.selection.policy = org.apache.hado
 set hive.auto.convert.join.noconditionaltask.size=1;
 
 -- Since size is being used to find the big table, the order of the tables in the join does not matter
-explain extended select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select count(*) FROM bucket_small_n0 a JOIN bucket_big_n0 b ON a.key = b.key;
+select count(*) FROM bucket_small_n0 a JOIN bucket_big_n0 b ON a.key = b.key;
 
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n0 a JOIN bucket_small_n0 b ON a.key = b.key;
+select count(*) FROM bucket_big_n0 a JOIN bucket_small_n0 b ON a.key = b.key;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 set hive.auto.convert.join=true;
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n0 a JOIN bucket_small_n0 b ON a.key = b.key;
+select count(*) FROM bucket_big_n0 a JOIN bucket_small_n0 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_6.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_6.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_6.q
index 32745c9..551e5f7 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_6.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_6.q
@@ -5,14 +5,14 @@ set hive.mapred.mode=nonstrict;
 set hive.exec.reducers.max = 1;
 set hive.explain.user=false;
 
-CREATE TABLE tbl1(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE tbl2(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE tbl3(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl1_n4(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl2_n3(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl3_n0(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 CREATE TABLE tbl4(key int, value string) CLUSTERED BY (value) SORTED BY (value) INTO 2 BUCKETS;
 
-insert overwrite table tbl1 select * from src;
-insert overwrite table tbl2 select * from src;
-insert overwrite table tbl3 select * from src;
+insert overwrite table tbl1_n4 select * from src;
+insert overwrite table tbl2_n3 select * from src;
+insert overwrite table tbl3_n0 select * from src;
 insert overwrite table tbl4 select * from src;
 
 set hive.auto.convert.sortmerge.join=true;
@@ -30,47 +30,47 @@ set hive.auto.convert.sortmerge.join.to.mapjoin=false;
 -- b = TS[0]-OP[13]-MAPJOIN[11]-RS[6]-JOIN[8]-SEL[9]-FS[10]
 -- c = TS[1]-RS[7]-JOIN[8]
 -- a = TS[2]-MAPJOIN[11]
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.value = a.value;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.value = a.value;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.value = a.value;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.value = a.value;
 
 -- d = TS[0]-RS[7]-JOIN[8]-SEL[9]-FS[10]
 -- b = TS[1]-OP[13]-MAPJOIN[11]-RS[6]-JOIN[8]
 -- a = TS[2]-MAPJOIN[11]
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src d on d.value = a.value;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src d on d.value = a.value;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src d on d.value = a.value;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src d on d.value = a.value;
 
 -- b = TS[0]-OP[13]-MAPJOIN[11]-RS[6]-JOIN[8]-SEL[9]-FS[10]
 -- a = TS[1]-MAPJOIN[11]
 -- h = TS[2]-RS[7]-JOIN[8]
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src h on h.value = a.value;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src h on h.value = a.value;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src h on h.value = a.value;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src h on h.value = a.value;
 
 -- A SMB join is being followed by a regular join on a non-bucketed table on the same key
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.key = a.key;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.key = a.key;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.key = a.key;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.key = a.key;
 
 -- A SMB join is being followed by a regular join on a bucketed table on the same key
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl3 c on c.key = a.key;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl3 c on c.key = a.key;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl3_n0 c on c.key = a.key;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl3_n0 c on c.key = a.key;
 
 -- A SMB join is being followed by a regular join on a bucketed table on a different key
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl4 c on c.value = a.value;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl4 c on c.value = a.value;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl4 c on c.value = a.value;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl4 c on c.value = a.value;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 
 -- A SMB join is being followed by a regular join on a non-bucketed table on a different key
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.value = a.value;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.value = a.value;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.value = a.value;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.value = a.value;
 
 -- A SMB join is being followed by a regular join on a non-bucketed table on the same key
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.key = a.key;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join src c on c.key = a.key;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.key = a.key;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join src c on c.key = a.key;
 
 -- A SMB join is being followed by a regular join on a bucketed table on the same key
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl3 c on c.key = a.key;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl3 c on c.key = a.key;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl3_n0 c on c.key = a.key;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl3_n0 c on c.key = a.key;
 
 -- A SMB join is being followed by a regular join on a bucketed table on a different key
-explain select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl4 c on c.value = a.value;
-select count(*) FROM tbl1 a JOIN tbl2 b ON a.key = b.key join tbl4 c on c.value = a.value;
+explain select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl4 c on c.value = a.value;
+select count(*) FROM tbl1_n4 a JOIN tbl2_n3 b ON a.key = b.key join tbl4 c on c.value = a.value;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_7.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_7.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_7.q
index 96f4250..8c9dbac 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_7.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_7.q
@@ -3,23 +3,23 @@ set hive.strict.checks.bucketing=false;
 
 set hive.mapred.mode=nonstrict;
 -- small 2 part, 4 bucket & big 2 part, 2 bucket
-CREATE TABLE bucket_small (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small partition(ds='2008-04-08');
+CREATE TABLE bucket_small_n6 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000002_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000003_0' INTO TABLE bucket_small_n6 partition(ds='2008-04-09');
 
-CREATE TABLE bucket_big (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-08');
+CREATE TABLE bucket_big_n6 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n6 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n6 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n6 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n6 partition(ds='2008-04-09');
 
 set hive.auto.convert.join=true;
 set hive.auto.convert.sortmerge.join=true;
@@ -31,12 +31,12 @@ set hive.auto.convert.sortmerge.join.bigtable.selection.policy = org.apache.hado
 set hive.auto.convert.join.noconditionaltask.size=10;
 
 -- Since size is being used to find the big table, the order of the tables in the join does not matter
-explain extended select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select count(*) FROM bucket_small_n6 a JOIN bucket_big_n6 b ON a.key = b.key;
+select count(*) FROM bucket_small_n6 a JOIN bucket_big_n6 b ON a.key = b.key;
 
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n6 a JOIN bucket_small_n6 b ON a.key = b.key;
+select count(*) FROM bucket_big_n6 a JOIN bucket_small_n6 b ON a.key = b.key;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n6 a JOIN bucket_small_n6 b ON a.key = b.key;
+select count(*) FROM bucket_big_n6 a JOIN bucket_small_n6 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_8.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_8.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_8.q
index 6783d35..51647e8 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_8.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_8.q
@@ -6,23 +6,23 @@ set hive.exec.submitviachild=false;
 set hive.exec.submit.local.task.via.child=false;
 
 -- small 2 part, 2 bucket & big 2 part, 4 bucket
-CREATE TABLE bucket_small (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-08');
+CREATE TABLE bucket_small_n5 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n5 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n5 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000000_0' INTO TABLE bucket_small_n5 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/small/000001_0' INTO TABLE bucket_small_n5 partition(ds='2008-04-09');
 
-CREATE TABLE bucket_big (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big partition(ds='2008-04-08');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big partition(ds='2008-04-08');
+CREATE TABLE bucket_big_n5 (key string, value string) partitioned by (ds string) CLUSTERED BY (key) SORTED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-08');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-08');
 
-load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big partition(ds='2008-04-09');
-load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000000_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000001_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000002_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-09');
+load data local inpath '../../data/files/auto_sortmerge_join/big/000003_0' INTO TABLE bucket_big_n5 partition(ds='2008-04-09');
 
 set hive.auto.convert.join=true;
 set hive.auto.convert.sortmerge.join=true;
@@ -34,16 +34,16 @@ set hive.auto.convert.sortmerge.join.bigtable.selection.policy = org.apache.hado
 set hive.auto.convert.join.noconditionaltask.size=10;
 
 -- Since size is being used to find the big table, the order of the tables in the join does not matter
-explain extended select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
-select count(*) FROM bucket_small a JOIN bucket_big b ON a.key = b.key;
+explain extended select count(*) FROM bucket_small_n5 a JOIN bucket_big_n5 b ON a.key = b.key;
+select count(*) FROM bucket_small_n5 a JOIN bucket_big_n5 b ON a.key = b.key;
 
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n5 a JOIN bucket_small_n5 b ON a.key = b.key;
+select count(*) FROM bucket_big_n5 a JOIN bucket_small_n5 b ON a.key = b.key;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 set hive.mapjoin.localtask.max.memory.usage = 0.0001;
 set hive.mapjoin.check.memory.rows = 2;
 
 -- The mapjoin should fail resulting in the sort-merge join
-explain extended select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
-select count(*) FROM bucket_big a JOIN bucket_small b ON a.key = b.key;
+explain extended select count(*) FROM bucket_big_n5 a JOIN bucket_small_n5 b ON a.key = b.key;
+select count(*) FROM bucket_big_n5 a JOIN bucket_small_n5 b ON a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/auto_sortmerge_join_9.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/auto_sortmerge_join_9.q b/ql/src/test/queries/clientpositive/auto_sortmerge_join_9.q
index b342dea..5696682 100644
--- a/ql/src/test/queries/clientpositive/auto_sortmerge_join_9.q
+++ b/ql/src/test/queries/clientpositive/auto_sortmerge_join_9.q
@@ -9,13 +9,13 @@ set hive.exec.reducers.max = 1;
 
 -- SORT_QUERY_RESULTS
 
-CREATE TABLE tbl1(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE tbl2(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl1_n10(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
+CREATE TABLE tbl2_n9(key int, value string) CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
-insert overwrite table tbl1
+insert overwrite table tbl1_n10
 select * from src where key < 10;
 
-insert overwrite table tbl2
+insert overwrite table tbl2_n9
 select * from src where key < 10;
 
 set hive.auto.convert.join=true;
@@ -29,24 +29,24 @@ set hive.auto.convert.join.noconditionaltask.size=1;
 -- The join is being performed as part of sub-query. It should be converted to a sort-merge join
 explain
 select count(*) from (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1;
 
 select count(*) from (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1;
 
 -- The join is being performed as part of sub-query. It should be converted to a sort-merge join
 explain
 select key, count(*) from 
 (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1
 group by key;
 
 select key, count(*) from 
 (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1
 group by key;
 
@@ -56,7 +56,7 @@ select count(*) from
 (
   select key, count(*) from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1
   group by key
 ) subq2;
@@ -65,7 +65,7 @@ select count(*) from
 (
   select key, count(*) from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1
   group by key
 ) subq2;
@@ -77,14 +77,14 @@ select src1.key, src1.cnt1, src2.cnt1 from
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1 group by key
 ) src1
 join
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq2 group by key
 ) src2
 on src1.key = src2.key;
@@ -93,14 +93,14 @@ select src1.key, src1.cnt1, src2.cnt1 from
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1 group by key
 ) src1
 join
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq2 group by key
 ) src2
 on src1.key = src2.key;
@@ -109,15 +109,15 @@ on src1.key = src2.key;
 -- be converted to a sort-merge join.
 explain
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on subq1.key = subq2.key;
 
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on subq1.key = subq2.key;
 
 -- The subquery itself is being joined. Since the sub-query only contains selects and filters, it should 
@@ -127,22 +127,22 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
-  join tbl2 b
+  join tbl2_n9 b
   on subq2.key = b.key;
 
 select count(*) from 
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
-  join tbl2 b
+  join tbl2_n9 b
   on subq2.key = b.key;
 
 -- Both the tables are nested sub-queries i.e more then 1 level of sub-query.
@@ -152,7 +152,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
@@ -160,7 +160,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq3 
   where key < 6
   ) subq4
@@ -170,7 +170,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
@@ -178,7 +178,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq3 
   where key < 6
   ) subq4
@@ -189,75 +189,75 @@ select count(*) from
 -- item, but that is not part of the join key.
 explain
 select count(*) from 
-  (select a.key as key, concat(a.value, a.value) as value from tbl1 a where key < 8) subq1 
+  (select a.key as key, concat(a.value, a.value) as value from tbl1_n10 a where key < 8) subq1 
     join
-  (select a.key as key, concat(a.value, a.value) as value from tbl2 a where key < 8) subq2
+  (select a.key as key, concat(a.value, a.value) as value from tbl2_n9 a where key < 8) subq2
   on subq1.key = subq2.key;
 
 select count(*) from 
-  (select a.key as key, concat(a.value, a.value) as value from tbl1 a where key < 8) subq1 
+  (select a.key as key, concat(a.value, a.value) as value from tbl1_n10 a where key < 8) subq1 
     join
-  (select a.key as key, concat(a.value, a.value) as value from tbl2 a where key < 8) subq2
+  (select a.key as key, concat(a.value, a.value) as value from tbl2_n9 a where key < 8) subq2
   on subq1.key = subq2.key;
 
 -- Since the join key is modified by the sub-query, neither sort-merge join not bucketized mapside
 -- join should be performed
 explain
 select count(*) from 
-  (select a.key +1 as key, concat(a.value, a.value) as value from tbl1 a) subq1 
+  (select a.key +1 as key, concat(a.value, a.value) as value from tbl1_n10 a) subq1 
     join
-  (select a.key +1 as key, concat(a.value, a.value) as value from tbl2 a) subq2
+  (select a.key +1 as key, concat(a.value, a.value) as value from tbl2_n9 a) subq2
   on subq1.key = subq2.key;
 
 select count(*) from 
-  (select a.key +1 as key, concat(a.value, a.value) as value from tbl1 a) subq1 
+  (select a.key +1 as key, concat(a.value, a.value) as value from tbl1_n10 a) subq1 
     join
-  (select a.key +1 as key, concat(a.value, a.value) as value from tbl2 a) subq2
+  (select a.key +1 as key, concat(a.value, a.value) as value from tbl2_n9 a) subq2
   on subq1.key = subq2.key;
 
 -- The left table is a sub-query and the right table is not.
 -- It should be converted to a sort-merge join.
 explain
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
-    join tbl2 a on subq1.key = a.key;
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
+    join tbl2_n9 a on subq1.key = a.key;
 
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
-    join tbl2 a on subq1.key = a.key;
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
+    join tbl2_n9 a on subq1.key = a.key;
 
 -- The right table is a sub-query and the left table is not.
 -- It should be converted to a sort-merge join.
 explain
-select count(*) from tbl1 a
+select count(*) from tbl1_n10 a
   join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq1 
   on a.key = subq1.key;
 
-select count(*) from tbl1 a
+select count(*) from tbl1_n10 a
   join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq1 
   on a.key = subq1.key;
 
 -- There are more than 2 inputs to the join, all of them being sub-queries. 
 -- It should be converted to to a sort-merge join
 explain
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on (subq1.key = subq2.key)
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq3
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq3
   on (subq1.key = subq3.key);
 
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on subq1.key = subq2.key
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq3
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq3
   on (subq1.key = subq3.key);
 
 -- The join is being performed on a nested sub-query, and an aggregation is performed after that.
@@ -268,11 +268,11 @@ select count(*) from (
   (
     select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1
     where key < 6
   ) subq2
-join tbl2 b
+join tbl2_n9 b
 on subq2.key = b.key) a;
 
 select count(*) from (
@@ -280,11 +280,11 @@ select count(*) from (
   (
     select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1
     where key < 6
   ) subq2
-join tbl2 b
+join tbl2_n9 b
 on subq2.key = b.key) a;
 
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
@@ -292,24 +292,24 @@ set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 -- The join is being performed as part of sub-query. It should be converted to a sort-merge join
 explain
 select count(*) from (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1;
 
 select count(*) from (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1;
 
 -- The join is being performed as part of sub-query. It should be converted to a sort-merge join
 explain
 select key, count(*) from 
 (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1
 group by key;
 
 select key, count(*) from 
 (
-  select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+  select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
 ) subq1
 group by key;
 
@@ -319,7 +319,7 @@ select count(*) from
 (
   select key, count(*) from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1
   group by key
 ) subq2;
@@ -328,7 +328,7 @@ select count(*) from
 (
   select key, count(*) from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1
   group by key
 ) subq2;
@@ -340,14 +340,14 @@ select src1.key, src1.cnt1, src2.cnt1 from
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1 group by key
 ) src1
 join
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq2 group by key
 ) src2
 on src1.key = src2.key;
@@ -356,14 +356,14 @@ select src1.key, src1.cnt1, src2.cnt1 from
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq1 group by key
 ) src1
 join
 (
   select key, count(*) as cnt1 from 
   (
-    select a.key as key, a.value as val1, b.value as val2 from tbl1 a join tbl2 b on a.key = b.key
+    select a.key as key, a.value as val1, b.value as val2 from tbl1_n10 a join tbl2_n9 b on a.key = b.key
   ) subq2 group by key
 ) src2
 on src1.key = src2.key;
@@ -372,15 +372,15 @@ on src1.key = src2.key;
 -- be converted to a sort-merge join.
 explain
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on subq1.key = subq2.key;
 
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on subq1.key = subq2.key;
 
 -- The subquery itself is being joined. Since the sub-query only contains selects and filters, it should 
@@ -390,22 +390,22 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
-  join tbl2 b
+  join tbl2_n9 b
   on subq2.key = b.key;
 
 select count(*) from 
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
-  join tbl2 b
+  join tbl2_n9 b
   on subq2.key = b.key;
 
 -- Both the tables are nested sub-queries i.e more then 1 level of sub-query.
@@ -415,7 +415,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
@@ -423,7 +423,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq3 
   where key < 6
   ) subq4
@@ -433,7 +433,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1 
   where key < 6
   ) subq2
@@ -441,7 +441,7 @@ select count(*) from
   (
   select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq3 
   where key < 6
   ) subq4
@@ -452,60 +452,60 @@ select count(*) from
 -- item, but that is not part of the join key.
 explain
 select count(*) from 
-  (select a.key as key, concat(a.value, a.value) as value from tbl1 a where key < 8) subq1 
+  (select a.key as key, concat(a.value, a.value) as value from tbl1_n10 a where key < 8) subq1 
     join
-  (select a.key as key, concat(a.value, a.value) as value from tbl2 a where key < 8) subq2
+  (select a.key as key, concat(a.value, a.value) as value from tbl2_n9 a where key < 8) subq2
   on subq1.key = subq2.key;
 
 select count(*) from 
-  (select a.key as key, concat(a.value, a.value) as value from tbl1 a where key < 8) subq1 
+  (select a.key as key, concat(a.value, a.value) as value from tbl1_n10 a where key < 8) subq1 
     join
-  (select a.key as key, concat(a.value, a.value) as value from tbl2 a where key < 8) subq2
+  (select a.key as key, concat(a.value, a.value) as value from tbl2_n9 a where key < 8) subq2
   on subq1.key = subq2.key;
 
 -- The left table is a sub-query and the right table is not.
 -- It should be converted to a sort-merge join.
 explain
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
-    join tbl2 a on subq1.key = a.key;
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
+    join tbl2_n9 a on subq1.key = a.key;
 
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
-    join tbl2 a on subq1.key = a.key;
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
+    join tbl2_n9 a on subq1.key = a.key;
 
 -- The right table is a sub-query and the left table is not.
 -- It should be converted to a sort-merge join.
 explain
-select count(*) from tbl1 a
+select count(*) from tbl1_n10 a
   join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq1 
   on a.key = subq1.key;
 
-select count(*) from tbl1 a
+select count(*) from tbl1_n10 a
   join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq1 
   on a.key = subq1.key;
 
 -- There are more than 2 inputs to the join, all of them being sub-queries. 
 -- It should be converted to to a sort-merge join
 explain
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on (subq1.key = subq2.key)
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq3
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq3
   on (subq1.key = subq3.key);
 
 select count(*) from 
-  (select a.key as key, a.value as value from tbl1 a where key < 6) subq1 
+  (select a.key as key, a.value as value from tbl1_n10 a where key < 6) subq1 
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq2
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq2
   on subq1.key = subq2.key
     join
-  (select a.key as key, a.value as value from tbl2 a where key < 6) subq3
+  (select a.key as key, a.value as value from tbl2_n9 a where key < 6) subq3
   on (subq1.key = subq3.key);
 
 -- The join is being performed on a nested sub-query, and an aggregation is performed after that.
@@ -516,11 +516,11 @@ select count(*) from (
   (
     select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1
     where key < 6
   ) subq2
-join tbl2 b
+join tbl2_n9 b
 on subq2.key = b.key) a;
 
 select count(*) from (
@@ -528,9 +528,9 @@ select count(*) from (
   (
     select * from
     (
-      select a.key as key, a.value as value from tbl1 a where key < 8
+      select a.key as key, a.value as value from tbl1_n10 a where key < 8
     ) subq1
     where key < 6
   ) subq2
-join tbl2 b
+join tbl2_n9 b
 on subq2.key = b.key) a;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/avro_add_column.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/avro_add_column.q b/ql/src/test/queries/clientpositive/avro_add_column.q
index 17dc2ff..fde9ab8 100644
--- a/ql/src/test/queries/clientpositive/avro_add_column.q
+++ b/ql/src/test/queries/clientpositive/avro_add_column.q
@@ -1,17 +1,17 @@
 -- SORT_QUERY_RESULTS
 
 -- verify that we can actually read avro files
-CREATE TABLE doctors (
+CREATE TABLE doctors_n0 (
   number int,
   first_name string)
 STORED AS AVRO;
 
-DESCRIBE doctors;
+DESCRIBE doctors_n0;
 
-ALTER TABLE doctors ADD COLUMNS (last_name string);
+ALTER TABLE doctors_n0 ADD COLUMNS (last_name string);
 
-DESCRIBE doctors;
+DESCRIBE doctors_n0;
 
-LOAD DATA LOCAL INPATH '../../data/files/doctors.avro' INTO TABLE doctors;
+LOAD DATA LOCAL INPATH '../../data/files/doctors.avro' INTO TABLE doctors_n0;
 
-SELECT * FROM doctors;
\ No newline at end of file
+SELECT * FROM doctors_n0;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/avro_add_column3.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/avro_add_column3.q b/ql/src/test/queries/clientpositive/avro_add_column3.q
index 939cb4f..692a86d 100644
--- a/ql/src/test/queries/clientpositive/avro_add_column3.q
+++ b/ql/src/test/queries/clientpositive/avro_add_column3.q
@@ -3,24 +3,24 @@ set hive.mapred.mode=nonstrict;
 -- SORT_QUERY_RESULTS
 
 -- verify that we can actually read avro files
-CREATE TABLE doctors (
+CREATE TABLE doctors_n3 (
   number int,
   first_name string,
   last_name string)
 STORED AS AVRO;
 
-LOAD DATA LOCAL INPATH '../../data/files/doctors.avro' INTO TABLE doctors;
+LOAD DATA LOCAL INPATH '../../data/files/doctors.avro' INTO TABLE doctors_n3;
 
-CREATE TABLE doctors_copy (
+CREATE TABLE doctors_copy_n0 (
   number int,
   first_name string)
 PARTITIONED BY (part int)
 STORED AS AVRO;
 
-INSERT INTO TABLE doctors_copy PARTITION(part=1) SELECT number, first_name FROM doctors;
+INSERT INTO TABLE doctors_copy_n0 PARTITION(part=1) SELECT number, first_name FROM doctors_n3;
 
-ALTER TABLE doctors_copy ADD COLUMNS (last_name string);
+ALTER TABLE doctors_copy_n0 ADD COLUMNS (last_name string);
 
-DESCRIBE doctors_copy;
+DESCRIBE doctors_copy_n0;
 
-SELECT * FROM doctors_copy;
\ No newline at end of file
+SELECT * FROM doctors_copy_n0;
\ No newline at end of file