diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java index e01c6c4976..539a5a6c8a 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java @@ -1640,8 +1640,18 @@ public void testHdfsNameserviceLazyCopy() throws Throwable { List clause = getHdfsNameserviceClause(); clause.add("'" + HiveConf.ConfVars.REPL_DUMP_METADATA_ONLY_FOR_EXTERNAL_TABLE.varname + "'='true'"); primary.run("use " + primaryDbName) - .run("create table acid_table (key int, value int) partitioned by (load_date date) " + + .run("create table acid_table (key int, value int) partitioned by (load_time timestamp) " + "clustered by(key) into 2 buckets stored as orc tblproperties ('transactional'='true')") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.123') values(1,2)") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.124') values(1,3)") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.125') values(1,4)") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.126') values(1,5)") + .run("show partitions acid_table") + .verifyResults(new String[] { + "load_time=2012-02-21 07%3A08%3A09.123", + "load_time=2012-02-21 07%3A08%3A09.124", + "load_time=2012-02-21 07%3A08%3A09.125", + "load_time=2012-02-21 07%3A08%3A09.126"}) .run("create table table1 (i int)") .run("insert into table1 values (1)") .run("insert into table1 values (2)") @@ -1662,7 +1672,7 @@ public void testHdfsNameserviceLazyCopy() throws Throwable { public void testHdfsNameserviceLazyCopyIncr() throws Throwable { List clause = getHdfsNameserviceClause(); primary.run("use " + primaryDbName) - .run("create table acid_table (key int, value int) partitioned by (load_date date) " + + .run("create table acid_table (key int, value int) partitioned by (load_time timestamp) " + "clustered by(key) into 2 buckets stored as orc tblproperties ('transactional'='true')") .run("create table table1 (i String)") .run("insert into table1 values (1)") @@ -1678,6 +1688,16 @@ public void testHdfsNameserviceLazyCopyIncr() throws Throwable { primary.run("use " + primaryDbName) .run("insert into table1 values (3)") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.123') values(1,2)") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.124') values(1,3)") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.125') values(1,4)") + .run("insert into acid_table partition(load_time = '2012-02-21 07:08:09.126') values(1,5)") + .run("show partitions acid_table") + .verifyResults(new String[] { + "load_time=2012-02-21 07%3A08%3A09.123", + "load_time=2012-02-21 07%3A08%3A09.124", + "load_time=2012-02-21 07%3A08%3A09.125", + "load_time=2012-02-21 07%3A08%3A09.126"}) .dump(primaryDbName, clause); try{ replica.load(replicatedDbName, primaryDbName, clause); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java index 5805a9c9d0..71b6041a2d 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/Utils.java @@ -98,12 +98,12 @@ private static String replaceHost(String originalURIStr, String newHost) throws if (StringUtils.isEmpty(originalURIStr)) { return originalURIStr; } - URI origUri = URI.create(originalURIStr); try { - return new URI(origUri.getScheme(), + URI origUri = new Path(originalURIStr).toUri(); + return new Path(new URI(origUri.getScheme(), origUri.getUserInfo(), newHost, origUri.getPort(), origUri.getPath(), origUri.getQuery(), - origUri.getFragment()).toString(); + origUri.getFragment())).toString(); } catch (URISyntaxException ex) { throw new SemanticException(ex); }