drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [5/9] git commit: DRILL-755: Show files without FROM clause should display files in default workspace
Date Wed, 09 Jul 2014 22:00:48 GMT
DRILL-755: Show files without FROM clause should display files in default workspace


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/9921547d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/9921547d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/9921547d

Branch: refs/heads/master
Commit: 9921547d31c0c9cdb8f3916f1d2d8bf51ffce7bf
Parents: b81f500
Author: Mehant Baid <mehantr@gmail.com>
Authored: Mon Jul 7 20:14:38 2014 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Tue Jul 8 13:50:10 2014 -0700

----------------------------------------------------------------------
 .../src/main/codegen/includes/parserImpls.ftl   |  4 +++-
 .../planner/sql/handlers/ShowFileHandler.java   | 20 +++++++++++++-------
 2 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9921547d/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/includes/parserImpls.ftl b/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
index 5e53ea6..1605b06 100644
--- a/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
+++ b/exec/java-exec/src/main/codegen/includes/parserImpls.ftl
@@ -65,7 +65,9 @@ SqlNode SqlShowFiles() :
 {
     <SHOW> { pos = getPos(); }
     <FILES>
-    (<FROM> | <IN>) { db = CompoundIdentifier(); }
+    [
+        (<FROM> | <IN>) { db = CompoundIdentifier(); }
+    ]
     {
         return new SqlShowFiles(pos, db);
     }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/9921547d/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 2be4b43..17e80bd 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
@@ -63,13 +63,16 @@ public class ShowFileHandler extends DefaultSqlHandler {
       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));
+      // Show files can be used without from clause, in which case we display the files in
the default schema
+      if (from != null) {
+        // 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));
+        }
       }
 
       AbstractSchema tempSchema = getDrillSchema(drillSchema);
@@ -86,6 +89,9 @@ public class ShowFileHandler extends DefaultSqlHandler {
       // Get the default path
       defaultLocation = schema.getDefaultLocation();
     } catch (Exception e) {
+        if (from == null) {
+          return DirectPlan.createDirectPlan(context, false, "Show files without FROM / IN
clause can be used only after specifying a default file system schema");
+        }
         return DirectPlan.createDirectPlan(context, false, String.format("Current schema
'%s' is not a file system schema. " +
                                            "Can't execute show files on this schema.", from.toString()));
     }


Mime
View raw message