Separate out JDBC drivers between ref (RefDriver) and full exec so that they 
don't fight with each other in the same JVM.
Add ClassPathFileSystem to support reading from classpath
Update merge join to support left and right by flipping right.


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

Branch: refs/heads/master
Commit: 651b3e9fd7032310eede1550d315f8c450fe3d1a
Parents: 6f300a3
Author: Jacques Nadeau <[email protected]>
Authored: Sun Sep 1 14:13:30 2013 -0700
Committer: Jacques Nadeau <[email protected]>
Committed: Sun Sep 1 15:16:22 2013 -0700

----------------------------------------------------------------------
 .../drill/common/expression/PathSegment.java    |   4 +-
 .../apache/drill/common/logical/data/Join.java  |   2 +-
 .../common/logical/data/JoinCondition.java      |   4 +
 .../exec/physical/config/MergeJoinPOP.java      |  15 +++
 .../physical/impl/join/MergeJoinCreator.java    |   9 +-
 .../drill/exec/store/ClassPathFileSystem.java   | 103 +++++++++++++++++++
 .../drill/exec/store/ResourceInputStream.java   |  89 ++++++++++++++++
 .../exec/store/json/JSONStorageEngine.java      |   2 +
 .../exec/store/json/JsonSchemaProvider.java     |   2 +
 .../store/parquet/ParquetSchemaProvider.java    |   2 +
 sandbox/prototype/pom.xml                       |  29 +++++-
 sandbox/prototype/sqlparser/pom.xml             |  20 +---
 .../org/apache/drill/jdbc/DrillHandler.java     |   7 +-
 .../main/java/org/apache/drill/jdbc/Driver.java |   2 +-
 .../java/org/apache/drill/jdbc/RefDriver.java   |  71 +++++++++++++
 .../org/apache/drill/optiq/DrillJoinRel.java    |   7 +-
 .../apache/drill/optiq/DrillPrepareImpl.java    |   2 +-
 .../src/main/resources/storage-engines.json     |  10 ++
 .../apache/drill/jdbc/test/FullEngineTest.java  |  32 ++----
 .../org/apache/drill/jdbc/test/JdbcAssert.java  |  10 +-
 .../org/apache/drill/jdbc/test/JdbcTest.java    |   2 +-
 21 files changed, 366 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/PathSegment.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/PathSegment.java
 
b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/PathSegment.java
index 28e820b..c6de1ab 100644
--- 
a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/PathSegment.java
+++ 
b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/PathSegment.java
@@ -76,11 +76,11 @@ public abstract class PathSegment{
   
   
   public static class NameSegment extends PathSegment{
-    private final CharSequence path;
+    private final String path;
     
     public NameSegment(CharSequence n, ValueExpressions.CollisionBehavior 
collision){
       super(collision);
-      this.path = n;
+      this.path = n.toString();
     }
     
     public CharSequence getPath(){

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
 
b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
index 865c78e..f97dab1 100644
--- 
a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
+++ 
b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
@@ -36,7 +36,7 @@ public class Join extends LogicalOperatorBase {
   private final JoinCondition[] conditions;
 
   public static enum JoinType{
-    LEFT, INNER, OUTER;
+    LEFT, INNER, OUTER, RIGHT;
     
     public static JoinType resolve(String val){
       for(JoinType jt : JoinType.values()){

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
 
b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
index 49646c1..01c332b 100644
--- 
a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
+++ 
b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
@@ -47,5 +47,9 @@ public class JoinCondition {
   public LogicalExpression getRight() {
     return right;
   }
+  
+  public JoinCondition flip(){
+    return new JoinCondition(relationship, right, left);
+  }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/MergeJoinPOP.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/MergeJoinPOP.java
 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/MergeJoinPOP.java
index 0ffd218..b234f15 100644
--- 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/MergeJoinPOP.java
+++ 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/MergeJoinPOP.java
@@ -4,6 +4,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.drill.common.logical.data.Join;
+import org.apache.drill.common.logical.data.Join.JoinType;
 import org.apache.drill.common.logical.data.JoinCondition;
 import org.apache.drill.exec.physical.OperatorCost;
 import org.apache.drill.exec.physical.base.AbstractBase;
@@ -11,6 +12,7 @@ import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.base.PhysicalVisitor;
 import org.apache.drill.exec.physical.base.Size;
 
+import com.beust.jcommander.internal.Lists;
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonTypeName;
@@ -81,4 +83,17 @@ public class MergeJoinPOP extends AbstractBase{
   public List<JoinCondition> getConditions() {
     return conditions;
   }
+  
+  public MergeJoinPOP flipIfRight(){
+    if(joinType == JoinType.RIGHT){
+      List<JoinCondition> flippedConditions = 
Lists.newArrayList(conditions.size());
+      for(JoinCondition c : conditions){
+        flippedConditions.add(c.flip());
+      }
+      return new MergeJoinPOP(right, left, flippedConditions, JoinType.LEFT);
+    }else{
+      return this;
+    }
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinCreator.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinCreator.java
 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinCreator.java
index 1b65227..9940219 100644
--- 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinCreator.java
+++ 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/MergeJoinCreator.java
@@ -19,7 +19,9 @@
 package org.apache.drill.exec.physical.impl.join;
 
 import com.google.common.base.Preconditions;
+
 import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.logical.data.Join.JoinType;
 import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.physical.config.MergeJoinPOP;
 import org.apache.drill.exec.physical.impl.BatchCreator;
@@ -33,6 +35,11 @@ public class MergeJoinCreator implements 
BatchCreator<MergeJoinPOP> {
   @Override
   public RecordBatch getBatch(FragmentContext context, MergeJoinPOP config, 
List<RecordBatch> children) throws ExecutionSetupException {
     Preconditions.checkArgument(children.size() == 2);
-    return new MergeJoinBatch(config, context, children.get(0), 
children.get(1));
+    if(config.getJoinType() == JoinType.RIGHT){
+      return new MergeJoinBatch(config.flipIfRight(), context, 
children.get(1), children.get(0));
+    }else{
+      return new MergeJoinBatch(config, context, children.get(0), 
children.get(1));  
+    }
+    
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ClassPathFileSystem.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ClassPathFileSystem.java
 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ClassPathFileSystem.java
new file mode 100644
index 0000000..85bf4f8
--- /dev/null
+++ 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ClassPathFileSystem.java
@@ -0,0 +1,103 @@
+package org.apache.drill.exec.store;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.util.Progressable;
+
+import com.google.common.io.Resources;
+
+
+public class ClassPathFileSystem extends FileSystem{
+  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(ClassPathFileSystem.class);
+
+  static final String ERROR_MSG = "ClassPathFileSystem is read only.";
+  
+  private Path working;
+  
+  @Override
+  public FSDataOutputStream append(Path arg0, int arg1, Progressable arg2) 
throws IOException {
+    throw new IOException(ERROR_MSG);
+  }
+
+  @Override
+  public FSDataOutputStream create(Path arg0, FsPermission arg1, boolean arg2, 
int arg3, short arg4, long arg5,
+      Progressable arg6) throws IOException {
+    throw new IOException(ERROR_MSG);
+  }
+
+  @Override
+  public boolean delete(Path arg0) throws IOException {
+    throw new IOException(ERROR_MSG);
+  }
+
+  @Override
+  public boolean delete(Path arg0, boolean arg1) throws IOException {
+    throw new IOException(ERROR_MSG);
+  }
+
+  @Override
+  public FileStatus getFileStatus(Path arg0) throws IOException {
+    URL url = Resources.getResource(arg0.toString());
+    if(url == null){
+      throw new IOException(String.format("Unable to find path %s.", 
arg0.toString()));
+    }
+    return new FileStatus(-1, false, 1, 8096, System.currentTimeMillis(), 
arg0);
+  }
+
+  @Override
+  public URI getUri() {
+    try {
+      return new URI("classpath:///");
+    } catch (URISyntaxException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  @Override
+  public Path getWorkingDirectory() {
+    return working;
+  }
+
+  @Override
+  public FileStatus[] listStatus(Path arg0) throws IOException {
+    throw new IOException("ClassPathFileSystem doesn't currently support 
listing files.");
+  }
+
+  @Override
+  public boolean mkdirs(Path arg0, FsPermission arg1) throws IOException {
+    throw new IOException(ERROR_MSG);
+  }
+
+  @Override
+  public FSDataInputStream open(Path arg0, int arg1) throws IOException {
+    URL url = Resources.getResource(arg0.toString());
+    if(url == null){
+      throw new IOException(String.format("Unable to find path %s.", 
arg0.getName()));
+    }
+    ResourceInputStream ris = new 
ResourceInputStream(Resources.toByteArray(url));
+    return new FSDataInputStream(ris);
+  }
+
+  @Override
+  public boolean rename(Path arg0, Path arg1) throws IOException {
+    throw new IOException(ERROR_MSG);
+  }
+
+  @Override
+  public void setWorkingDirectory(Path arg0) {
+    this.working = arg0;
+  }
+  
+  public static void main(String[] args) throws Exception{
+    URI uri = new URI("classpath:///");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ResourceInputStream.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ResourceInputStream.java
 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ResourceInputStream.java
new file mode 100644
index 0000000..6d83cf9
--- /dev/null
+++ 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/ResourceInputStream.java
@@ -0,0 +1,89 @@
+package org.apache.drill.exec.store;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+
+import org.apache.hadoop.fs.PositionedReadable;
+import org.apache.hadoop.fs.Seekable;
+
+public class ResourceInputStream extends ByteArrayInputStream implements 
Seekable, PositionedReadable {
+  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(ResourceInputStream.class);
+
+
+  public ResourceInputStream(byte[] bytes) {
+    super(bytes);
+  }
+
+  
+  
+
+  @Override
+  public void readFully(long position, byte[] buffer) throws IOException {
+    int l = read(position, buffer, 0, buffer.length);
+    if (l < buffer.length) {
+      throw new EOFException();
+    }
+  }
+
+  public int read(long position, byte b[], int off, int len) {
+    int start = (int) position;
+    if (b == null) {
+        throw new NullPointerException();
+    } else if (off < 0 || len < 0 || len > b.length - off) {
+        throw new IndexOutOfBoundsException();
+    }
+
+    if (start >= count) {
+        return -1;
+    }
+
+    int avail = count - start;
+    if (len > avail) {
+        len = avail;
+    }
+    if (len <= 0) {
+        return 0;
+    }
+    System.arraycopy(buf, start, b, off, len);
+    return len;
+}
+  
+  @Override
+  public void readFully(long position, byte[] buffer, int offset, int length) 
throws IOException {
+    int l = read(position, buffer, offset, length);
+    if (l < length) throw new EOFException();
+  }
+
+  @Override
+  public long getPos() throws IOException {
+    return pos;
+  }
+
+  
+  @Override
+  public int read(byte[] b) throws IOException {
+    int l = read(pos, b, 0, b.length);
+    pos += l;
+    return l;
+  }
+
+  @Override
+  public boolean seekToNewSource(long arg0) throws IOException {
+    seek(arg0);
+    return true;
+  }
+
+
+
+
+  @Override
+  public void seek(long arg0) throws IOException {
+    if(buf.length > arg0){
+      pos = (int) arg0;
+    }else{
+      throw new EOFException();
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JSONStorageEngine.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JSONStorageEngine.java
 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JSONStorageEngine.java
index b0a2e3b..f5370ca 100644
--- 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JSONStorageEngine.java
+++ 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JSONStorageEngine.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import org.apache.drill.common.logical.data.Scan;
 import org.apache.drill.exec.server.DrillbitContext;
 import org.apache.drill.exec.store.AbstractStorageEngine;
+import org.apache.drill.exec.store.ClassPathFileSystem;
 import org.apache.drill.exec.store.SchemaProvider;
 import org.apache.drill.exec.store.json.JSONGroupScan.ScanEntry;
 import org.apache.hadoop.conf.Configuration;
@@ -44,6 +45,7 @@ public class JSONStorageEngine extends AbstractStorageEngine {
     
     try {
       this.conf = new Configuration();
+      this.conf.set("fs.classpath.impl", ClassPathFileSystem.class.getName());
       this.conf.set(HADOOP_DEFAULT_NAME, config.getDfsName());
       this.fileSystem = FileSystem.get(conf);
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JsonSchemaProvider.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JsonSchemaProvider.java
 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JsonSchemaProvider.java
index 065652a..e7f027e 100644
--- 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JsonSchemaProvider.java
+++ 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/json/JsonSchemaProvider.java
@@ -4,6 +4,7 @@ import java.io.IOException;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.exec.physical.ReadEntryWithPath;
+import org.apache.drill.exec.store.ClassPathFileSystem;
 import org.apache.drill.exec.store.SchemaProvider;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
@@ -23,6 +24,7 @@ public class JsonSchemaProvider implements SchemaProvider{
     try {
       this.conf = new Configuration();
       this.conf.set(HADOOP_DEFAULT_NAME, "file:///");
+      this.conf.set("fs.classpath.impl", ClassPathFileSystem.class.getName());
       this.fs = FileSystem.get(conf);
     } catch (IOException ie) {
       throw new RuntimeException("Error setting up filesystem");

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetSchemaProvider.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetSchemaProvider.java
 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetSchemaProvider.java
index 3e4b02a..9442841 100644
--- 
a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetSchemaProvider.java
+++ 
b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetSchemaProvider.java
@@ -4,6 +4,7 @@ import java.io.IOException;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.exec.physical.ReadEntryWithPath;
+import org.apache.drill.exec.store.ClassPathFileSystem;
 import org.apache.drill.exec.store.SchemaProvider;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
@@ -23,6 +24,7 @@ public class ParquetSchemaProvider implements SchemaProvider{
     this.configuration = configuration;
     try {
       this.conf = new Configuration();
+      this.conf.set("fs.classpath.impl", ClassPathFileSystem.class.getName());
       this.conf.set(HADOOP_DEFAULT_NAME, "file:///");
       this.fs = FileSystem.get(conf);
     } catch (IOException ie) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/prototype/pom.xml b/sandbox/prototype/pom.xml
index 2f2eae2..ccb8d76 100644
--- a/sandbox/prototype/pom.xml
+++ b/sandbox/prototype/pom.xml
@@ -26,16 +26,35 @@
 
   <repositories>
     <repository>
+      <id>conjars</id>
+      <name>Conjars</name>
+      <url>http://conjars.org/repo</url>
+      <layout>default</layout>
       <releases>
         <enabled>true</enabled>
-        <updatePolicy>always</updatePolicy>
+        <updatePolicy>never</updatePolicy>
         <checksumPolicy>warn</checksumPolicy>
       </releases>
-      <id>conjars</id>
-      <name>Conjars</name>
-      <url>http://conjars.org/repo</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>      
+    </repository>
+    
+    <repository>
+      <id>pentaho</id>
+      <name>Pentaho</name>
+      <url>http://repo.pentaho.org/artifactory/repo</url>
       <layout>default</layout>
+      <releases>
+        <enabled>true</enabled>
+        <updatePolicy>never</updatePolicy>
+        <checksumPolicy>warn</checksumPolicy>
+      </releases>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
     </repository>
+    
     <repository>
       <id>sonatype-nexus-snapshots</id>
       <url>https://oss.sonatype.org/content/repositories/snapshots</url>
@@ -234,7 +253,7 @@
       <artifactId>guava</artifactId>
       <version>14.0.1</version>
     </dependency>
-
+    
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/prototype/sqlparser/pom.xml 
b/sandbox/prototype/sqlparser/pom.xml
index 212362c..a9d6cfb 100644
--- a/sandbox/prototype/sqlparser/pom.xml
+++ b/sandbox/prototype/sqlparser/pom.xml
@@ -11,20 +11,6 @@
   <artifactId>sqlparser</artifactId>
   <name>sqlparser</name>
 
-  <repositories>
-    <repository>
-      <releases>
-        <enabled>true</enabled>
-        <updatePolicy>always</updatePolicy>
-        <checksumPolicy>warn</checksumPolicy>
-      </releases>
-      <id>conjars</id>
-      <name>Conjars</name>
-      <url>http://conjars.org/repo</url>
-      <layout>default</layout>
-    </repository>
-  </repositories>
-
   <dependencies>
     <dependency>
       <groupId>net.hydromatic</groupId>
@@ -59,7 +45,11 @@
       <version>0.3</version>
       <scope>test</scope>
     </dependency>
-
+    <dependency>
+      <groupId>pentaho</groupId>
+      <artifactId>mondrian-data-foodmart-json</artifactId>
+      <version>0.2</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.drill.exec</groupId>
       <artifactId>ref</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
index 380993b..6b45843 100644
--- 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/DrillHandler.java
@@ -37,13 +37,18 @@ public class DrillHandler extends HandlerImpl {
   private Drillbit bit;
   private DrillConfig config = DrillConfig.create();
   private SchemaProviderRegistry registry;
+  private final boolean ref;
+  
+  public DrillHandler(boolean ref){
+    this.ref = ref;
+  }
 
   public void onConnectionInit(OptiqConnection connection) throws SQLException 
{
     super.onConnectionInit(connection);
 
     final Properties p = connection.getProperties();
     
-    if (p.getProperty("ref") != null) {
+    if (ref) {
       final String model = p.getProperty("model");
       if (model != null) {
         if (model != null) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/Driver.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/Driver.java 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/Driver.java
index 7812c2c..425bcae 100644
--- 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/Driver.java
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/Driver.java
@@ -62,7 +62,7 @@ public class Driver extends UnregisteredDriver {
   
   @Override
   protected Handler createHandler() {
-    this.handler = new DrillHandler();
+    this.handler = new DrillHandler(false);
     return handler;
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/RefDriver.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/RefDriver.java
 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/RefDriver.java
new file mode 100644
index 0000000..e2e0f79
--- /dev/null
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/jdbc/RefDriver.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.jdbc;
+
+import net.hydromatic.linq4j.function.Function0;
+import net.hydromatic.optiq.jdbc.DriverVersion;
+import net.hydromatic.optiq.jdbc.Handler;
+import net.hydromatic.optiq.jdbc.OptiqPrepare;
+import net.hydromatic.optiq.jdbc.UnregisteredDriver;
+
+import org.apache.drill.exec.client.DrillClient;
+import org.apache.drill.optiq.DrillPrepareImpl;
+
+/**
+ * JDBC driver for Apache Drill.
+ */
+public class RefDriver extends UnregisteredDriver {
+  public static final String CONNECT_STRING_PREFIX = "jdbc:drillref:";
+
+  private volatile DrillHandler handler;
+  
+  static {
+    new RefDriver().register();
+  }
+
+  protected String getConnectStringPrefix() {
+    return CONNECT_STRING_PREFIX;
+  }
+
+  protected DriverVersion createDriverVersion() {
+    return new DrillDriverVersion();
+  }
+
+  @Override
+  protected Function0<OptiqPrepare> createPrepareFactory() {
+    return new Function0<OptiqPrepare>() {
+      @Override
+      public OptiqPrepare apply() {
+        return new DrillPrepareImpl(null);
+      }
+    };
+  }
+
+  public DrillClient getClient(){
+    return handler.getClient();
+  }
+  
+  @Override
+  protected Handler createHandler() {
+    this.handler = new DrillHandler(true);
+    return handler;
+  }
+  
+}
+
+// End Driver.java

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillJoinRel.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillJoinRel.java
 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillJoinRel.java
index f367e6d..2659063 100644
--- 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillJoinRel.java
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillJoinRel.java
@@ -47,10 +47,7 @@ public class DrillJoinRel extends JoinRelBase implements 
DrillRel {
   public DrillJoinRel(RelOptCluster cluster, RelTraitSet traits, RelNode left, 
RelNode right, RexNode condition,
       JoinRelType joinType) throws InvalidRelException {
     super(cluster, traits, left, right, condition, joinType, 
Collections.<String> emptySet());
-    switch (joinType) {
-    case RIGHT:
-      throw new InvalidRelException("DrillJoinRel does not support RIGHT 
join");
-    }
+
     RexNode remaining = RelOptUtil.splitJoinCondition(left, right, condition, 
leftKeys, rightKeys);
     if (!remaining.isAlwaysTrue()) {
       throw new InvalidRelException("DrillJoinRel only supports equi-join");
@@ -148,6 +145,8 @@ public class DrillJoinRel extends JoinRelBase implements 
DrillRel {
     switch (joinType) {
     case LEFT:
       return "left";
+    case RIGHT:
+      return "right";
     case INNER:
       return "inner";
     case FULL:

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillPrepareImpl.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillPrepareImpl.java
 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillPrepareImpl.java
index b80bc8c..f4c508f 100644
--- 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillPrepareImpl.java
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillPrepareImpl.java
@@ -37,7 +37,7 @@ public class DrillPrepareImpl extends OptiqPrepareImpl {
   @Override
   protected RelOptPlanner createPlanner() {
     final RelOptPlanner planner = super.createPlanner();
-    planner.addRule(EnumerableDrillRule.getInstance(driver.getClient()));
+    planner.addRule(EnumerableDrillRule.getInstance(driver == null ? null : 
driver.getClient()));
 
     // Enable when https://issues.apache.org/jira/browse/DRILL-57 fixed
     if (false) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/main/resources/storage-engines.json
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/main/resources/storage-engines.json 
b/sandbox/prototype/sqlparser/src/main/resources/storage-engines.json
index 1eead25..0dff70c 100644
--- a/sandbox/prototype/sqlparser/src/main/resources/storage-engines.json
+++ b/sandbox/prototype/sqlparser/src/main/resources/storage-engines.json
@@ -5,11 +5,21 @@
         "type":"parquet",
         "dfsName" : "file:///"
       },
+    "parquet-cp" :
+      {
+        "type":"parquet",
+        "dfsName" : "classpath:///"
+      },
     "jsonl" :
       {
         "type":"json",
         "dfsName" : "file:///"
       },
+    "json-cp" :
+      {
+        "type":"json",
+        "dfsName" : "classpath:///"
+      },
     "parquet" :
       {
         "type":"parquet",

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
 
b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
index e88dc0d..a1a6cf2 100644
--- 
a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
+++ 
b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java
@@ -1,8 +1,5 @@
 package org.apache.drill.jdbc.test;
 
-import java.io.IOException;
-
-import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
@@ -10,42 +7,29 @@ import org.junit.rules.TestName;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 
-import com.google.common.base.Charsets;
-import com.google.common.io.Resources;
-
 
 public class FullEngineTest {
   static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(FullEngineTest.class);
 
-  private static String MODEL_FULL_ENGINE;
-
   // Determine if we are in Eclipse Debug mode.
   static final boolean IS_DEBUG = 
java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp")
 > 0;
 
   // Set a timeout unless we're debugging.
   @Rule public TestRule globalTimeout = IS_DEBUG ? new TestName() : new 
Timeout(10000);
   
-//  @BeforeClass
-//  public static void setupFixtures() throws IOException {
-//    MODEL_FULL_ENGINE = 
Resources.toString(Resources.getResource("full-model.json"), Charsets.UTF_8);
-//  }
-  
-  
-  
   @Test
+  @Ignore // since this is a specifically located file.
   public void fullSelectStarEngine() throws Exception {
     JdbcAssert.withFull("parquet-local")
     // .sql("select cast(_MAP['red'] as bigint) + 1 as red_inc from donuts ")
         .sql("select _MAP['d'] as d, _MAP['b'] as b from 
\"/tmp/parquet_test_file_many_types\" ").displayResults(50);
   }
 
-//  @Test
-//  public void fullEngine() throws Exception {
-//    JdbcAssert
-//        .withModel(MODEL_FULL_ENGINE, "DONUTS")
-//        // .sql("select cast(_MAP['red'] as bigint) + 1 as red_inc from 
donuts ")
-//        .sql(
-//            "select cast(_MAP['RED'] as bigint)  as RED, cast(_MAP['GREEN'] 
as bigint)  as GREEN from 'monkeys' where cast(_MAP['red'] as BIGINT) > 1 ")
-//        .displayResults(50);
-//  }
+  @Test
+  public void setCPRead() throws Exception {
+    JdbcAssert.withFull("json-cp")
+    // .sql("select cast(_MAP['red'] as bigint) + 1 as red_inc from donuts ")
+        .sql("select * from \"department.json\" ").displayResults(50);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
 
b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
index 54af383..17b267e 100644
--- 
a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
+++ 
b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
@@ -122,8 +122,14 @@ public class JdbcAssert {
       this.info = info;
       this.connectionFactory = new ConnectionFactory() {
         public Connection createConnection() throws Exception {
-          Class.forName("org.apache.drill.jdbc.Driver");
-          String connect = ref ? "jdbc:drill:ref=true" : "jdbc:drill:";
+          String connect = ref ? "jdbc:drillref:" : "jdbc:drill:";
+          if(ref){
+            Class.forName("org.apache.drill.jdbc.RefDriver");
+          }else{
+            Class.forName("org.apache.drill.jdbc.Driver");  
+          }
+          
+          
           return DriverManager.getConnection(connect, 
ModelAndSchema.this.info);  
         }
       };

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/651b3e9f/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
----------------------------------------------------------------------
diff --git 
a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
 
b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
index d9dd11a..37e81b7 100644
--- 
a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
+++ 
b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
@@ -65,7 +65,7 @@ public class JdbcTest {
   @Test
   public void testConnect() throws Exception {
     Class.forName("org.apache.drill.jdbc.Driver");
-    final Connection connection = 
DriverManager.getConnection("jdbc:drill:ref=true&schema=DONUTS");
+    final Connection connection = 
DriverManager.getConnection("jdbc:drillref:schema=DONUTS");
     connection.close();
   }
 

Reply via email to