DRILL-1130: Leading / in a select query should be rooted from the workspace rather than from the file system
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/b6410ff8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/b6410ff8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/b6410ff8 Branch: refs/heads/master Commit: b6410ff846217ebffda23528bb46619248b1675a Parents: c331aed Author: Steven Phillips <[email protected]> Authored: Fri Jul 25 18:48:05 2014 -0700 Committer: Steven Phillips <[email protected]> Committed: Fri Jul 25 18:48:05 2014 -0700 ---------------------------------------------------------------------- .../org/apache/drill/exec/store/dfs/FileSelection.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b6410ff8/exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java ---------------------------------------------------------------------- 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 709fac9..4fbe87c 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; + } + } + }
