drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdunn...@apache.org
Subject [2/4] git commit: DRILL-5 - Sample data for test of the physical plan interpreter. Also, allow scan-json to read from resources for testing.
Date Thu, 18 Oct 2012 21:04:24 GMT
DRILL-5 - Sample data for test of the physical plan interpreter.  Also, allow scan-json to
read from resources for testing.


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

Branch: refs/heads/master
Commit: 2917c7b6ed33fd5ae1efa7bf61fe5d5ca008f993
Parents: efeec4d
Author: tdunning <tdunning@apache.org>
Authored: Wed Oct 17 18:35:02 2012 -0700
Committer: tdunning <tdunning@apache.org>
Committed: Wed Oct 17 18:35:02 2012 -0700

----------------------------------------------------------------------
 .../drill/plan/physical/operators/ScanJson.java    |    8 +++-
 .../apache/drill/plan/PhysicalInterpreterTest.java |   35 +++++++++++++++
 .../src/test/resources/physical-1.drillx           |    4 ++
 3 files changed, 46 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2917c7b6/sandbox/plan-parser/src/main/java/org/apache/drill/plan/physical/operators/ScanJson.java
----------------------------------------------------------------------
diff --git a/sandbox/plan-parser/src/main/java/org/apache/drill/plan/physical/operators/ScanJson.java
b/sandbox/plan-parser/src/main/java/org/apache/drill/plan/physical/operators/ScanJson.java
index 55e4ea0..2e7155d 100644
--- a/sandbox/plan-parser/src/main/java/org/apache/drill/plan/physical/operators/ScanJson.java
+++ b/sandbox/plan-parser/src/main/java/org/apache/drill/plan/physical/operators/ScanJson.java
@@ -21,6 +21,7 @@ import com.google.common.base.Charsets;
 import com.google.common.base.Splitter;
 import com.google.common.io.Files;
 import com.google.common.io.InputSupplier;
+import com.google.common.io.Resources;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonPrimitive;
@@ -51,7 +52,12 @@ public class ScanJson extends Operator {
         if (in.size() != 1) {
             throw new IllegalArgumentException("scan-json should have exactly one argument
(a file name)");
         }
-        input = Files.newReaderSupplier(new File(in.get(0).asString()), Charsets.UTF_8);
+        String inputName = in.get(0).asString();
+        if (inputName.startsWith("resource:")) {
+            input = Resources.newReaderSupplier(Resources.getResource(inputName.substring(inputName.indexOf(':')
+ 1)), Charsets.UTF_8);
+        } else {
+            input = Files.newReaderSupplier(new File(inputName), Charsets.UTF_8);
+        }
 
         List<Arg> out = op.getOutputs();
         if (out.size() != 1) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2917c7b6/sandbox/plan-parser/src/test/java/org/apache/drill/plan/PhysicalInterpreterTest.java
----------------------------------------------------------------------
diff --git a/sandbox/plan-parser/src/test/java/org/apache/drill/plan/PhysicalInterpreterTest.java
b/sandbox/plan-parser/src/test/java/org/apache/drill/plan/PhysicalInterpreterTest.java
new file mode 100644
index 0000000..6d401c1
--- /dev/null
+++ b/sandbox/plan-parser/src/test/java/org/apache/drill/plan/PhysicalInterpreterTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.drill.plan;
+
+import org.antlr.runtime.RecognitionException;
+import org.apache.drill.plan.ast.Plan;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.concurrent.ExecutionException;
+
+public class PhysicalInterpreterTest {
+    @Test
+    public void testTrivialPlan() throws ParsePlan.ValidationException, RecognitionException,
IOException, InvocationTargetException, NoSuchMethodException, IllegalAccessException, InstantiationException,
InterruptedException, ExecutionException {
+        Plan p = ParsePlan.parseResource("physical-1.drillx");
+        PhysicalInterpreter pi = new PhysicalInterpreter(p);
+        pi.run();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2917c7b6/sandbox/plan-parser/src/test/resources/physical-1.drillx
----------------------------------------------------------------------
diff --git a/sandbox/plan-parser/src/test/resources/physical-1.drillx b/sandbox/plan-parser/src/test/resources/physical-1.drillx
new file mode 100644
index 0000000..0d1707e
--- /dev/null
+++ b/sandbox/plan-parser/src/test/resources/physical-1.drillx
@@ -0,0 +1,4 @@
+%1 := scan-json "resource:data1.json"
+%2 := bind "a", %1
+%3 := < %2, 3
+%4 := filter %3, %1


Mime
View raw message