You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ja...@apache.org on 2014/07/10 00:00:47 UTC
[4/9] git commit: DRILL-879: Fix show files to treat '/' as a root of
workspace instead of FS
DRILL-879: Fix show files to treat '/' as a root of workspace instead of FS
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/b81f5000
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/b81f5000
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/b81f5000
Branch: refs/heads/master
Commit: b81f50008982fc8bb355b3fbaa91c7b4dcfada1c
Parents: e29d2fc
Author: Mehant Baid <me...@gmail.com>
Authored: Mon Jul 7 19:25:29 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Tue Jul 8 13:50:04 2014 -0700
----------------------------------------------------------------------
.../exec/planner/sql/handlers/ShowFileHandler.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b81f5000/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowFileHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowFileHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowFileHandler.java
index 8ce0463..2be4b43 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowFileHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowFileHandler.java
@@ -57,11 +57,21 @@ public class ShowFileHandler extends DefaultSqlHandler {
DrillFileSystem fs = null;
String defaultLocation = null;
+ String fromDir = "./";
try {
+ SchemaPlus defaultSchema = context.getNewDefaultSchema();
+ SchemaPlus drillSchema = defaultSchema;
+
+ // We are not sure if the full from clause is just the schema or includes table name, first try to see if the full path specified is a schema
+ try {
+ drillSchema = findSchema(context.getRootSchema(), defaultSchema, from.names);
+ } catch (Exception e) {
+ // Entire from clause is not a schema, try to obtain the schema without the last part of the specified clause.
+ drillSchema = findSchema(context.getRootSchema(), defaultSchema, from.names.subList(0, from.names.size() - 1));
+ fromDir = fromDir + from.names.get((from.names.size() - 1));
+ }
- // Traverse and find the schema
- SchemaPlus drillSchema = findSchema(context.getRootSchema(), context.getNewDefaultSchema(), from.names.subList(0, from.names.size() - 1));
AbstractSchema tempSchema = getDrillSchema(drillSchema);
WorkspaceSchema schema = null;
if (tempSchema instanceof WorkspaceSchema) {
@@ -81,7 +91,6 @@ public class ShowFileHandler extends DefaultSqlHandler {
}
List<ShowFilesCommandResult> rows = new ArrayList<>();
- String fromDir = from.names.get((from.names.size() - 1));
for (FileStatus fileStatus : fs.list(false, new Path(defaultLocation, fromDir))) {
ShowFilesCommandResult result = new ShowFilesCommandResult(fileStatus.getPath().getName(), fileStatus.isDir(),