http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin4.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin4.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin4.q
index d882a38..2957d4a 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin4.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin4.q
@@ -2,82 +2,82 @@ SET hive.vectorized.execution.enabled=false;
 set hive.strict.checks.bucketing=false;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
-CREATE TABLE srcbucket_mapjoin(key int, value string) CLUSTERED BY (key) INTO 
2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin;
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin;
+CREATE TABLE srcbucket_mapjoin_n17(key int, value string) CLUSTERED BY (key) 
INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_n17;
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_n17;
 
-CREATE TABLE srcbucket_mapjoin_part (key int, value string) partitioned by (ds 
string) CLUSTERED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000003_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
+CREATE TABLE srcbucket_mapjoin_part_n18 (key int, value string) partitioned by 
(ds string) CLUSTERED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_n18 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_n18 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part_n18 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000003_0' INTO TABLE 
srcbucket_mapjoin_part_n18 partition(ds='2008-04-08');
 
-CREATE TABLE srcbucket_mapjoin_part_2 (key int, value string) partitioned by 
(ds string) CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2 partition(ds='2008-04-08');
+CREATE TABLE srcbucket_mapjoin_part_2_n15 (key int, value string) partitioned 
by (ds string) CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2_n15 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2_n15 partition(ds='2008-04-08');
 
-create table bucketmapjoin_hash_result_1 (key bigint , value1 bigint, value2 
bigint);
-create table bucketmapjoin_hash_result_2 (key bigint , value1 bigint, value2 
bigint);
+create table bucketmapjoin_hash_result_1_n6 (key bigint , value1 bigint, 
value2 bigint);
+create table bucketmapjoin_hash_result_2_n6 (key bigint , value1 bigint, 
value2 bigint);
 
 set hive.optimize.bucketmapjoin = true;
-create table bucketmapjoin_tmp_result (key string , value1 string, value2 
string);
+create table bucketmapjoin_tmp_result_n8 (key string , value1 string, value2 
string);
 
 explain extended
-insert overwrite table bucketmapjoin_tmp_result
+insert overwrite table bucketmapjoin_tmp_result_n8
 select /*+mapjoin(b)*/ a.key, a.value, b.value
-from srcbucket_mapjoin a join srcbucket_mapjoin b
+from srcbucket_mapjoin_n17 a join srcbucket_mapjoin_n17 b
 on a.key=b.key;
 
-insert overwrite table bucketmapjoin_tmp_result
+insert overwrite table bucketmapjoin_tmp_result_n8
 select /*+mapjoin(b)*/ a.key, a.value, b.value
-from srcbucket_mapjoin a join srcbucket_mapjoin b
+from srcbucket_mapjoin_n17 a join srcbucket_mapjoin_n17 b
 on a.key=b.key;
 
-select count(1) from bucketmapjoin_tmp_result;
-insert overwrite table bucketmapjoin_hash_result_1
-select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result;
+select count(1) from bucketmapjoin_tmp_result_n8;
+insert overwrite table bucketmapjoin_hash_result_1_n6
+select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result_n8;
 
 set hive.optimize.bucketmapjoin = false;
-insert overwrite table bucketmapjoin_tmp_result
+insert overwrite table bucketmapjoin_tmp_result_n8
 select /*+mapjoin(b)*/ a.key, a.value, b.value
-from srcbucket_mapjoin a join srcbucket_mapjoin b
+from srcbucket_mapjoin_n17 a join srcbucket_mapjoin_n17 b
 on a.key=b.key;
 
-select count(1) from bucketmapjoin_tmp_result;
-insert overwrite table bucketmapjoin_hash_result_2
-select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result;
+select count(1) from bucketmapjoin_tmp_result_n8;
+insert overwrite table bucketmapjoin_hash_result_2_n6
+select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result_n8;
 
 select a.key-b.key, a.value1-b.value1, a.value2-b.value2
-from bucketmapjoin_hash_result_1 a left outer join bucketmapjoin_hash_result_2 
b
+from bucketmapjoin_hash_result_1_n6 a left outer join 
bucketmapjoin_hash_result_2_n6 b
 on a.key = b.key;
 
 
 set hive.optimize.bucketmapjoin = true;
 explain extended
-insert overwrite table bucketmapjoin_tmp_result
+insert overwrite table bucketmapjoin_tmp_result_n8
 select /*+mapjoin(a)*/ a.key, a.value, b.value
-from srcbucket_mapjoin a join srcbucket_mapjoin b
+from srcbucket_mapjoin_n17 a join srcbucket_mapjoin_n17 b
 on a.key=b.key;
 
-insert overwrite table bucketmapjoin_tmp_result
+insert overwrite table bucketmapjoin_tmp_result_n8
 select /*+mapjoin(a)*/ a.key, a.value, b.value
-from srcbucket_mapjoin a join srcbucket_mapjoin b
+from srcbucket_mapjoin_n17 a join srcbucket_mapjoin_n17 b
 on a.key=b.key;
 
-select count(1) from bucketmapjoin_tmp_result;
-insert overwrite table bucketmapjoin_hash_result_1
-select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result;
+select count(1) from bucketmapjoin_tmp_result_n8;
+insert overwrite table bucketmapjoin_hash_result_1_n6
+select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result_n8;
 
 set hive.optimize.bucketmapjoin = false;
-insert overwrite table bucketmapjoin_tmp_result
+insert overwrite table bucketmapjoin_tmp_result_n8
 select /*+mapjoin(a)*/ a.key, a.value, b.value
-from srcbucket_mapjoin a join srcbucket_mapjoin b
+from srcbucket_mapjoin_n17 a join srcbucket_mapjoin_n17 b
 on a.key=b.key;
 
-select count(1) from bucketmapjoin_tmp_result;
-insert overwrite table bucketmapjoin_hash_result_2
-select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result;
+select count(1) from bucketmapjoin_tmp_result_n8;
+insert overwrite table bucketmapjoin_hash_result_2_n6
+select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) from 
bucketmapjoin_tmp_result_n8;
 
 select a.key-b.key, a.value1-b.value1, a.value2-b.value2
-from bucketmapjoin_hash_result_1 a left outer join bucketmapjoin_hash_result_2 
b
+from bucketmapjoin_hash_result_1_n6 a left outer join 
bucketmapjoin_hash_result_2_n6 b
 on a.key = b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin5.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin5.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin5.q
index 7b09e7a..c2737cc 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin5.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin5.q
@@ -2,19 +2,19 @@ SET hive.vectorized.execution.enabled=false;
 set hive.strict.checks.bucketing=false;
 
 set hive.mapred.mode=nonstrict;
-CREATE TABLE srcbucket_mapjoin(key int, value string) CLUSTERED BY (key) INTO 
2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin;
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin;
-
-CREATE TABLE srcbucket_mapjoin_part (key int, value string) partitioned by (ds 
string) CLUSTERED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000003_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-09');
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-09');
-load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-09');
-load data local inpath '../../data/files/bmj/000003_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-09');
+CREATE TABLE srcbucket_mapjoin_n0(key int, value string) CLUSTERED BY (key) 
INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_n0;
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_n0;
+
+CREATE TABLE srcbucket_mapjoin_part_n0 (key int, value string) partitioned by 
(ds string) CLUSTERED BY (key) INTO 4 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000003_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-09');
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-09');
+load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-09');
+load data local inpath '../../data/files/bmj/000003_0' INTO TABLE 
srcbucket_mapjoin_part_n0 partition(ds='2008-04-09');
 
 CREATE TABLE srcbucket_mapjoin_part_2 (key int, value string) partitioned by 
(ds string) CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
 load data local inpath '../../data/files/bmj2/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 partition(ds='2008-04-08');
@@ -31,12 +31,12 @@ create table bucketmapjoin_tmp_result (key string , value1 
string, value2 string
 explain extended
 insert overwrite table bucketmapjoin_tmp_result 
 select /*+mapjoin(a)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part b 
+from srcbucket_mapjoin_n0 a join srcbucket_mapjoin_part_n0 b 
 on a.key=b.key;
 
 insert overwrite table bucketmapjoin_tmp_result 
 select /*+mapjoin(a)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part b 
+from srcbucket_mapjoin_n0 a join srcbucket_mapjoin_part_n0 b 
 on a.key=b.key;
 
 select count(1) from bucketmapjoin_tmp_result;
@@ -46,7 +46,7 @@ select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) 
from bucketmapjoin_t
 set hive.optimize.bucketmapjoin = false;
 insert overwrite table bucketmapjoin_tmp_result 
 select /*+mapjoin(a)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part b 
+from srcbucket_mapjoin_n0 a join srcbucket_mapjoin_part_n0 b 
 on a.key=b.key;
 
 select count(1) from bucketmapjoin_tmp_result;
@@ -62,12 +62,12 @@ set hive.optimize.bucketmapjoin = true;
 explain extended
 insert overwrite table bucketmapjoin_tmp_result 
 select /*+mapjoin(a)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part_2 b 
+from srcbucket_mapjoin_n0 a join srcbucket_mapjoin_part_2 b 
 on a.key=b.key;
 
 insert overwrite table bucketmapjoin_tmp_result 
 select /*+mapjoin(a)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part_2 b 
+from srcbucket_mapjoin_n0 a join srcbucket_mapjoin_part_2 b 
 on a.key=b.key;
 
 select count(1) from bucketmapjoin_tmp_result;
@@ -77,7 +77,7 @@ select sum(hash(key)), sum(hash(value1)), sum(hash(value2)) 
from bucketmapjoin_t
 set hive.optimize.bucketmapjoin = false;
 insert overwrite table bucketmapjoin_tmp_result 
 select /*+mapjoin(a)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part_2 b 
+from srcbucket_mapjoin_n0 a join srcbucket_mapjoin_part_2 b 
 on a.key=b.key;
 
 select count(1) from bucketmapjoin_tmp_result;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin7.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin7.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin7.q
index cbd690f..917a4a1 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin7.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin7.q
@@ -4,15 +4,15 @@ set hive.cbo.enable=false;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
 
-CREATE TABLE srcbucket_mapjoin_part_1 (key INT, value STRING) PARTITIONED BY 
(ds STRING, hr STRING) 
+CREATE TABLE srcbucket_mapjoin_part_1_n4 (key INT, value STRING) PARTITIONED 
BY (ds STRING, hr STRING) 
 CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_1 PARTITION (ds='2008-04-08', hr='0');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_1 PARTITION (ds='2008-04-08', hr='0');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_1_n4 PARTITION (ds='2008-04-08', hr='0');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_1_n4 PARTITION (ds='2008-04-08', hr='0');
 
-CREATE TABLE srcbucket_mapjoin_part_2 (key INT, value STRING) PARTITIONED BY 
(ds STRING, hr STRING) 
+CREATE TABLE srcbucket_mapjoin_part_2_n9 (key INT, value STRING) PARTITIONED 
BY (ds STRING, hr STRING) 
 CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (ds='2008-04-08', hr='0');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (ds='2008-04-08', hr='0');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2_n9 PARTITION (ds='2008-04-08', hr='0');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2_n9 PARTITION (ds='2008-04-08', hr='0');
 
 set hive.optimize.bucketmapjoin=true;
 
@@ -20,11 +20,11 @@ set hive.optimize.bucketmapjoin=true;
 
 EXPLAIN EXTENDED
 SELECT /*+ MAPJOIN(b) */ a.key, b.value
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n4 a JOIN srcbucket_mapjoin_part_2_n9 b
 ON a.key = b.key AND a.ds = '2008-04-08' AND b.ds = '2008-04-08'
 ORDER BY a.key, b.value LIMIT 1;
 
 SELECT /*+ MAPJOIN(b) */ a.key, b.value
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n4 a JOIN srcbucket_mapjoin_part_2_n9 b
 ON a.key = b.key AND a.ds = '2008-04-08' AND b.ds = '2008-04-08'
 ORDER BY a.key, b.value LIMIT 1;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin8.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin8.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin8.q
index 15c52db..ce05e34 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin8.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin8.q
@@ -4,17 +4,17 @@ set hive.strict.checks.bucketing=false;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
 
-CREATE TABLE srcbucket_mapjoin_part_1 (key INT, value STRING) PARTITIONED BY 
(part STRING) 
+CREATE TABLE srcbucket_mapjoin_part_1_n1 (key INT, value STRING) PARTITIONED 
BY (part STRING) 
 CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_1 PARTITION (part='1');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_1 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_1_n1 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_1_n1 PARTITION (part='1');
 
-CREATE TABLE srcbucket_mapjoin_part_2 (key INT, value STRING) PARTITIONED BY 
(part STRING) 
+CREATE TABLE srcbucket_mapjoin_part_2_n4 (key INT, value STRING) PARTITIONED 
BY (part STRING) 
 CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (part='1');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2_n4 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2_n4 PARTITION (part='1');
 
-ALTER TABLE srcbucket_mapjoin_part_2 CLUSTERED BY (key) INTO 3 BUCKETS;
+ALTER TABLE srcbucket_mapjoin_part_2_n4 CLUSTERED BY (key) INTO 3 BUCKETS;
 
 set hive.optimize.bucketmapjoin=true;
 set hive.cbo.enable=false;
@@ -22,22 +22,22 @@ set hive.cbo.enable=false;
 
 EXPLAIN EXTENDED
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n1 a JOIN srcbucket_mapjoin_part_2_n4 b
 ON a.key = b.key AND a.part = '1' and b.part = '1';
 
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n1 a JOIN srcbucket_mapjoin_part_2_n4 b
 ON a.key = b.key AND a.part = '1' and b.part = '1';
 
-ALTER TABLE srcbucket_mapjoin_part_2 CLUSTERED BY (value) INTO 2 BUCKETS;
+ALTER TABLE srcbucket_mapjoin_part_2_n4 CLUSTERED BY (value) INTO 2 BUCKETS;
 
 -- The partition bucketing metadata match but the tables are bucketed on 
different columns, bucket map join should still be used
 
 EXPLAIN EXTENDED
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n1 a JOIN srcbucket_mapjoin_part_2_n4 b
 ON a.key = b.key AND a.part = '1' and b.part = '1';
 
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n1 a JOIN srcbucket_mapjoin_part_2_n4 b
 ON a.key = b.key AND a.part = '1' and b.part = '1';

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin9.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin9.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin9.q
index d6ebd06..6cfebba 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin9.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin9.q
@@ -5,18 +5,18 @@ set hive.strict.checks.bucketing=false;
 
 set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
 
-CREATE TABLE srcbucket_mapjoin_part_1 (key INT, value STRING) PARTITIONED BY 
(part STRING) 
+CREATE TABLE srcbucket_mapjoin_part_1_n5 (key INT, value STRING) PARTITIONED 
BY (part STRING) 
 CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_1 PARTITION (part='1');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_1 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_1_n5 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_1_n5 PARTITION (part='1');
 
-CREATE TABLE srcbucket_mapjoin_part_2 (key INT, value STRING) PARTITIONED BY 
(part STRING) 
+CREATE TABLE srcbucket_mapjoin_part_2_n12 (key INT, value STRING) PARTITIONED 
BY (part STRING) 
 CLUSTERED BY (key) INTO 3 BUCKETS STORED AS TEXTFILE;
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (part='1');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (part='1');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2_n12 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2_n12 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part_2_n12 PARTITION (part='1');
 
-ALTER TABLE srcbucket_mapjoin_part_2 CLUSTERED BY (key) INTO 2 BUCKETS;
+ALTER TABLE srcbucket_mapjoin_part_2_n12 CLUSTERED BY (key) INTO 2 BUCKETS;
 
 set hive.optimize.bucketmapjoin=true;
 
@@ -25,27 +25,27 @@ set hive.cbo.enable=false;
 
 EXPLAIN EXTENDED
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n5 a JOIN srcbucket_mapjoin_part_2_n12 b
 ON a.key = b.key AND a.part = '1' and b.part = '1';
 
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n5 a JOIN srcbucket_mapjoin_part_2_n12 b
 ON a.key = b.key AND a.part = '1' and b.part = '1';
 
-ALTER TABLE srcbucket_mapjoin_part_2 DROP PARTITION (part='1');
-ALTER TABLE srcbucket_mapjoin_part_2 CLUSTERED BY (value) INTO 2 BUCKETS;
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (part='1');
-LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2 PARTITION (part='1');
+ALTER TABLE srcbucket_mapjoin_part_2_n12 DROP PARTITION (part='1');
+ALTER TABLE srcbucket_mapjoin_part_2_n12 CLUSTERED BY (value) INTO 2 BUCKETS;
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2_n12 PARTITION (part='1');
+LOAD DATA LOCAL INPATH '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2_n12 PARTITION (part='1');
 
-ALTER TABLE srcbucket_mapjoin_part_2 CLUSTERED BY (key) INTO 2 BUCKETS;
+ALTER TABLE srcbucket_mapjoin_part_2_n12 CLUSTERED BY (key) INTO 2 BUCKETS;
 
 -- The table bucketing metadata matches but the partitions are bucketed on 
different columns, bucket map join should not be used
 
 EXPLAIN EXTENDED
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n5 a JOIN srcbucket_mapjoin_part_2_n12 b
 ON a.key = b.key AND a.part = '1' AND b.part = '1';
 
 SELECT /*+ MAPJOIN(b) */ count(*)
-FROM srcbucket_mapjoin_part_1 a JOIN srcbucket_mapjoin_part_2 b
+FROM srcbucket_mapjoin_part_1_n5 a JOIN srcbucket_mapjoin_part_2_n12 b
 ON a.key = b.key AND a.part = '1' AND b.part = '1';

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin_negative.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin_negative.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin_negative.q
index aa207a8..7c38238 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin_negative.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin_negative.q
@@ -1,24 +1,24 @@
 set hive.strict.checks.bucketing=false;
 
-CREATE TABLE srcbucket_mapjoin(key int, value string) CLUSTERED BY (key) INTO 
2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin;
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin;
+CREATE TABLE srcbucket_mapjoin_n10(key int, value string) CLUSTERED BY (key) 
INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_n10;
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_n10;
 
-CREATE TABLE srcbucket_mapjoin_part (key int, value string) partitioned by (ds 
string) CLUSTERED BY (key) INTO 3 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part partition(ds='2008-04-08');
+CREATE TABLE srcbucket_mapjoin_part_n10 (key int, value string) partitioned by 
(ds string) CLUSTERED BY (key) INTO 3 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_part_n10 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_part_n10 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj/000002_0' INTO TABLE 
srcbucket_mapjoin_part_n10 partition(ds='2008-04-08');
 
 
 
 set hive.cbo.enable=false;
 set hive.optimize.bucketmapjoin = true;
-create table bucketmapjoin_tmp_result (key string , value1 string, value2 
string);
+create table bucketmapjoin_tmp_result_n4 (key string , value1 string, value2 
string);
 
 explain extended
-insert overwrite table bucketmapjoin_tmp_result 
+insert overwrite table bucketmapjoin_tmp_result_n4 
 select /*+mapjoin(b)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part b 
+from srcbucket_mapjoin_n10 a join srcbucket_mapjoin_part_n10 b 
 on a.key=b.key where b.ds="2008-04-08";
 
 

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin_negative2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin_negative2.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin_negative2.q
index c0db5df..c8538d7 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin_negative2.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin_negative2.q
@@ -1,21 +1,21 @@
 set hive.strict.checks.bucketing=false;
 
 set hive.mapred.mode=nonstrict;
-CREATE TABLE srcbucket_mapjoin(key int, value string) CLUSTERED BY (key) INTO 
2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin;
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin;
+CREATE TABLE srcbucket_mapjoin_n5(key int, value string) CLUSTERED BY (key) 
INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE 
srcbucket_mapjoin_n5;
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE 
srcbucket_mapjoin_n5;
 
-CREATE TABLE srcbucket_mapjoin_part_2 (key int, value string) partitioned by 
(ds string) CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
-load data local inpath '../../data/files/bmj2/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj2/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2 partition(ds='2008-04-08');
-load data local inpath '../../data/files/bmj2/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2 partition(ds='2008-04-09');
-load data local inpath '../../data/files/bmj2/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2 partition(ds='2008-04-09');
+CREATE TABLE srcbucket_mapjoin_part_2_n7 (key int, value string) partitioned 
by (ds string) CLUSTERED BY (key) INTO 2 BUCKETS STORED AS TEXTFILE;
+load data local inpath '../../data/files/bmj2/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2_n7 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj2/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2_n7 partition(ds='2008-04-08');
+load data local inpath '../../data/files/bmj2/000000_0' INTO TABLE 
srcbucket_mapjoin_part_2_n7 partition(ds='2008-04-09');
+load data local inpath '../../data/files/bmj2/000001_0' INTO TABLE 
srcbucket_mapjoin_part_2_n7 partition(ds='2008-04-09');
 set hive.cbo.enable=false;
 set hive.optimize.bucketmapjoin = true;
-create table bucketmapjoin_tmp_result (key string , value1 string, value2 
string);
+create table bucketmapjoin_tmp_result_n3 (key string , value1 string, value2 
string);
 
 explain extended
-insert overwrite table bucketmapjoin_tmp_result 
+insert overwrite table bucketmapjoin_tmp_result_n3 
 select /*+mapjoin(b)*/ a.key, a.value, b.value 
-from srcbucket_mapjoin a join srcbucket_mapjoin_part_2 b 
+from srcbucket_mapjoin_n5 a join srcbucket_mapjoin_part_2_n7 b 
 on a.key=b.key;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketmapjoin_negative3.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketmapjoin_negative3.q 
b/ql/src/test/queries/clientpositive/bucketmapjoin_negative3.q
index 5d319b6..e301b9a 100644
--- a/ql/src/test/queries/clientpositive/bucketmapjoin_negative3.q
+++ b/ql/src/test/queries/clientpositive/bucketmapjoin_negative3.q
@@ -1,22 +1,22 @@
 set hive.strict.checks.bucketing=false;
 
-drop table test1;
-drop table test2;
+drop table test1_n11;
+drop table test2_n7;
 drop table test3;
 drop table test4;
 
-create table test1 (key string, value string) clustered by (key) sorted by 
(key) into 3 buckets;
-create table test2 (key string, value string) clustered by (value) sorted by 
(value) into 3 buckets;
+create table test1_n11 (key string, value string) clustered by (key) sorted by 
(key) into 3 buckets;
+create table test2_n7 (key string, value string) clustered by (value) sorted 
by (value) into 3 buckets;
 create table test3 (key string, value string) clustered by (key, value) sorted 
by (key, value) into 3 buckets;
 create table test4 (key string, value string) clustered by (value, key) sorted 
by (value, key) into 3 buckets;
 
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE test1;
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE test1;
-load data local inpath '../../data/files/bmj/000002_0' INTO TABLE test1;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE test1_n11;
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE test1_n11;
+load data local inpath '../../data/files/bmj/000002_0' INTO TABLE test1_n11;
 
-load data local inpath '../../data/files/bmj/000000_0' INTO TABLE test2;
-load data local inpath '../../data/files/bmj/000001_0' INTO TABLE test2;
-load data local inpath '../../data/files/bmj/000002_0' INTO TABLE test2;
+load data local inpath '../../data/files/bmj/000000_0' INTO TABLE test2_n7;
+load data local inpath '../../data/files/bmj/000001_0' INTO TABLE test2_n7;
+load data local inpath '../../data/files/bmj/000002_0' INTO TABLE test2_n7;
 
 load data local inpath '../../data/files/bmj/000000_0' INTO TABLE test3;
 load data local inpath '../../data/files/bmj/000001_0' INTO TABLE test3;
@@ -28,14 +28,14 @@ load data local inpath '../../data/files/bmj/000002_0' INTO 
TABLE test4;
 set hive.cbo.enable=false;
 set hive.optimize.bucketmapjoin = true;
 -- should be allowed
-explain extended select /*+ MAPJOIN(R) */ * from test1 L join test1 R on 
L.key=R.key AND L.value=R.value;
-explain extended select /*+ MAPJOIN(R) */ * from test2 L join test2 R on 
L.key=R.key AND L.value=R.value;
+explain extended select /*+ MAPJOIN(R) */ * from test1_n11 L join test1_n11 R 
on L.key=R.key AND L.value=R.value;
+explain extended select /*+ MAPJOIN(R) */ * from test2_n7 L join test2_n7 R on 
L.key=R.key AND L.value=R.value;
 
 -- should not apply bucket mapjoin
-explain extended select /*+ MAPJOIN(R) */ * from test1 L join test1 R on 
L.key+L.key=R.key;
-explain extended select /*+ MAPJOIN(R) */ * from test1 L join test2 R on 
L.key=R.key AND L.value=R.value;
-explain extended select /*+ MAPJOIN(R) */ * from test1 L join test3 R on 
L.key=R.key AND L.value=R.value;
-explain extended select /*+ MAPJOIN(R) */ * from test1 L join test4 R on 
L.key=R.key AND L.value=R.value;
-explain extended select /*+ MAPJOIN(R) */ * from test2 L join test3 R on 
L.key=R.key AND L.value=R.value;
-explain extended select /*+ MAPJOIN(R) */ * from test2 L join test4 R on 
L.key=R.key AND L.value=R.value;
+explain extended select /*+ MAPJOIN(R) */ * from test1_n11 L join test1_n11 R 
on L.key+L.key=R.key;
+explain extended select /*+ MAPJOIN(R) */ * from test1_n11 L join test2_n7 R 
on L.key=R.key AND L.value=R.value;
+explain extended select /*+ MAPJOIN(R) */ * from test1_n11 L join test3 R on 
L.key=R.key AND L.value=R.value;
+explain extended select /*+ MAPJOIN(R) */ * from test1_n11 L join test4 R on 
L.key=R.key AND L.value=R.value;
+explain extended select /*+ MAPJOIN(R) */ * from test2_n7 L join test3 R on 
L.key=R.key AND L.value=R.value;
+explain extended select /*+ MAPJOIN(R) */ * from test2_n7 L join test4 R on 
L.key=R.key AND L.value=R.value;
 explain extended select /*+ MAPJOIN(R) */ * from test3 L join test4 R on 
L.key=R.key AND L.value=R.value;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_1.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_1.q
index d5791e1..5bfdf48 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_1.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_1.q
@@ -11,70 +11,70 @@ set hive.merge.mapredfiles=false;
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table1_n5 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table2_n5 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT *;
+INSERT OVERWRITE TABLE test_table1_n5 PARTITION (ds = '1') SELECT *;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n5 PARTITION (ds = '1')
 SELECT x.key, x.value from 
 (
-SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1'
+SELECT a.key, a.value FROM test_table1_n5 a WHERE a.ds = '1'
 )x;
 
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n5 PARTITION (ds = '1')
 SELECT x.key, x.value from 
 (
-SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1'
+SELECT a.key, a.value FROM test_table1_n5 a WHERE a.ds = '1'
 )x;
 
-select count(*) from test_table2 where ds = '1';
-select count(*) from test_table2 tablesample (bucket 1 out of 2) s where ds = 
'1';
-select count(*) from test_table2 tablesample (bucket 2 out of 2) s where ds = 
'1';
+select count(*) from test_table2_n5 where ds = '1';
+select count(*) from test_table2_n5 tablesample (bucket 1 out of 2) s where ds 
= '1';
+select count(*) from test_table2_n5 tablesample (bucket 2 out of 2) s where ds 
= '1';
 
 EXPLAIN
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n5 PARTITION (ds = '1')
 SELECT * from 
 (
-SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1'
+SELECT a.key, a.value FROM test_table1_n5 a WHERE a.ds = '1'
 )x;
 
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n5 PARTITION (ds = '1')
 SELECT * from 
 (
-SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1'
+SELECT a.key, a.value FROM test_table1_n5 a WHERE a.ds = '1'
 )x;
 
-select count(*) from test_table2 where ds = '1';
-select count(*) from test_table2 tablesample (bucket 1 out of 2) s where ds = 
'1';
-select count(*) from test_table2 tablesample (bucket 2 out of 2) s where ds = 
'1';
+select count(*) from test_table2_n5 where ds = '1';
+select count(*) from test_table2_n5 tablesample (bucket 1 out of 2) s where ds 
= '1';
+select count(*) from test_table2_n5 tablesample (bucket 2 out of 2) s where ds 
= '1';
 
 -- it should be a map-only job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n5 PARTITION (ds = '1')
 SELECT x.key, concat(x.value, x.value) from 
 (
-SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1'
+SELECT a.key, a.value FROM test_table1_n5 a WHERE a.ds = '1'
 )x;
 
 -- it should be a map-reduce job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n5 PARTITION (ds = '1')
 SELECT x.key+x.key, x.value from 
 (
-SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1'
+SELECT a.key, a.value FROM test_table1_n5 a WHERE a.ds = '1'
 )x;
 
 -- it should be a map-only job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n5 PARTITION (ds = '1')
 SELECT x.k1, concat(x.v1, x.v1) from 
 (
-SELECT a.key as k1, a.value as v1 FROM test_table1 a WHERE a.ds = '1'
+SELECT a.key as k1, a.value as v1 FROM test_table1_n5 a WHERE a.ds = '1'
 )x;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_2.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_2.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_2.q
index fadd178..0b913ca 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_2.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_2.q
@@ -17,132 +17,132 @@ set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 set hive.auto.convert.join.noconditionaltask.size=10;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table1_n0 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table2_n0 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table3 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table3_n0 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT * where key < 
10;
+INSERT OVERWRITE TABLE test_table1_n0 PARTITION (ds = '1') SELECT * where key 
< 10;
 
 FROM src
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1') SELECT * where key < 
100;
+INSERT OVERWRITE TABLE test_table2_n0 PARTITION (ds = '1') SELECT * where key 
< 100;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '2') SELECT * where key < 
10;
+INSERT OVERWRITE TABLE test_table1_n0 PARTITION (ds = '2') SELECT * where key 
< 10;
 
 FROM src
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '2') SELECT * where key < 
100;
+INSERT OVERWRITE TABLE test_table2_n0 PARTITION (ds = '2') SELECT * where key 
< 100;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n0 a JOIN test_table2_n0 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n0 a JOIN test_table2_n0 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- Since more than one partition of 'a' (the big table) is being selected,
 -- it should be a map-reduce job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n0 a JOIN test_table2_n0 b 
 ON a.key = b.key WHERE a.ds is not null and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n0 a JOIN test_table2_n0 b 
 ON a.key = b.key WHERE a.ds is not null and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- Since a single partition of the big table ('a') is being selected, it 
should be a map-only
 -- job even though multiple partitions of 'b' are being selected
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n0 a JOIN test_table2_n0 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds is not null;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n0 a JOIN test_table2_n0 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds is not null;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- This should be a map-only job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1') a 
+(select key, value from test_table1_n0 where ds = '1') a 
 JOIN 
-(select key, value from test_table2 where ds = '1') b 
+(select key, value from test_table2_n0 where ds = '1') b 
 ON a.key = b.key;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1') a 
+(select key, value from test_table1_n0 where ds = '1') a 
 JOIN 
-(select key, value from test_table2 where ds = '1') b 
+(select key, value from test_table2_n0 where ds = '1') b 
 ON a.key = b.key;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- This should be a map-only job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.v1, b.v2) 
 FROM 
-(select key, concat(value, value) as v1 from test_table1 where ds = '1') a 
+(select key, concat(value, value) as v1 from test_table1_n0 where ds = '1') a 
 JOIN 
-(select key, concat(value, value) as v2 from test_table2 where ds = '1') b 
+(select key, concat(value, value) as v2 from test_table2_n0 where ds = '1') b 
 ON a.key = b.key;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key, concat(a.v1, b.v2) 
 FROM 
-(select key, concat(value, value) as v1 from test_table1 where ds = '1') a 
+(select key, concat(value, value) as v1 from test_table1_n0 where ds = '1') a 
 JOIN 
-(select key, concat(value, value) as v2 from test_table2 where ds = '1') b 
+(select key, concat(value, value) as v2 from test_table2_n0 where ds = '1') b 
 ON a.key = b.key;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- This should be a map-reduce job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key+a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1') a 
+(select key, value from test_table1_n0 where ds = '1') a 
 JOIN 
-(select key, value from test_table2 where ds = '1') b 
+(select key, value from test_table2_n0 where ds = '1') b 
 ON a.key = b.key;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n0 PARTITION (ds = '1')
 SELECT a.key+a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1') a 
+(select key, value from test_table1_n0 where ds = '1') a 
 JOIN 
-(select key, value from test_table2 where ds = '1') b 
+(select key, value from test_table2_n0 where ds = '1') b 
 ON a.key = b.key;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n0 tablesample (bucket 2 out of 2) s where ds = '1';

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_3.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_3.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_3.q
index 7c44d70..289d10e 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_3.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_3.q
@@ -11,44 +11,44 @@ set hive.merge.mapredfiles=false;
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table1_n19 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (value STRING, key INT) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table2_n18 (value STRING, key INT) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT *;
+INSERT OVERWRITE TABLE test_table1_n19 PARTITION (ds = '1') SELECT *;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- The bucketing positions dont match - although the actual bucketing do.
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n18 PARTITION (ds = '1')
 SELECT x.value, x.key from 
-(SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1')x;
+(SELECT a.key, a.value FROM test_table1_n19 a WHERE a.ds = '1')x;
 
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n18 PARTITION (ds = '1')
 SELECT x.value, x.key from 
-(SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1')x;
+(SELECT a.key, a.value FROM test_table1_n19 a WHERE a.ds = '1')x;
 
-select count(*) from test_table2 where ds = '1';
-select count(*) from test_table2 tablesample (bucket 1 out of 2) s where ds = 
'1';
-select count(*) from test_table2 tablesample (bucket 2 out of 2) s where ds = 
'1';
+select count(*) from test_table2_n18 where ds = '1';
+select count(*) from test_table2_n18 tablesample (bucket 1 out of 2) s where 
ds = '1';
+select count(*) from test_table2_n18 tablesample (bucket 2 out of 2) s where 
ds = '1';
 
-CREATE TABLE test_table3 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table3_n10 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (value) SORTED BY (value) INTO 2 BUCKETS;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- The bucketing positions dont match - this should be a map-reduce operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n18 PARTITION (ds = '1')
 SELECT x.key, x.value from 
-(SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1')x;
+(SELECT a.key, a.value FROM test_table1_n19 a WHERE a.ds = '1')x;
 
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table2_n18 PARTITION (ds = '1')
 SELECT x.key, x.value from 
-(SELECT a.key, a.value FROM test_table1 a WHERE a.ds = '1')x;
+(SELECT a.key, a.value FROM test_table1_n19 a WHERE a.ds = '1')x;
 
-select count(*) from test_table2 where ds = '1';
-select count(*) from test_table2 tablesample (bucket 1 out of 2) s where ds = 
'1';
-select count(*) from test_table2 tablesample (bucket 2 out of 2) s where ds = 
'1';
+select count(*) from test_table2_n18 where ds = '1';
+select count(*) from test_table2_n18 tablesample (bucket 1 out of 2) s where 
ds = '1';
+select count(*) from test_table2_n18 tablesample (bucket 2 out of 2) s where 
ds = '1';

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_4.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_4.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_4.q
index 4189c54..25bb872 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_4.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_4.q
@@ -15,54 +15,54 @@ set 
hive.auto.convert.sortmerge.join.bigtable.selection.policy=org.apache.hadoop
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table1_n16 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table2_n15 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table3 (key INT, key2 INT, value STRING) PARTITIONED BY (ds 
STRING)
+CREATE TABLE test_table3_n8 (key INT, key2 INT, value STRING) PARTITIONED BY 
(ds STRING)
 CLUSTERED BY (key2) SORTED BY (key2) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT * where key < 
10;
+INSERT OVERWRITE TABLE test_table1_n16 PARTITION (ds = '1') SELECT * where key 
< 10;
 
 FROM src
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1') SELECT * where key < 
100;
+INSERT OVERWRITE TABLE test_table2_n15 PARTITION (ds = '1') SELECT * where key 
< 100;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation, since the insert is happening on the 
bucketing position
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n8 PARTITION (ds = '1')
 SELECT a.key, a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n16 a JOIN test_table2_n15 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n8 PARTITION (ds = '1')
 SELECT a.key, a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n16 a JOIN test_table2_n15 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n8 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n8 tablesample (bucket 2 out of 2) s where ds = '1';
 
-DROP TABLE test_table3;
+DROP TABLE test_table3_n8;
 
-CREATE TABLE test_table3 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table3_n8 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (value) SORTED BY (value) INTO 2 BUCKETS;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-reduce operation, since the insert is happening on a 
non-bucketing position
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n8 PARTITION (ds = '1')
 SELECT a.key, a.value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n16 a JOIN test_table2_n15 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n8 PARTITION (ds = '1')
 SELECT a.key, a.value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n16 a JOIN test_table2_n15 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n8 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n8 tablesample (bucket 2 out of 2) s where ds = '1';
 
-DROP TABLE test_table3;
+DROP TABLE test_table3_n8;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_5.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_5.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_5.q
index c9c617d..038c03c 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_5.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_5.q
@@ -15,52 +15,52 @@ set 
hive.auto.convert.sortmerge.join.bigtable.selection.policy=org.apache.hadoop
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table1_n8 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table2_n8 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table3 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table3_n5 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key desc) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT * where key < 
10;
+INSERT OVERWRITE TABLE test_table1_n8 PARTITION (ds = '1') SELECT * where key 
< 10;
 
 FROM src
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1') SELECT * where key < 
100;
+INSERT OVERWRITE TABLE test_table2_n8 PARTITION (ds = '1') SELECT * where key 
< 100;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-reduce operation, since the sort-order does not match
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n5 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n8 a JOIN test_table2_n8 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n5 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n8 a JOIN test_table2_n8 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n5 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n5 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- This should be a map-reduce job since the sort order does not match
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n5 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1') a 
+(select key, value from test_table1_n8 where ds = '1') a 
 JOIN 
-(select key, value from test_table2 where ds = '1') b 
+(select key, value from test_table2_n8 where ds = '1') b 
 ON a.key = b.key;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n5 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1') a 
+(select key, value from test_table1_n8 where ds = '1') a 
 JOIN 
-(select key, value from test_table2 where ds = '1') b 
+(select key, value from test_table2_n8 where ds = '1') b 
 ON a.key = b.key;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n5 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n5 tablesample (bucket 2 out of 2) s where ds = '1';

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_6.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_6.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_6.q
index af2ab96..cd0a234 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_6.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_6.q
@@ -15,132 +15,132 @@ set 
hive.auto.convert.sortmerge.join.bigtable.selection.policy=org.apache.hadoop
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, key2 INT, value STRING) PARTITIONED BY (ds 
STRING)
+CREATE TABLE test_table1_n3 (key INT, key2 INT, value STRING) PARTITIONED BY 
(ds STRING)
 CLUSTERED BY (key, key2) SORTED BY (key ASC, key2 DESC) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (key INT, key2 INT, value STRING) PARTITIONED BY (ds 
STRING)
+CREATE TABLE test_table2_n3 (key INT, key2 INT, value STRING) PARTITIONED BY 
(ds STRING)
 CLUSTERED BY (key, key2) SORTED BY (key ASC, key2 DESC) INTO 2 BUCKETS;
-CREATE TABLE test_table3 (key INT, key2 INT, value STRING) PARTITIONED BY (ds 
STRING)
+CREATE TABLE test_table3_n3 (key INT, key2 INT, value STRING) PARTITIONED BY 
(ds STRING)
 CLUSTERED BY (key, key2) SORTED BY (key ASC, key2 DESC) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT key, key+1, 
value where key < 10;
+INSERT OVERWRITE TABLE test_table1_n3 PARTITION (ds = '1') SELECT key, key+1, 
value where key < 10;
 
 FROM src
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1') SELECT key, key+1, 
value where key < 100;
+INSERT OVERWRITE TABLE test_table2_n3 PARTITION (ds = '1') SELECT key, key+1, 
value where key < 100;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation, since the sort-order matches
 set hive.auto.convert.join.noconditionaltask.size=800;
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT a.key, a.key2, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT a.key, a.key2, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation, since the sort-order matches
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT subq1.key, subq1.key2, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT subq1.key, subq1.key2, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-reduce operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT a.key2, a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1';
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-reduce operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT subq1.key2, subq1.key, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT subq2.key, subq2.key2, subq2.value from
 (
 SELECT subq1.key2, subq1.key, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1
 )subq2;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT subq2.key, subq2.key2, subq2.value from
 (
 SELECT subq1.key2, subq1.key, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1
 )subq2;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT subq2.k2, subq2.k1, subq2.value from
 (
 SELECT subq1.key2 as k1, subq1.key as k2, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1
 )subq2;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n3 PARTITION (ds = '1')
 SELECT subq2.k2, subq2.k1, subq2.value from
 (
 SELECT subq1.key2 as k1, subq1.key  as k2, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1
 )subq2;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n3 tablesample (bucket 2 out of 2) s where ds = '1';
 
 CREATE TABLE test_table4 (key INT, key2 INT, value STRING) PARTITIONED BY (ds 
STRING)
 CLUSTERED BY (key, key2) SORTED BY (key DESC, key2 DESC) INTO 2 BUCKETS;
@@ -154,7 +154,7 @@ SELECT subq2.k2, subq2.k1, subq2.value from
 SELECT subq1.key2 as k1, subq1.key  as k2, subq1.value from
 (
 SELECT a.key, a.key2, concat(a.value, b.value) as value
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n3 a JOIN test_table2_n3 b 
 ON a.key = b.key and a.key2 = b.key2 WHERE a.ds = '1' and b.ds = '1'
 )subq1
 )subq2;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_7.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_7.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_7.q
index 1b344da..bef48b2 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_7.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_7.q
@@ -17,77 +17,77 @@ set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 set hive.auto.convert.join.noconditionaltask.size=10;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table1_n20 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table2_n19 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table3 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table3_n11 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT * where key < 
10;
+INSERT OVERWRITE TABLE test_table1_n20 PARTITION (ds = '1') SELECT * where key 
< 10;
 
 FROM src
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1') SELECT * where key < 
100;
+INSERT OVERWRITE TABLE test_table2_n19 PARTITION (ds = '1') SELECT * where key 
< 100;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n11 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n20 a JOIN test_table2_n19 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1'
 and (a.key = 0 or a.key = 5);
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n11 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n20 a JOIN test_table2_n19 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1'
 and (a.key = 0 or a.key = 5);
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n11 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n11 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- This should be a map-only job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n11 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1' and (key = 0 or key = 5)) a 
+(select key, value from test_table1_n20 where ds = '1' and (key = 0 or key = 
5)) a 
 JOIN 
-(select key, value from test_table2 where ds = '1' and (key = 0 or key = 5)) b 
+(select key, value from test_table2_n19 where ds = '1' and (key = 0 or key = 
5)) b 
 ON a.key = b.key;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n11 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1' and (key = 0 or key = 5)) a 
+(select key, value from test_table1_n20 where ds = '1' and (key = 0 or key = 
5)) a 
 JOIN 
-(select key, value from test_table2 where ds = '1' and (key = 0 or key = 5)) b 
+(select key, value from test_table2_n19 where ds = '1' and (key = 0 or key = 
5)) b 
 ON a.key = b.key;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n11 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n11 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- This should be a map-only job
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n11 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1' and key < 8) a 
+(select key, value from test_table1_n20 where ds = '1' and key < 8) a 
 JOIN 
-(select key, value from test_table2 where ds = '1' and key < 8) b 
+(select key, value from test_table2_n19 where ds = '1' and key < 8) b 
 ON a.key = b.key
 WHERE a.key = 0 or a.key = 5;
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n11 PARTITION (ds = '1')
 SELECT a.key, concat(a.value, b.value) 
 FROM 
-(select key, value from test_table1 where ds = '1' and key < 8) a 
+(select key, value from test_table1_n20 where ds = '1' and key < 8) a 
 JOIN 
-(select key, value from test_table2 where ds = '1' and key < 8) b 
+(select key, value from test_table2_n19 where ds = '1' and key < 8) b 
 ON a.key = b.key
 WHERE a.key = 0 or a.key = 5;
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n11 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n11 tablesample (bucket 2 out of 2) s where ds = '1';

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_8.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_8.q 
b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_8.q
index b9492eb..1f66e20 100644
--- a/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_8.q
+++ b/ql/src/test/queries/clientpositive/bucketsortoptimize_insert_8.q
@@ -15,47 +15,47 @@ set 
hive.auto.convert.sortmerge.join.bigtable.selection.policy=org.apache.hadoop
 set hive.auto.convert.sortmerge.join.to.mapjoin=true;
 
 -- Create two bucketed and sorted tables
-CREATE TABLE test_table1 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table1_n2 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table2 (key INT, value STRING) PARTITIONED BY (ds STRING)
+CREATE TABLE test_table2_n2 (key INT, value STRING) PARTITIONED BY (ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
-CREATE TABLE test_table3 (key INT, key2 INT, value STRING) PARTITIONED BY (ds 
STRING)
+CREATE TABLE test_table3_n2 (key INT, key2 INT, value STRING) PARTITIONED BY 
(ds STRING)
 CLUSTERED BY (key) SORTED BY (key) INTO 2 BUCKETS;
 
 FROM src
-INSERT OVERWRITE TABLE test_table1 PARTITION (ds = '1') SELECT * where key < 
10;
+INSERT OVERWRITE TABLE test_table1_n2 PARTITION (ds = '1') SELECT * where key 
< 10;
 
 FROM src
-INSERT OVERWRITE TABLE test_table2 PARTITION (ds = '1') SELECT * where key < 
100;
+INSERT OVERWRITE TABLE test_table2_n2 PARTITION (ds = '1') SELECT * where key 
< 100;
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n2 PARTITION (ds = '1')
 SELECT a.key, b.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n2 a JOIN test_table2_n2 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n2 PARTITION (ds = '1')
 SELECT a.key, b.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n2 a JOIN test_table2_n2 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n2 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n2 tablesample (bucket 2 out of 2) s where ds = '1';
 
 -- Insert data into the bucketed table by selecting from another bucketed table
 -- This should be a map-only operation
 EXPLAIN
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n2 PARTITION (ds = '1')
 SELECT b.key, a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n2 a JOIN test_table2_n2 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-INSERT OVERWRITE TABLE test_table3 PARTITION (ds = '1')
+INSERT OVERWRITE TABLE test_table3_n2 PARTITION (ds = '1')
 SELECT b.key, a.key, concat(a.value, b.value) 
-FROM test_table1 a JOIN test_table2 b 
+FROM test_table1_n2 a JOIN test_table2_n2 b 
 ON a.key = b.key WHERE a.ds = '1' and b.ds = '1';
 
-select * from test_table3 tablesample (bucket 1 out of 2) s where ds = '1';
-select * from test_table3 tablesample (bucket 2 out of 2) s where ds = '1';
+select * from test_table3_n2 tablesample (bucket 1 out of 2) s where ds = '1';
+select * from test_table3_n2 tablesample (bucket 2 out of 2) s where ds = '1';

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/case_sensitivity.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/case_sensitivity.q 
b/ql/src/test/queries/clientpositive/case_sensitivity.q
index 1dab85e..3f9f9c9 100644
--- a/ql/src/test/queries/clientpositive/case_sensitivity.q
+++ b/ql/src/test/queries/clientpositive/case_sensitivity.q
@@ -1,11 +1,11 @@
 --! qt:dataset:src_thrift
-CREATE TABLE DEST1(Key INT, VALUE STRING) STORED AS TEXTFILE;
+CREATE TABLE DEST1_n129(Key INT, VALUE STRING) STORED AS TEXTFILE;
 
 EXPLAIN
 FROM SRC_THRIFT
-INSERT OVERWRITE TABLE dest1 SELECT src_Thrift.LINT[1], 
src_thrift.lintstring[0].MYSTRING where src_thrift.liNT[0] > 0;
+INSERT OVERWRITE TABLE dest1_n129 SELECT src_Thrift.LINT[1], 
src_thrift.lintstring[0].MYSTRING where src_thrift.liNT[0] > 0;
 
 FROM SRC_THRIFT
-INSERT OVERWRITE TABLE dest1 SELECT src_Thrift.LINT[1], 
src_thrift.lintstring[0].MYSTRING where src_thrift.liNT[0] > 0;
+INSERT OVERWRITE TABLE dest1_n129 SELECT src_Thrift.LINT[1], 
src_thrift.lintstring[0].MYSTRING where src_thrift.liNT[0] > 0;
 
-SELECT DEST1.* FROM Dest1;
+SELECT DEST1_n129.* FROM Dest1_n129;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/cast1.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cast1.q 
b/ql/src/test/queries/clientpositive/cast1.q
index 359b022..a3fd707 100644
--- a/ql/src/test/queries/clientpositive/cast1.q
+++ b/ql/src/test/queries/clientpositive/cast1.q
@@ -1,11 +1,11 @@
 --! qt:dataset:src
 set hive.mapred.mode=nonstrict;
-CREATE TABLE dest1(c1 INT, c2 DOUBLE, c3 DOUBLE, c4 DOUBLE, c5 INT, c6 STRING, 
c7 INT) STORED AS TEXTFILE;
+CREATE TABLE dest1_n151(c1 INT, c2 DOUBLE, c3 DOUBLE, c4 DOUBLE, c5 INT, c6 
STRING, c7 INT) STORED AS TEXTFILE;
 
 EXPLAIN
-FROM src INSERT OVERWRITE TABLE dest1 SELECT 3 + 2, 3.0 + 2, 3 + 2.0, 3.0 + 
2.0, 3 + CAST(2.0 AS INT) + CAST(CAST(0 AS SMALLINT) AS INT), CAST(1 AS 
BOOLEAN), CAST(TRUE AS INT) WHERE src.key = 86;
+FROM src INSERT OVERWRITE TABLE dest1_n151 SELECT 3 + 2, 3.0 + 2, 3 + 2.0, 3.0 
+ 2.0, 3 + CAST(2.0 AS INT) + CAST(CAST(0 AS SMALLINT) AS INT), CAST(1 AS 
BOOLEAN), CAST(TRUE AS INT) WHERE src.key = 86;
 
-FROM src INSERT OVERWRITE TABLE dest1 SELECT 3 + 2, 3.0 + 2, 3 + 2.0, 3.0 + 
2.0, 3 + CAST(2.0 AS INT) + CAST(CAST(0 AS SMALLINT) AS INT), CAST(1 AS 
BOOLEAN), CAST(TRUE AS INT) WHERE src.key = 86;
+FROM src INSERT OVERWRITE TABLE dest1_n151 SELECT 3 + 2, 3.0 + 2, 3 + 2.0, 3.0 
+ 2.0, 3 + CAST(2.0 AS INT) + CAST(CAST(0 AS SMALLINT) AS INT), CAST(1 AS 
BOOLEAN), CAST(TRUE AS INT) WHERE src.key = 86;
 
-select dest1.* FROM dest1;
+select dest1_n151.* FROM dest1_n151;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/cast_on_constant.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cast_on_constant.q 
b/ql/src/test/queries/clientpositive/cast_on_constant.q
index bd9d57a..780a6ef 100644
--- a/ql/src/test/queries/clientpositive/cast_on_constant.q
+++ b/ql/src/test/queries/clientpositive/cast_on_constant.q
@@ -1,8 +1,8 @@
-create table t1(ts_field timestamp, date_field date);
-explain select * from t1 where ts_field = "2016-01-23 00:00:00";
-explain select * from t1 where date_field = "2016-01-23";
-explain select * from t1 where ts_field = timestamp '2016-01-23 00:00:00';
-explain select * from t1 where date_field = date '2016-01-23';
-explain select * from t1 where date_field = ts_field;
+create table t1_n138(ts_field timestamp, date_field date);
+explain select * from t1_n138 where ts_field = "2016-01-23 00:00:00";
+explain select * from t1_n138 where date_field = "2016-01-23";
+explain select * from t1_n138 where ts_field = timestamp '2016-01-23 00:00:00';
+explain select * from t1_n138 where date_field = date '2016-01-23';
+explain select * from t1_n138 where date_field = ts_field;
 
-drop table t1;
+drop table t1_n138;

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/cast_tinyint_to_double.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cast_tinyint_to_double.q 
b/ql/src/test/queries/clientpositive/cast_tinyint_to_double.q
index 95cc518..eea85b9 100644
--- a/ql/src/test/queries/clientpositive/cast_tinyint_to_double.q
+++ b/ql/src/test/queries/clientpositive/cast_tinyint_to_double.q
@@ -1,8 +1,8 @@
 --! qt:dataset:src
-drop table t;
-CREATE TABLE t(c tinyint);
-insert overwrite table t select 10 from src limit 1;
+drop table t_n24;
+CREATE TABLE t_n24(c tinyint);
+insert overwrite table t_n24 select 10 from src limit 1;
 
-select * from t where c = 10.0;
+select * from t_n24 where c = 10.0;
 
-select * from t where c = -10.0;
\ No newline at end of file
+select * from t_n24 where c = -10.0;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/cbo_SortUnionTransposeRule.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cbo_SortUnionTransposeRule.q 
b/ql/src/test/queries/clientpositive/cbo_SortUnionTransposeRule.q
index 1b2925e..cfdcf3d 100644
--- a/ql/src/test/queries/clientpositive/cbo_SortUnionTransposeRule.q
+++ b/ql/src/test/queries/clientpositive/cbo_SortUnionTransposeRule.q
@@ -2,30 +2,30 @@
 --! qt:dataset:src
 set hive.mapred.mode=nonstrict;
 
-create table s as select * from src limit 10;
+create table s_n3 as select * from src limit 10;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 order by key;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 limit 0;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 limit 5;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 order by key
 limit 5;
 
@@ -46,27 +46,27 @@ limit 5;
 set hive.optimize.limittranspose=true;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 order by key;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 limit 0;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 limit 5;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 order by key
 limit 5;
 
@@ -87,16 +87,16 @@ limit 5;
 set hive.optimize.limittranspose.reductionpercentage=0.1f;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 limit 5;
 
 set hive.optimize.limittranspose.reductionpercentage=1f;
 set hive.optimize.limittranspose.reductiontuples=8;
 
 explain
-select key from s a
+select key from s_n3 a
 union all
-select key from s b
+select key from s_n3 b
 limit 5;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/38d3b8e1/ql/src/test/queries/clientpositive/cbo_const.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/cbo_const.q 
b/ql/src/test/queries/clientpositive/cbo_const.q
index de5d219..1cc7afa 100644
--- a/ql/src/test/queries/clientpositive/cbo_const.q
+++ b/ql/src/test/queries/clientpositive/cbo_const.q
@@ -14,7 +14,7 @@ from src limit 1;
 
 select count(*) from srcpart join (select ds as ds, ds as `date` from srcpart 
group by ds) s on (srcpart.ds = s.ds) where s.`date` = '2008-04-08';
 
-drop view t1;
+drop view t1_n107;
 
 create table t1_new (key string, value string) partitioned by (ds string);
 
@@ -24,7 +24,7 @@ select 'key1', 'value1' from src tablesample (1 rows);
 insert overwrite table t1_new partition (ds = '2011-10-16')
 select 'key2', 'value2' from src tablesample (1 rows);
 
-create view t1 partitioned on (ds) as
+create view t1_n107 partitioned on (ds) as
 select * from
 (
 select key, value, ds from t1_new
@@ -32,7 +32,7 @@ union all
 select key, value, ds from t1_new
 )subq;
 
-select * from t1 where ds = '2011-10-15';
+select * from t1_n107 where ds = '2011-10-15';
 
 
 explain select array(1,2,3) from src;

Reply via email to