aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/main
diff options
context:
space:
mode:
authorSteven Phillips <sphillips@maprtech.com>2014-07-25 18:48:05 -0700
committerSteven Phillips <sphillips@maprtech.com>2014-07-25 18:48:05 -0700
commitb6410ff846217ebffda23528bb46619248b1675a (patch)
treedd42da56e82cb20d73ce437fd27c80649c816f12 /exec/java-exec/src/main
parentc331aed81e73d16ea29bf8c94863591b212aa644 (diff)
DRILL-1130: Leading / in a select query should be rooted from the workspace rather than from the file system
Diffstat (limited to 'exec/java-exec/src/main')
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
index 709fac9ba..4fbe87cd6 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
@@ -125,11 +125,11 @@ public class FileSelection {
public static FileSelection create(DrillFileSystem fs, String parent, String path) throws IOException {
if ( !(path.contains("*") || path.contains("?")) ) {
- Path p = new Path(parent, path);
+ Path p = new Path(parent, removeLeadingSlash(path));
FileStatus status = fs.getFileStatus(p);
return new FileSelection(Collections.singletonList(status), p.toUri().getPath());
} else {
- Path p = new Path(parent, path);
+ Path p = new Path(parent,removeLeadingSlash(path));
FileStatus[] status = fs.getUnderlying().globStatus(p);
if(status == null || status.length == 0) return null;
String[] s = p.toUri().getPath().split("/");
@@ -139,4 +139,13 @@ public class FileSelection {
}
}
+ private static String removeLeadingSlash(String path) {
+ if (path.charAt(0) == '/') {
+ String newPath = path.substring(1);
+ return removeLeadingSlash(newPath);
+ } else {
+ return path;
+ }
+ }
+
}