diff --git build-common.xml build-common.xml
index 4f72cda..f17a59d 100644
--- build-common.xml
+++ build-common.xml
@@ -59,7 +59,7 @@
-
+
diff --git data/files/ext_test_space/folder with space/data.txt data/files/ext_test_space/folder with space/data.txt
new file mode 100644
index 0000000..6a39069
--- /dev/null
+++ data/files/ext_test_space/folder with space/data.txt
@@ -0,0 +1,3 @@
+12 jason
+13 steven
+15 joe
\ No newline at end of file
diff --git ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java
index 321759b..7da1daf 100644
--- ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java
+++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java
@@ -30,6 +30,8 @@
import java.util.Map;
import java.util.Properties;
+import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileStatus;
@@ -498,9 +500,13 @@ public String getBucketingDimensionId() {
return bcols.get(0);
}
- public void setDataLocation(URI uri) {
+ public void setDataLocation(URI uri) throws HiveException {
this.uri = uri;
- tTable.getSd().setLocation(uri.toString());
+ try {
+ tTable.getSd().setLocation(URIUtil.decode(uri.toString()));
+ } catch (URIException e) {
+ throw new HiveException("Invalid UIR for table location: " + uri.toString(), e);
+ }
}
public void unsetDataLocation() {
diff --git ql/src/test/queries/clientpositive/external_table_with_space_in_location_path.q ql/src/test/queries/clientpositive/external_table_with_space_in_location_path.q
new file mode 100644
index 0000000..dc870fd
--- /dev/null
+++ ql/src/test/queries/clientpositive/external_table_with_space_in_location_path.q
@@ -0,0 +1,9 @@
+dfs -mkdir hdfs:///tmp/test/;
+
+dfs -copyFromLocal ../data/files/ext_test_space hdfs:///tmp/test/ext_test_space;
+
+CREATE EXTERNAL TABLE spacetest (id int, message string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LOCATION 'hdfs:///tmp/test/ext_test_space/folder with space';
+
+SELECT * FROM spacetest;
+
+dfs -rmr hdfs:///tmp/test;
\ No newline at end of file
diff --git ql/src/test/results/clientpositive/external_table_with_space_in_location_path.q.out ql/src/test/results/clientpositive/external_table_with_space_in_location_path.q.out
new file mode 100644
index 0000000..fe26deb
--- /dev/null
+++ ql/src/test/results/clientpositive/external_table_with_space_in_location_path.q.out
@@ -0,0 +1,17 @@
+#### A masked pattern was here ####
+PREHOOK: type: CREATETABLE
+#### A masked pattern was here ####
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: default@spacetest
+PREHOOK: query: SELECT * FROM spacetest
+PREHOOK: type: QUERY
+PREHOOK: Input: default@spacetest
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT * FROM spacetest
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@spacetest
+#### A masked pattern was here ####
+12 jason
+13 steven
+15 joe
+#### A masked pattern was here ####
\ No newline at end of file