You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2014/04/24 09:08:21 UTC

[03/10] Make tests extend shared base class. Add additional tracking in base class around memory usage per test.

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java
index c508b21..b7f002e 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java
@@ -25,6 +25,7 @@ import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.expression.ExpressionPosition;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.memory.TopLevelAllocator;
@@ -49,11 +50,11 @@ import com.google.common.base.Charsets;
 import com.google.common.io.Files;
 import com.codahale.metrics.MetricRegistry;
 
-public class TestSimpleSort {
+public class TestSimpleSort extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSimpleSort.class);
   DrillConfig c = DrillConfig.create();
-  
-  
+
+
   @Test
   public void sortOneKeyAscending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{
 
@@ -63,14 +64,14 @@ public class TestSimpleSort {
       bitContext.getAllocator(); result = new TopLevelAllocator();
       bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
     }};
-    
-    
+
+
     PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
     PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/sort/one_key_sort.json"), Charsets.UTF_8));
     FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
     FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
     SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
-    
+
     int previousInt = Integer.MIN_VALUE;
 
     int recordCount = 0;
@@ -80,20 +81,20 @@ public class TestSimpleSort {
       batchCount++;
       IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
       IntVector c2 = exec.getValueVectorById(new SchemaPath("green", ExpressionPosition.UNKNOWN), IntVector.class);
-      
+
       IntVector.Accessor a1 = c1.getAccessor();
       IntVector.Accessor a2 = c2.getAccessor();
-      
+
       for(int i =0; i < c1.getAccessor().getValueCount(); i++){
         recordCount++;
         assert previousInt <= a1.get(i);
         previousInt = a1.get(i);
         assert previousInt == a2.get(i);
       }
-     
-      
+
+
     }
-    
+
     System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
 
     if(context.getFailureCause() != null){
@@ -101,7 +102,7 @@ public class TestSimpleSort {
     }
     assertTrue(!context.isFailed());
   }
-  
+
   @Test
   public void sortTwoKeysOneAscendingOneDescending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{
 
@@ -111,17 +112,17 @@ public class TestSimpleSort {
       bitContext.getAllocator(); result = new TopLevelAllocator();
       bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
     }};
-    
-    
+
+
     PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
     PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/sort/two_key_sort.json"), Charsets.UTF_8));
     FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
     FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
     SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
-    
+
     int previousInt = Integer.MIN_VALUE;
     long previousLong = Long.MAX_VALUE;
-    
+
     int recordCount = 0;
     int batchCount = 0;
 
@@ -129,28 +130,28 @@ public class TestSimpleSort {
       batchCount++;
       IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class);
       BigIntVector c2 = exec.getValueVectorById(new SchemaPath("alt", ExpressionPosition.UNKNOWN), BigIntVector.class);
-      
+
       IntVector.Accessor a1 = c1.getAccessor();
       BigIntVector.Accessor a2 = c2.getAccessor();
-      
+
       for(int i =0; i < c1.getAccessor().getValueCount(); i++){
         recordCount++;
         assert previousInt <= a1.get(i);
-        
+
         if(previousInt != a1.get(i)){
           previousLong = Long.MAX_VALUE;
           previousInt = a1.get(i);
         }
-        
+
         assert previousLong >= a2.get(i);
-        
+
         //System.out.println(previousInt + "\t" + a2.get(i));
-        
+
       }
-     
-      
+
+
     }
-    
+
     System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
 
     if(context.getFailureCause() != null){
@@ -158,7 +159,7 @@ public class TestSimpleSort {
     }
     assertTrue(!context.isFailed());
   }
-  
+
   @AfterClass
   public static void tearDown() throws Exception{
     // pause to get logger to catch up.

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/svremover/TestSVRemover.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/svremover/TestSVRemover.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/svremover/TestSVRemover.java
index fa04654..e45c938 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/svremover/TestSVRemover.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/svremover/TestSVRemover.java
@@ -24,6 +24,7 @@ import mockit.NonStrictExpectations;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.memory.TopLevelAllocator;
@@ -48,11 +49,11 @@ import com.google.common.base.Charsets;
 import com.google.common.io.Files;
 import com.codahale.metrics.MetricRegistry;
 
-public class TestSVRemover {
+public class TestSVRemover extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSVRemover.class);
   DrillConfig c = DrillConfig.create();
-  
-  
+
+
   @Test
   public void testSelectionVectorRemoval(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{
 //    System.out.println(System.getProperty("java.class.path"));
@@ -63,8 +64,8 @@ public class TestSVRemover {
       bitContext.getAllocator(); result = new TopLevelAllocator();
       bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
     }};
-    
-    
+
+
     PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
     PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/remover/test1.json"), Charsets.UTF_8));
     FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
@@ -77,14 +78,14 @@ public class TestSVRemover {
         assertEquals(count, a.getValueCount());
       }
     }
-    
+
     if(context.getFailureCause() != null){
       throw context.getFailureCause();
     }
     assertTrue(!context.isFailed());
 
   }
-  
+
   @AfterClass
   public static void tearDown() throws Exception{
     // pause to get logger to catch up.

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceMultiRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceMultiRecordBatch.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceMultiRecordBatch.java
index b7b148c..f115c44 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceMultiRecordBatch.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceMultiRecordBatch.java
@@ -23,6 +23,7 @@ import mockit.NonStrictExpectations;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
 import org.apache.drill.exec.memory.BufferAllocator;
@@ -53,7 +54,7 @@ import com.codahale.metrics.MetricRegistry;
  * multiple record batches and when there is a selection vector present in the
  * incoming container of the trace operator.
  */
-public class TestTraceMultiRecordBatch {
+public class TestTraceMultiRecordBatch extends ExecTest {
     static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestTraceOutputDump.class);
     DrillConfig c = DrillConfig.create();
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceOutputDump.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceOutputDump.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceOutputDump.java
index 910d782..f42efd4 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceOutputDump.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/trace/TestTraceOutputDump.java
@@ -23,6 +23,7 @@ import mockit.NonStrictExpectations;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.cache.VectorAccessibleSerializable;
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
@@ -67,7 +68,7 @@ import com.codahale.metrics.MetricRegistry;
  * the record that is dumped (Integer.MIN_VALUE) so we compare it with this
  * known value.
  */
-public class TestTraceOutputDump {
+public class TestTraceOutputDump extends ExecTest {
     static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestTraceOutputDump.class);
     DrillConfig c = DrillConfig.create();
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/union/TestSimpleUnion.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/union/TestSimpleUnion.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/union/TestSimpleUnion.java
index a57b41f..fc88f2a 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/union/TestSimpleUnion.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/union/TestSimpleUnion.java
@@ -26,6 +26,7 @@ import mockit.NonStrictExpectations;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.memory.TopLevelAllocator;
@@ -47,42 +48,42 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-public class TestSimpleUnion {
+public class TestSimpleUnion extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSimpleUnion.class);
   DrillConfig c = DrillConfig.create();
-  
-  
+
+
   @Test
   public void testUnion(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection) throws Throwable{
 
-    
+
     new NonStrictExpectations(){{
       bitContext.getMetrics(); result = new MetricRegistry();
       bitContext.getAllocator(); result = new TopLevelAllocator();
       bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c);
     }};
-    
-    
+
+
     PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
     PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/union/test1.json"), Charsets.UTF_8));
     FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
     FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
     SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
-    
+
     int[] counts = new int[]{100,50};
     int i=0;
     while(exec.next()){
       System.out.println("iteration count:" + exec.getRecordCount());
       assertEquals(counts[i++], exec.getRecordCount());
     }
-    
+
     if(context.getFailureCause() != null){
       throw context.getFailureCause();
     }
     assertTrue(!context.isFailed());
-    
+
   }
-  
+
   @After
   public void tearDown() throws Exception{
     // pause to get logger to catch up.

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/pop/PopUnitTestBase.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/pop/PopUnitTestBase.java b/exec/java-exec/src/test/java/org/apache/drill/exec/pop/PopUnitTestBase.java
index e5cd508..79bdbae 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/pop/PopUnitTestBase.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/pop/PopUnitTestBase.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.exception.FragmentSetupException;
 import org.apache.drill.exec.physical.PhysicalPlan;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
@@ -37,9 +38,9 @@ import org.junit.rules.Timeout;
 import com.google.common.base.Charsets;
 import com.google.common.io.Files;
 
-public abstract class PopUnitTestBase {
+public abstract class PopUnitTestBase  extends ExecTest{
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PopUnitTestBase.class);
-  
+
   // Determine if we are in Eclipse Debug mode.
   static final boolean IS_DEBUG = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
   protected static DrillConfig CONFIG;
@@ -52,7 +53,7 @@ public abstract class PopUnitTestBase {
     CONFIG = DrillConfig.create();
   }
 
-  
+
   public static int getFragmentCount(Fragment b) {
     int i = 1;
     for (ExchangeFragmentPair p : b) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestInjectionValue.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestInjectionValue.java b/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestInjectionValue.java
index f7c0d06..43fce83 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestInjectionValue.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestInjectionValue.java
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.physical.PhysicalPlan;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.config.Screen;
@@ -34,23 +35,23 @@ import org.junit.Test;
 import com.google.common.base.Charsets;
 import com.google.common.io.Files;
 
-public class TestInjectionValue {
+public class TestInjectionValue extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestInjectionValue.class);
-  
+
   static DrillConfig config;
-  
+
   @BeforeClass
   public static void setup(){
     config = DrillConfig.create();
   }
-  
+
   @Test
   public void testInjected() throws Exception{
     PhysicalPlanReader r = new PhysicalPlanReader(config, config.getMapper(), DrillbitEndpoint.getDefaultInstance());
     PhysicalPlan p = r.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/physical_screen.json"), Charsets.UTF_8));
-    
+
     List<PhysicalOperator> o = p.getSortedOperators(false);
-    
+
     PhysicalOperator op = o.iterator().next();
     assertEquals(Screen.class, op.getClass());
     Screen s = (Screen) op;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java
index 1cc77f9..78fb1c1 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java
@@ -20,7 +20,6 @@ package org.apache.drill.exec.record;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
 import mockit.Injectable;
 import mockit.NonStrictExpectations;
 
@@ -38,6 +37,7 @@ import org.apache.drill.common.types.TypeProtos.DataMode;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.exception.SchemaChangeException;
 import org.apache.drill.exec.expr.ExpressionTreeMaterializer;
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
@@ -48,7 +48,7 @@ import org.junit.Test;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Range;
 
-public class ExpressionTreeMaterializerTest {
+public class ExpressionTreeMaterializerTest extends ExecTest {
 
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExpressionTreeMaterializerTest.class);
 
@@ -58,7 +58,7 @@ public class ExpressionTreeMaterializerTest {
 
   DrillConfig c = DrillConfig.create();
   FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
-      
+
   private MaterializedField getField(int fieldId, String name, MajorType type) {
     return new MaterializedField(FieldDef.newBuilder().setMajorType(type).addName(NamePart.newBuilder().setName(name))
         .build());
@@ -202,7 +202,7 @@ public class ExpressionTreeMaterializerTest {
       }
     };
 
-    
+
     LogicalExpression functionCallExpr = new FunctionCall("testFunc",
       ImmutableList.of((LogicalExpression) new FieldReference("test", ExpressionPosition.UNKNOWN) ),
       ExpressionPosition.UNKNOWN);

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java
index 6251c7f..5c5d566 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java
@@ -27,6 +27,7 @@ import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.types.TypeProtos;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.memory.TopLevelAllocator;
 import org.apache.drill.exec.record.MaterializedField;
@@ -42,7 +43,8 @@ import org.junit.Test;
 
 import com.google.common.collect.Lists;
 
-public class TestLoad {
+public class TestLoad extends ExecTest {
+
   @Test
   public void testLoadValueVector() throws Exception {
     BufferAllocator allocator = new TopLevelAllocator();

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java
index d04e4b3..d79735b 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java
@@ -24,6 +24,7 @@ import java.nio.charset.Charset;
 import org.apache.drill.common.types.TypeProtos.DataMode;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.expr.TypeHelper;
 import org.apache.drill.exec.memory.TopLevelAllocator;
 import org.apache.drill.exec.proto.SchemaDefProtos.FieldDef;
@@ -35,7 +36,7 @@ import org.apache.drill.exec.vector.NullableVarCharVector;
 import org.apache.drill.exec.vector.UInt4Vector;
 import org.junit.Test;
 
-public class TestValueVector {
+public class TestValueVector extends ExecTest {
 
   TopLevelAllocator allocator = new TopLevelAllocator();
 
@@ -108,7 +109,7 @@ public class TestValueVector {
     boolean b = false;
     try {
       v.getAccessor().get(3);
-    } catch(AssertionError e) { 
+    } catch(AssertionError e) {
       b = true;
     }finally{
       if(!b){
@@ -154,30 +155,30 @@ public class TestValueVector {
       boolean b = false;
       try {
         v.getAccessor().get(3);
-      } catch(AssertionError e) { 
+      } catch(AssertionError e) {
         b = true;
       }finally{
         if(!b){
           assert false;
         }
-      }      
+      }
     }
 
-    
+
     v.allocateNew(2048);
     {
       boolean b = false;
       try {
         v.getAccessor().get(0);
-      } catch(AssertionError e) { 
+      } catch(AssertionError e) {
         b = true;
       }finally{
         if(!b){
           assert false;
         }
-      }   
+      }
     }
-    
+
     m.set(0, 100);
     m.set(1, 101);
     m.set(100, 102);
@@ -190,18 +191,18 @@ public class TestValueVector {
     assertEquals(104, v.getAccessor().get(1023));
 
     // Ensure null values throw
-    
+
     {
       boolean b = false;
       try {
         v.getAccessor().get(3);
-      } catch(AssertionError e) { 
+      } catch(AssertionError e) {
         b = true;
       }finally{
         if(!b){
           assert false;
         }
-      }   
+      }
     }
 
   }
@@ -241,27 +242,27 @@ public class TestValueVector {
       boolean b = false;
       try {
         v.getAccessor().get(3);
-      } catch(AssertionError e) { 
+      } catch(AssertionError e) {
         b = true;
       }finally{
         if(!b){
           assert false;
         }
-      }   
+      }
     }
-    
+
     v.allocateNew(2048);
     {
       boolean b = false;
       try {
         v.getAccessor().get(0);
-      } catch(AssertionError e) { 
+      } catch(AssertionError e) {
         b = true;
       }finally{
         if(!b){
           assert false;
         }
-      }   
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java b/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java
index cb81175..74f5ba9 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java
@@ -31,6 +31,7 @@ import org.apache.drill.common.expression.ExpressionPosition;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.expr.TypeHelper;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.proto.BitData.FragmentRecordBatch;
@@ -61,7 +62,7 @@ import org.junit.Test;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.Lists;
 
-public class TestBitRpc {
+public class TestBitRpc extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestBitRpc.class);
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestAffinityCalculator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestAffinityCalculator.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestAffinityCalculator.java
index 67b11cb..58a36a8 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestAffinityCalculator.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestAffinityCalculator.java
@@ -24,6 +24,7 @@ import junit.framework.Assert;
 import mockit.Injectable;
 import mockit.NonStrictExpectations;
 
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.physical.EndpointAffinity;
 import org.apache.drill.exec.proto.CoordinationProtos;
 import org.apache.drill.exec.server.DrillbitContext;
@@ -46,7 +47,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 
-public class TestAffinityCalculator {
+public class TestAffinityCalculator extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestAffinityCalculator.class);
 
   String port = "1234";

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestOrphanSchema.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestOrphanSchema.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestOrphanSchema.java
index f61f4ee..d7e74cb 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestOrphanSchema.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/TestOrphanSchema.java
@@ -22,7 +22,7 @@ import net.hydromatic.optiq.SchemaPlus;
 import net.hydromatic.optiq.tools.Frameworks;
 
 import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.exec.cache.HazelCache;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.cache.LocalCache;
 import org.apache.drill.exec.memory.TopLevelAllocator;
 import org.apache.drill.exec.server.DrillbitContext;
@@ -30,7 +30,7 @@ import org.junit.Test;
 
 import com.codahale.metrics.MetricRegistry;
 
-public class TestOrphanSchema {
+public class TestOrphanSchema extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestOrphanSchema.class);
 
 
@@ -52,7 +52,7 @@ public class TestOrphanSchema {
     };
 
     bitContext.getCache().run();
-    
+
     StoragePluginRegistry r = new StoragePluginRegistry(bitContext);
     SchemaPlus plus = Frameworks.createRootSchema();
     r.init();

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestOrphanSchema.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestOrphanSchema.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestOrphanSchema.java
index d4755fa..0e06af1 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestOrphanSchema.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestOrphanSchema.java
@@ -26,6 +26,7 @@ import java.util.List;
 import net.hydromatic.optiq.SchemaPlus;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.exception.SchemaChangeException;
 import org.apache.drill.exec.memory.TopLevelAllocator;
 import org.apache.drill.exec.ops.FragmentContext;
@@ -46,7 +47,7 @@ import org.junit.Test;
  * Using an orphan schema, create and display the various information schema tables.
  * An "orphan schema" is a stand alone schema which is not (yet?) connected to Optiq.
  */
-public class TestOrphanSchema {
+public class TestOrphanSchema extends ExecTest {
   static SchemaPlus root;
 
   @BeforeClass

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestTableProvider.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestTableProvider.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestTableProvider.java
index 0cc0b71..e1ed53a 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestTableProvider.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/ischema/TestTableProvider.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
 import org.apache.drill.common.types.TypeProtos.MajorType;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.exception.SchemaChangeException;
 import org.apache.drill.exec.memory.TopLevelAllocator;
 import org.apache.drill.exec.ops.FragmentContext;
@@ -39,7 +40,7 @@ import org.junit.Test;
 /**
  * Using a test table with two columns, create data and verify the values are in the record batch.
  */
-public class TestTableProvider {
+public class TestTableProvider extends ExecTest {
 
   @Test
   public void zeroRead() {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java
index 9f54349..c3e7491 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java
@@ -38,6 +38,7 @@ import org.apache.drill.common.expression.FieldReference;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.exception.SchemaChangeException;
 import org.apache.drill.exec.memory.TopLevelAllocator;
 import org.apache.drill.exec.ops.FragmentContext;
@@ -55,7 +56,7 @@ import org.junit.Test;
 import com.google.common.collect.Lists;
 
 
-public class JSONRecordReaderTest {
+public class JSONRecordReaderTest extends ExecTest {
   private static final Charset UTF_8 = Charset.forName("UTF-8");
 
   private String getResource(String resourceName) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java
index 4d9b606..a885ede 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java
@@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.client.DrillClient;
 import org.apache.drill.exec.proto.UserBitShared.QueryId;
 import org.apache.drill.exec.proto.UserProtos;
@@ -43,7 +44,7 @@ import com.google.common.base.Charsets;
 import com.google.common.base.Stopwatch;
 import com.google.common.io.Resources;
 
-public class TestParquetPhysicalPlan {
+public class TestParquetPhysicalPlan extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestParquetPhysicalPlan.class);
 
   public String fileName = "parquet/parquet_scan_filter_union_screen_physical.json";

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/TestSpoolingBuffer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/TestSpoolingBuffer.java b/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/TestSpoolingBuffer.java
index d8c280a..e2fc3f7 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/TestSpoolingBuffer.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/TestSpoolingBuffer.java
@@ -20,8 +20,10 @@ package org.apache.drill.exec.work.batch;
 import com.google.common.base.Charsets;
 import com.google.common.io.Files;
 import com.google.common.io.Resources;
+
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.ExecTest;
 import org.apache.drill.exec.client.DrillClient;
 import org.apache.drill.exec.proto.UserProtos;
 import org.apache.drill.exec.rpc.user.QueryResultBatch;
@@ -34,7 +36,7 @@ import java.util.List;
 
 import static org.junit.Assert.assertEquals;
 
-public class TestSpoolingBuffer {
+public class TestSpoolingBuffer extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSpoolingBuffer.class);
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/sqlparser/pom.xml
----------------------------------------------------------------------
diff --git a/sqlparser/pom.xml b/sqlparser/pom.xml
index 8266dcb..931fc7d 100644
--- a/sqlparser/pom.xml
+++ b/sqlparser/pom.xml
@@ -35,7 +35,13 @@
       <artifactId>drill-java-exec</artifactId>
       <version>${project.version}</version>
     </dependency>
-
+    <dependency>
+      <groupId>org.apache.drill</groupId>
+      <artifactId>drill-common</artifactId>
+      <classifier>tests</classifier>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.drill.exec</groupId>
       <artifactId>drill-java-exec</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/sqlparser/src/test/java/org/apache/drill/jdbc/JdbcTest.java
----------------------------------------------------------------------
diff --git a/sqlparser/src/test/java/org/apache/drill/jdbc/JdbcTest.java b/sqlparser/src/test/java/org/apache/drill/jdbc/JdbcTest.java
new file mode 100644
index 0000000..3f44ed8
--- /dev/null
+++ b/sqlparser/src/test/java/org/apache/drill/jdbc/JdbcTest.java
@@ -0,0 +1,24 @@
+/**
+ * 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 org.apache.drill.exec.ExecTest;
+
+public class JdbcTest extends ExecTest{
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JdbcTest.class);
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcDataTest.java
----------------------------------------------------------------------
diff --git a/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcDataTest.java b/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcDataTest.java
new file mode 100644
index 0000000..0e9f8a0
--- /dev/null
+++ b/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcDataTest.java
@@ -0,0 +1,521 @@
+/**
+ * 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.test;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Map;
+
+import org.apache.drill.common.logical.LogicalPlan;
+import org.apache.drill.common.logical.PlanProperties;
+import org.apache.drill.common.logical.StoragePluginConfig;
+import org.apache.drill.common.logical.data.Filter;
+import org.apache.drill.common.logical.data.Join;
+import org.apache.drill.common.logical.data.Limit;
+import org.apache.drill.common.logical.data.LogicalOperator;
+import org.apache.drill.common.logical.data.Order;
+import org.apache.drill.common.logical.data.Project;
+import org.apache.drill.common.logical.data.Scan;
+import org.apache.drill.common.logical.data.Store;
+import org.apache.drill.common.logical.data.Union;
+import org.apache.drill.jdbc.JdbcTest;
+import org.apache.drill.jdbc.test.JdbcAssert.TestDataConnection;
+import org.eigenbase.rel.JoinRelType;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.io.Resources;
+
+/** Unit tests for Drill's JDBC driver. */
+
+
+@Ignore // ignore for now.
+public class JdbcDataTest extends JdbcTest{
+  private static String MODEL;
+  private static String EXPECTED;
+
+
+  @BeforeClass
+  public static void setupFixtures() throws IOException {
+    MODEL = Resources.toString(Resources.getResource("test-models.json"), Charsets.UTF_8);
+    EXPECTED = Resources.toString(Resources.getResource("donuts-output-data.txt"), Charsets.UTF_8);
+  }
+
+  /**
+   * Command-line utility to execute a logical plan.
+   *
+   * <p>
+   * The forwarding method ensures that the IDE calls this method with the right classpath.
+   * </p>
+   */
+  public static void main(String[] args) throws Exception {
+  }
+
+  /** Load driver. */
+  @Test
+  public void testLoadDriver() throws ClassNotFoundException {
+    Class.forName("org.apache.drill.jdbc.Driver");
+  }
+
+  /** Load driver and make a connection. */
+  @Test
+  public void testConnect() throws Exception {
+    Class.forName("org.apache.drill.jdbc.Driver");
+    final Connection connection = DriverManager.getConnection("jdbc:drill:zk=local");
+    connection.close();
+  }
+
+  /** Load driver, make a connection, prepare a statement. */
+  @Test
+  public void testPrepare() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").withConnection(new Function<Connection, Void>() {
+      public Void apply(Connection connection) {
+        try {
+          final Statement statement = connection.prepareStatement("select * from donuts");
+          statement.close();
+          return null;
+        } catch (Exception e) {
+          throw new RuntimeException(e);
+        }
+      }
+    });
+  }
+
+  /** Simple query against JSON. */
+  @Test
+  public void testSelectJson() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("select * from donuts").returns(EXPECTED);
+  }
+
+  /** Simple query against EMP table in HR database. */
+  @Test
+  public void testSelectEmployees() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from employees")
+        .returns(
+            "_MAP={deptId=31, lastName=Rafferty}\n" + "_MAP={deptId=33, lastName=Jones}\n"
+                + "_MAP={deptId=33, lastName=Steinberg}\n" + "_MAP={deptId=34, lastName=Robinson}\n"
+                + "_MAP={deptId=34, lastName=Smith}\n" + "_MAP={lastName=John}\n");
+  }
+
+  /** Simple query against EMP table in HR database. */
+  @Test
+  public void testSelectEmpView() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp")
+        .returns(
+            "DEPTID=31; LASTNAME=Rafferty\n" + "DEPTID=33; LASTNAME=Jones\n" + "DEPTID=33; LASTNAME=Steinberg\n"
+                + "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n" + "DEPTID=null; LASTNAME=John\n");
+  }
+
+  /** Simple query against EMP table in HR database. */
+  @Test
+  public void testSelectDept() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from departments")
+        .returns(
+            "_MAP={deptId=31, name=Sales}\n" + "_MAP={deptId=33, name=Engineering}\n"
+                + "_MAP={deptId=34, name=Clerical}\n" + "_MAP={deptId=35, name=Marketing}\n");
+  }
+
+  /** Query with project list. No field references yet. */
+  @Test
+  public void testProjectConstant() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("select 1 + 3 as c from donuts")
+        .returns("C=4\n" + "C=4\n" + "C=4\n" + "C=4\n" + "C=4\n");
+  }
+
+  /** Query that projects an element from the map. */
+  @Test
+  public void testProject() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("select _MAP['ppu'] as ppu from donuts")
+        .returns("PPU=0.55\n" + "PPU=0.69\n" + "PPU=0.55\n" + "PPU=0.69\n" + "PPU=1.0\n");
+  }
+
+  /** Same logic as {@link #testProject()}, but using a subquery. */
+  @Test
+  public void testProjectOnSubquery() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("select d['ppu'] as ppu from (\n" + " select _MAP as d from donuts)")
+        .returns("PPU=0.55\n" + "PPU=0.69\n" + "PPU=0.55\n" + "PPU=0.69\n" + "PPU=1.0\n");
+  }
+
+  /** Checks the logical plan. */
+  @Test
+  public void testProjectPlan() throws Exception {
+    LogicalPlan plan = JdbcAssert
+        .withModel(MODEL, "DONUTS")
+        .sql("select _MAP['ppu'] as ppu from donuts")
+        .logicalPlan();
+
+    PlanProperties planProperties = plan.getProperties();
+    Assert.assertEquals("optiq", planProperties.generator.type);
+    Assert.assertEquals("na", planProperties.generator.info);
+    Assert.assertEquals(1, planProperties.version);
+    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
+    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
+    StoragePluginConfig config = seConfigs.get("donuts-json");
+//    Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
+    config = seConfigs.get("queue");
+//    Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
+    Scan scan = findOnlyOperator(plan, Scan.class);
+    Assert.assertEquals("donuts-json", scan.getStorageEngine());
+    Project project = findOnlyOperator(plan, Project.class);
+    Assert.assertEquals(1, project.getSelections().length);
+    Assert.assertEquals(Scan.class, project.getInput().getClass());
+    Store store = findOnlyOperator(plan, Store.class);
+    Assert.assertEquals("queue", store.getStorageEngine());
+    Assert.assertEquals("output sink", store.getMemo());
+    Assert.assertEquals(Project.class, store.getInput().getClass());
+  }
+
+  /**
+   * Query with subquery, filter, and projection of one real and one nonexistent field from a map field.
+   */
+  @Test
+  public void testProjectFilterSubquery() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "DONUTS")
+        .sql(
+            "select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP as d from donuts)\n"
+                + "where cast(d['ppu'] as double) > 0.6")
+        .returns("NAME=Raised; XX=null\n" + "NAME=Filled; XX=null\n" + "NAME=Apple Fritter; XX=null\n");
+  }
+
+  private static <T extends LogicalOperator> Iterable<T> findOperator(LogicalPlan plan, final Class<T> operatorClazz) {
+    return (Iterable<T>) Iterables.filter(plan.getSortedOperators(), new Predicate<LogicalOperator>() {
+      @Override
+      public boolean apply(LogicalOperator input) {
+        return input.getClass().equals(operatorClazz);
+      }
+    });
+  }
+
+  private static <T extends LogicalOperator> T findOnlyOperator(LogicalPlan plan, final Class<T> operatorClazz) {
+    return Iterables.getOnlyElement(findOperator(plan, operatorClazz));
+  }
+
+  @Test
+  public void testProjectFilterSubqueryPlan() throws Exception {
+    LogicalPlan plan = JdbcAssert
+        .withModel(MODEL, "DONUTS")
+        .sql(
+            "select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP['donuts'] as d from donuts)\n"
+                + "where cast(d['ppu'] as double) > 0.6")
+        .logicalPlan();
+    PlanProperties planProperties = plan.getProperties();
+    Assert.assertEquals("optiq", planProperties.generator.type);
+    Assert.assertEquals("na", planProperties.generator.info);
+    Assert.assertEquals(1, planProperties.version);
+    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
+    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
+    StoragePluginConfig config = seConfigs.get("donuts-json");
+//    Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
+    config = seConfigs.get("queue");
+//    Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
+    Scan scan = findOnlyOperator(plan, Scan.class);
+    Assert.assertEquals("donuts-json", scan.getStorageEngine());
+    Filter filter = findOnlyOperator(plan, Filter.class);
+    Assert.assertTrue(filter.getInput() instanceof Scan);
+    Project[] projects = Iterables.toArray(findOperator(plan, Project.class), Project.class);
+    Assert.assertEquals(2, projects.length);
+    Assert.assertEquals(1, projects[0].getSelections().length);
+    Assert.assertEquals(Filter.class, projects[0].getInput().getClass());
+    Assert.assertEquals(2, projects[1].getSelections().length);
+    Assert.assertEquals(Project.class, projects[1].getInput().getClass());
+    Store store = findOnlyOperator(plan, Store.class);
+    Assert.assertEquals("queue", store.getStorageEngine());
+    Assert.assertEquals("output sink", store.getMemo());
+    Assert.assertEquals(Project.class, store.getInput().getClass());
+  }
+
+  /** Query that projects one field. (Disabled; uses sugared syntax.) */
+  @Test @Ignore
+  public void testProjectNestedFieldSugared() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("select donuts.ppu from donuts")
+        .returns("C=4\n" + "C=4\n" + "C=4\n" + "C=4\n" + "C=4\n");
+  }
+
+  /** Query with filter. No field references yet. */
+  @Test
+  public void testFilterConstantFalse() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("select * from donuts where 3 > 4").returns("");
+  }
+
+  @Test
+  public void testFilterConstant() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("select * from donuts where 3 < 4").returns(EXPECTED);
+  }
+
+
+  @Ignore
+  @Test
+  public void testValues() throws Exception {
+    JdbcAssert.withModel(MODEL, "DONUTS").sql("values (1)").returns("EXPR$0=1\n");
+
+    // Enable when https://issues.apache.org/jira/browse/DRILL-57 fixed
+    // .planContains("store");
+  }
+
+//  @Test
+//  public void testDistinct() throws Exception {
+//    JdbcAssert.withModel(MODEL, "HR").sql("select distinct deptId from emp")
+//        .returnsUnordered("DEPTID=null", "DEPTID=31", "DEPTID=34", "DEPTID=33")
+//        .planContains(CollapsingAggregate.class);
+//  }
+//
+//  @Test
+//  public void testCountNoGroupBy() throws Exception {
+//    // 5 out of 6 employees have a not-null deptId
+//    JdbcAssert.withModel(MODEL, "HR").sql("select count(deptId) as cd, count(*) as c from emp").returns("CD=5; C=6\n")
+//        .planContains(CollapsingAggregate.class);
+//  }
+//
+//  @Test
+//  public void testDistinctCountNoGroupBy() throws Exception {
+//    JdbcAssert.withModel(MODEL, "HR").sql("select count(distinct deptId) as c from emp").returns("C=3\n")
+//        .planContains(CollapsingAggregate.class);
+//  }
+//
+//  @Test
+//  public void testDistinctCountGroupByEmpty() throws Exception {
+//    JdbcAssert.withModel(MODEL, "HR").sql("select count(distinct deptId) as c from emp group by ()").returns("C=3\n")
+//        .planContains(CollapsingAggregate.class);
+//  }
+//
+//  @Test
+//  public void testCountNull() throws Exception {
+//    JdbcAssert.withModel(MODEL, "HR").sql("select count(distinct deptId) as c from emp group by ()").returns("C=3\n")
+//        .planContains(CollapsingAggregate.class);
+//  }
+//
+//  @Test
+//  public void testCount() throws Exception {
+//    JdbcAssert.withModel(MODEL, "HR").sql("select deptId, count(*) as c from emp group by deptId")
+//        .returnsUnordered("DEPTID=31; C=1", "DEPTID=33; C=2", "DEPTID=34; C=2", "DEPTID=null; C=1")
+//        .planContains(CollapsingAggregate.class); // make sure using drill
+//  }
+
+  @Test
+  public void testJoin() throws Exception {
+    Join join = JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp join dept on emp.deptId = dept.deptId")
+        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales",
+            "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering",
+            "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering",
+            "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical",
+            "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical").planContains(Join.class);
+    Assert.assertEquals(JoinRelType.INNER, join.getJoinType());
+  }
+
+  @Test
+  public void testLeftJoin() throws Exception {
+    Join join = JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp left join dept on emp.deptId = dept.deptId")
+        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales",
+            "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering",
+            "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering",
+            "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical",
+            "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical",
+            "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null").planContains(Join.class);
+    Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
+  }
+
+  /**
+   * Right join is tricky because Drill's "join" operator only supports "left", so we have to flip inputs.
+   */
+  @Test @Ignore
+  public void testRightJoin() throws Exception {
+    Join join = JdbcAssert.withModel(MODEL, "HR").sql("select * from emp right join dept on emp.deptId = dept.deptId")
+        .returnsUnordered("xx").planContains(Join.class);
+    Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
+  }
+
+  @Test
+  public void testFullJoin() throws Exception {
+    Join join = JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp full join dept on emp.deptId = dept.deptId")
+        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales",
+            "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering",
+            "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering",
+            "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical",
+            "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical",
+            "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null",
+            "DEPTID=null; LASTNAME=null; DEPTID0=35; NAME=Marketing").planContains(Join.class);
+    Assert.assertEquals(JoinRelType.FULL, join.getJoinType());
+  }
+
+  /**
+   * Join on subquery; also tests that if a field of the same name exists in both inputs, both fields make it through
+   * the join.
+   */
+  @Test
+  public void testJoinOnSubquery() throws Exception {
+    Join join = JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql(
+            "select * from (\n" + "select deptId, lastname, 'x' as name from emp) as e\n"
+                + " join dept on e.deptId = dept.deptId")
+        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; NAME=x; DEPTID0=31; NAME0=Sales",
+            "DEPTID=33; LASTNAME=Jones; NAME=x; DEPTID0=33; NAME0=Engineering",
+            "DEPTID=33; LASTNAME=Steinberg; NAME=x; DEPTID0=33; NAME0=Engineering",
+            "DEPTID=34; LASTNAME=Robinson; NAME=x; DEPTID0=34; NAME0=Clerical",
+            "DEPTID=34; LASTNAME=Smith; NAME=x; DEPTID0=34; NAME0=Clerical").planContains(Join.class);
+    Assert.assertEquals(JoinRelType.INNER, join.getJoinType());
+  }
+
+  /** Tests that one of the FoodMart tables is present. */
+  @Test @Ignore
+  public void testFoodMart() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "FOODMART")
+        .sql("select * from product_class where cast(_map['product_class_id'] as integer) < 3")
+        .returnsUnordered(
+            "_MAP={product_category=Seafood, product_class_id=2, product_department=Seafood, product_family=Food, product_subcategory=Shellfish}",
+            "_MAP={product_category=Specialty, product_class_id=1, product_department=Produce, product_family=Food, product_subcategory=Nuts}");
+  }
+
+  @Test
+  public void testUnionAll() throws Exception {
+    Union union = JdbcAssert.withModel(MODEL, "HR").sql("select deptId from dept\n" + "union all\n" + "select deptId from emp")
+        .returnsUnordered("DEPTID=31", "DEPTID=33", "DEPTID=34", "DEPTID=35", "DEPTID=null")
+        .planContains(Union.class);
+    Assert.assertFalse(union.isDistinct());
+  }
+
+  @Test
+  public void testUnion() throws Exception {
+    Union union = JdbcAssert.withModel(MODEL, "HR").sql("select deptId from dept\n" + "union\n" + "select deptId from emp")
+        .returnsUnordered("DEPTID=31", "DEPTID=33", "DEPTID=34", "DEPTID=35", "DEPTID=null")
+        .planContains(Union.class);
+    Assert.assertTrue(union.isDistinct());
+  }
+
+  @Test
+  public void testOrderByDescNullsFirst() throws Exception {
+    // desc nulls last
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp order by deptId desc nulls first")
+        .returns(
+            "DEPTID=null; LASTNAME=John\n" + "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n"
+                + "DEPTID=33; LASTNAME=Jones\n" + "DEPTID=33; LASTNAME=Steinberg\n" + "DEPTID=31; LASTNAME=Rafferty\n")
+        .planContains(Order.class);
+  }
+
+  @Test
+  public void testOrderByDescNullsLast() throws Exception {
+    // desc nulls first
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp order by deptId desc nulls last")
+        .returns(
+            "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n" + "DEPTID=33; LASTNAME=Jones\n"
+                + "DEPTID=33; LASTNAME=Steinberg\n" + "DEPTID=31; LASTNAME=Rafferty\n" + "DEPTID=null; LASTNAME=John\n")
+        .planContains(Order.class);
+  }
+
+  @Test @Ignore
+  public void testOrderByDesc() throws Exception {
+    // desc is implicitly "nulls first" (i.e. null sorted as +inf)
+    // Current behavior is to sort nulls last. This is wrong.
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp order by deptId desc")
+        .returns(
+            "DEPTID=null; LASTNAME=John\n" + "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n"
+                + "DEPTID=33; LASTNAME=Jones\n" + "DEPTID=33; LASTNAME=Steinberg\n" + "DEPTID=31; LASTNAME=Rafferty\n")
+        .planContains(Order.class);
+  }
+
+  @Test
+  public void testOrderBy() throws Exception {
+    // no sort order specified is implicitly "asc", and asc is "nulls last"
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select * from emp order by deptId")
+        .returns(
+            "DEPTID=31; LASTNAME=Rafferty\n"
+            + "DEPTID=33; LASTNAME=Jones\n"
+            + "DEPTID=33; LASTNAME=Steinberg\n"
+            + "DEPTID=34; LASTNAME=Robinson\n"
+            + "DEPTID=34; LASTNAME=Smith\n"
+            + "DEPTID=null; LASTNAME=John\n")
+        .planContains(Order.class);
+  }
+
+  @Test
+  public void testLimit() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select LASTNAME from emp limit 2")
+        .returns("LASTNAME=Rafferty\n" +
+            "LASTNAME=Jones")
+        .planContains(Limit.class);
+  }
+
+
+  @Test
+  public void testLimitOrderBy() throws Exception {
+    TestDataConnection tdc = JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select LASTNAME from emp order by LASTNAME limit 2")
+        .returns("LASTNAME=John\n" +
+            "LASTNAME=Jones");
+        tdc.planContains(Limit.class);
+        tdc.planContains(Order.class);
+
+  }
+
+  @Test
+  public void testOrderByWithOffset() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select LASTNAME from emp order by LASTNAME asc offset 3")
+        .returns("LASTNAME=Robinson\n" +
+            "LASTNAME=Smith\n" +
+            "LASTNAME=Steinberg")
+        .planContains(Limit.class);
+
+  }
+
+  @Test
+  public void testOrderByWithOffsetAndFetch() throws Exception {
+    JdbcAssert
+        .withModel(MODEL, "HR")
+        .sql("select LASTNAME from emp order by LASTNAME asc offset 3 fetch next 2 rows only")
+        .returns("LASTNAME=Robinson\n" +
+            "LASTNAME=Smith")
+        .planContains(Limit.class);
+  }
+}
+
+// End JdbcTest.java

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/16481951/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java b/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
deleted file mode 100644
index 1e4edca..0000000
--- a/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java
+++ /dev/null
@@ -1,520 +0,0 @@
-/**
- * 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.test;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.Map;
-
-import org.apache.drill.common.logical.LogicalPlan;
-import org.apache.drill.common.logical.PlanProperties;
-import org.apache.drill.common.logical.StoragePluginConfig;
-import org.apache.drill.common.logical.data.Filter;
-import org.apache.drill.common.logical.data.Join;
-import org.apache.drill.common.logical.data.Limit;
-import org.apache.drill.common.logical.data.LogicalOperator;
-import org.apache.drill.common.logical.data.Order;
-import org.apache.drill.common.logical.data.Project;
-import org.apache.drill.common.logical.data.Scan;
-import org.apache.drill.common.logical.data.Store;
-import org.apache.drill.common.logical.data.Union;
-import org.apache.drill.jdbc.test.JdbcAssert.TestDataConnection;
-import org.eigenbase.rel.JoinRelType;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.io.Resources;
-
-/** Unit tests for Drill's JDBC driver. */
-
-
-@Ignore // ignore for now.
-public class JdbcTest {
-  private static String MODEL;
-  private static String EXPECTED;
-
-
-  @BeforeClass
-  public static void setupFixtures() throws IOException {
-    MODEL = Resources.toString(Resources.getResource("test-models.json"), Charsets.UTF_8);
-    EXPECTED = Resources.toString(Resources.getResource("donuts-output-data.txt"), Charsets.UTF_8);
-  }
-
-  /**
-   * Command-line utility to execute a logical plan.
-   * 
-   * <p>
-   * The forwarding method ensures that the IDE calls this method with the right classpath.
-   * </p>
-   */
-  public static void main(String[] args) throws Exception {
-  }
-
-  /** Load driver. */
-  @Test
-  public void testLoadDriver() throws ClassNotFoundException {
-    Class.forName("org.apache.drill.jdbc.Driver");
-  }
-
-  /** Load driver and make a connection. */
-  @Test
-  public void testConnect() throws Exception {
-    Class.forName("org.apache.drill.jdbc.Driver");
-    final Connection connection = DriverManager.getConnection("jdbc:drill:zk=local");
-    connection.close();
-  }
-
-  /** Load driver, make a connection, prepare a statement. */
-  @Test
-  public void testPrepare() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").withConnection(new Function<Connection, Void>() {
-      public Void apply(Connection connection) {
-        try {
-          final Statement statement = connection.prepareStatement("select * from donuts");
-          statement.close();
-          return null;
-        } catch (Exception e) {
-          throw new RuntimeException(e);
-        }
-      }
-    });
-  }
-
-  /** Simple query against JSON. */
-  @Test
-  public void testSelectJson() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("select * from donuts").returns(EXPECTED);
-  }
-
-  /** Simple query against EMP table in HR database. */
-  @Test
-  public void testSelectEmployees() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from employees")
-        .returns(
-            "_MAP={deptId=31, lastName=Rafferty}\n" + "_MAP={deptId=33, lastName=Jones}\n"
-                + "_MAP={deptId=33, lastName=Steinberg}\n" + "_MAP={deptId=34, lastName=Robinson}\n"
-                + "_MAP={deptId=34, lastName=Smith}\n" + "_MAP={lastName=John}\n");
-  }
-
-  /** Simple query against EMP table in HR database. */
-  @Test
-  public void testSelectEmpView() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp")
-        .returns(
-            "DEPTID=31; LASTNAME=Rafferty\n" + "DEPTID=33; LASTNAME=Jones\n" + "DEPTID=33; LASTNAME=Steinberg\n"
-                + "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n" + "DEPTID=null; LASTNAME=John\n");
-  }
-
-  /** Simple query against EMP table in HR database. */
-  @Test
-  public void testSelectDept() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from departments")
-        .returns(
-            "_MAP={deptId=31, name=Sales}\n" + "_MAP={deptId=33, name=Engineering}\n"
-                + "_MAP={deptId=34, name=Clerical}\n" + "_MAP={deptId=35, name=Marketing}\n");
-  }
-
-  /** Query with project list. No field references yet. */
-  @Test
-  public void testProjectConstant() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("select 1 + 3 as c from donuts")
-        .returns("C=4\n" + "C=4\n" + "C=4\n" + "C=4\n" + "C=4\n");
-  }
-
-  /** Query that projects an element from the map. */
-  @Test
-  public void testProject() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("select _MAP['ppu'] as ppu from donuts")
-        .returns("PPU=0.55\n" + "PPU=0.69\n" + "PPU=0.55\n" + "PPU=0.69\n" + "PPU=1.0\n");
-  }
-
-  /** Same logic as {@link #testProject()}, but using a subquery. */
-  @Test
-  public void testProjectOnSubquery() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("select d['ppu'] as ppu from (\n" + " select _MAP as d from donuts)")
-        .returns("PPU=0.55\n" + "PPU=0.69\n" + "PPU=0.55\n" + "PPU=0.69\n" + "PPU=1.0\n");
-  }
-
-  /** Checks the logical plan. */
-  @Test
-  public void testProjectPlan() throws Exception {
-    LogicalPlan plan = JdbcAssert
-        .withModel(MODEL, "DONUTS")
-        .sql("select _MAP['ppu'] as ppu from donuts")
-        .logicalPlan();
-
-    PlanProperties planProperties = plan.getProperties();
-    Assert.assertEquals("optiq", planProperties.generator.type);
-    Assert.assertEquals("na", planProperties.generator.info);
-    Assert.assertEquals(1, planProperties.version);
-    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
-    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
-    StoragePluginConfig config = seConfigs.get("donuts-json");
-//    Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
-    config = seConfigs.get("queue");
-//    Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
-    Scan scan = findOnlyOperator(plan, Scan.class);
-    Assert.assertEquals("donuts-json", scan.getStorageEngine());
-    Project project = findOnlyOperator(plan, Project.class);
-    Assert.assertEquals(1, project.getSelections().length);
-    Assert.assertEquals(Scan.class, project.getInput().getClass());
-    Store store = findOnlyOperator(plan, Store.class);
-    Assert.assertEquals("queue", store.getStorageEngine());
-    Assert.assertEquals("output sink", store.getMemo());
-    Assert.assertEquals(Project.class, store.getInput().getClass());
-  }
-
-  /**
-   * Query with subquery, filter, and projection of one real and one nonexistent field from a map field.
-   */
-  @Test
-  public void testProjectFilterSubquery() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "DONUTS")
-        .sql(
-            "select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP as d from donuts)\n"
-                + "where cast(d['ppu'] as double) > 0.6")
-        .returns("NAME=Raised; XX=null\n" + "NAME=Filled; XX=null\n" + "NAME=Apple Fritter; XX=null\n");
-  }
-
-  private static <T extends LogicalOperator> Iterable<T> findOperator(LogicalPlan plan, final Class<T> operatorClazz) {
-    return (Iterable<T>) Iterables.filter(plan.getSortedOperators(), new Predicate<LogicalOperator>() {
-      @Override
-      public boolean apply(LogicalOperator input) {
-        return input.getClass().equals(operatorClazz);
-      }
-    });
-  }
-
-  private static <T extends LogicalOperator> T findOnlyOperator(LogicalPlan plan, final Class<T> operatorClazz) {
-    return Iterables.getOnlyElement(findOperator(plan, operatorClazz));
-  }
-
-  @Test
-  public void testProjectFilterSubqueryPlan() throws Exception {
-    LogicalPlan plan = JdbcAssert
-        .withModel(MODEL, "DONUTS")
-        .sql(
-            "select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP['donuts'] as d from donuts)\n"
-                + "where cast(d['ppu'] as double) > 0.6")
-        .logicalPlan();
-    PlanProperties planProperties = plan.getProperties();
-    Assert.assertEquals("optiq", planProperties.generator.type);
-    Assert.assertEquals("na", planProperties.generator.info);
-    Assert.assertEquals(1, planProperties.version);
-    Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
-    Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
-    StoragePluginConfig config = seConfigs.get("donuts-json");
-//    Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
-    config = seConfigs.get("queue");
-//    Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
-    Scan scan = findOnlyOperator(plan, Scan.class);
-    Assert.assertEquals("donuts-json", scan.getStorageEngine());
-    Filter filter = findOnlyOperator(plan, Filter.class);
-    Assert.assertTrue(filter.getInput() instanceof Scan);
-    Project[] projects = Iterables.toArray(findOperator(plan, Project.class), Project.class);
-    Assert.assertEquals(2, projects.length);
-    Assert.assertEquals(1, projects[0].getSelections().length);
-    Assert.assertEquals(Filter.class, projects[0].getInput().getClass());
-    Assert.assertEquals(2, projects[1].getSelections().length);
-    Assert.assertEquals(Project.class, projects[1].getInput().getClass());
-    Store store = findOnlyOperator(plan, Store.class);
-    Assert.assertEquals("queue", store.getStorageEngine());
-    Assert.assertEquals("output sink", store.getMemo());
-    Assert.assertEquals(Project.class, store.getInput().getClass());
-  }
-
-  /** Query that projects one field. (Disabled; uses sugared syntax.) */
-  @Test @Ignore
-  public void testProjectNestedFieldSugared() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("select donuts.ppu from donuts")
-        .returns("C=4\n" + "C=4\n" + "C=4\n" + "C=4\n" + "C=4\n");
-  }
-
-  /** Query with filter. No field references yet. */
-  @Test
-  public void testFilterConstantFalse() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("select * from donuts where 3 > 4").returns("");
-  }
-
-  @Test
-  public void testFilterConstant() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("select * from donuts where 3 < 4").returns(EXPECTED);
-  }
-
-  
-  @Ignore
-  @Test
-  public void testValues() throws Exception {
-    JdbcAssert.withModel(MODEL, "DONUTS").sql("values (1)").returns("EXPR$0=1\n");
-
-    // Enable when https://issues.apache.org/jira/browse/DRILL-57 fixed
-    // .planContains("store");
-  }
-
-//  @Test
-//  public void testDistinct() throws Exception {
-//    JdbcAssert.withModel(MODEL, "HR").sql("select distinct deptId from emp")
-//        .returnsUnordered("DEPTID=null", "DEPTID=31", "DEPTID=34", "DEPTID=33")
-//        .planContains(CollapsingAggregate.class);
-//  }
-//
-//  @Test
-//  public void testCountNoGroupBy() throws Exception {
-//    // 5 out of 6 employees have a not-null deptId
-//    JdbcAssert.withModel(MODEL, "HR").sql("select count(deptId) as cd, count(*) as c from emp").returns("CD=5; C=6\n")
-//        .planContains(CollapsingAggregate.class);
-//  }
-//
-//  @Test
-//  public void testDistinctCountNoGroupBy() throws Exception {
-//    JdbcAssert.withModel(MODEL, "HR").sql("select count(distinct deptId) as c from emp").returns("C=3\n")
-//        .planContains(CollapsingAggregate.class);
-//  }
-//
-//  @Test
-//  public void testDistinctCountGroupByEmpty() throws Exception {
-//    JdbcAssert.withModel(MODEL, "HR").sql("select count(distinct deptId) as c from emp group by ()").returns("C=3\n")
-//        .planContains(CollapsingAggregate.class);
-//  }
-//
-//  @Test
-//  public void testCountNull() throws Exception {
-//    JdbcAssert.withModel(MODEL, "HR").sql("select count(distinct deptId) as c from emp group by ()").returns("C=3\n")
-//        .planContains(CollapsingAggregate.class);
-//  }
-//
-//  @Test
-//  public void testCount() throws Exception {
-//    JdbcAssert.withModel(MODEL, "HR").sql("select deptId, count(*) as c from emp group by deptId")
-//        .returnsUnordered("DEPTID=31; C=1", "DEPTID=33; C=2", "DEPTID=34; C=2", "DEPTID=null; C=1")
-//        .planContains(CollapsingAggregate.class); // make sure using drill
-//  }
-
-  @Test
-  public void testJoin() throws Exception {
-    Join join = JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp join dept on emp.deptId = dept.deptId")
-        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales",
-            "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering",
-            "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering",
-            "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical",
-            "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical").planContains(Join.class);
-    Assert.assertEquals(JoinRelType.INNER, join.getJoinType());
-  }
-
-  @Test
-  public void testLeftJoin() throws Exception {
-    Join join = JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp left join dept on emp.deptId = dept.deptId")
-        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales",
-            "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering",
-            "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering",
-            "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical",
-            "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical",
-            "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null").planContains(Join.class);
-    Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
-  }
-
-  /**
-   * Right join is tricky because Drill's "join" operator only supports "left", so we have to flip inputs.
-   */
-  @Test @Ignore
-  public void testRightJoin() throws Exception {
-    Join join = JdbcAssert.withModel(MODEL, "HR").sql("select * from emp right join dept on emp.deptId = dept.deptId")
-        .returnsUnordered("xx").planContains(Join.class);
-    Assert.assertEquals(JoinRelType.LEFT, join.getJoinType());
-  }
-
-  @Test
-  public void testFullJoin() throws Exception {
-    Join join = JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp full join dept on emp.deptId = dept.deptId")
-        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; DEPTID0=31; NAME=Sales",
-            "DEPTID=33; LASTNAME=Jones; DEPTID0=33; NAME=Engineering",
-            "DEPTID=33; LASTNAME=Steinberg; DEPTID0=33; NAME=Engineering",
-            "DEPTID=34; LASTNAME=Robinson; DEPTID0=34; NAME=Clerical",
-            "DEPTID=34; LASTNAME=Smith; DEPTID0=34; NAME=Clerical",
-            "DEPTID=null; LASTNAME=John; DEPTID0=null; NAME=null",
-            "DEPTID=null; LASTNAME=null; DEPTID0=35; NAME=Marketing").planContains(Join.class);
-    Assert.assertEquals(JoinRelType.FULL, join.getJoinType());
-  }
-
-  /**
-   * Join on subquery; also tests that if a field of the same name exists in both inputs, both fields make it through
-   * the join.
-   */
-  @Test
-  public void testJoinOnSubquery() throws Exception {
-    Join join = JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql(
-            "select * from (\n" + "select deptId, lastname, 'x' as name from emp) as e\n"
-                + " join dept on e.deptId = dept.deptId")
-        .returnsUnordered("DEPTID=31; LASTNAME=Rafferty; NAME=x; DEPTID0=31; NAME0=Sales",
-            "DEPTID=33; LASTNAME=Jones; NAME=x; DEPTID0=33; NAME0=Engineering",
-            "DEPTID=33; LASTNAME=Steinberg; NAME=x; DEPTID0=33; NAME0=Engineering",
-            "DEPTID=34; LASTNAME=Robinson; NAME=x; DEPTID0=34; NAME0=Clerical",
-            "DEPTID=34; LASTNAME=Smith; NAME=x; DEPTID0=34; NAME0=Clerical").planContains(Join.class);
-    Assert.assertEquals(JoinRelType.INNER, join.getJoinType());
-  }
-
-  /** Tests that one of the FoodMart tables is present. */
-  @Test @Ignore
-  public void testFoodMart() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "FOODMART")
-        .sql("select * from product_class where cast(_map['product_class_id'] as integer) < 3")
-        .returnsUnordered(
-            "_MAP={product_category=Seafood, product_class_id=2, product_department=Seafood, product_family=Food, product_subcategory=Shellfish}",
-            "_MAP={product_category=Specialty, product_class_id=1, product_department=Produce, product_family=Food, product_subcategory=Nuts}");
-  }
-
-  @Test
-  public void testUnionAll() throws Exception {
-    Union union = JdbcAssert.withModel(MODEL, "HR").sql("select deptId from dept\n" + "union all\n" + "select deptId from emp")
-        .returnsUnordered("DEPTID=31", "DEPTID=33", "DEPTID=34", "DEPTID=35", "DEPTID=null")
-        .planContains(Union.class);
-    Assert.assertFalse(union.isDistinct());
-  }
-
-  @Test
-  public void testUnion() throws Exception {
-    Union union = JdbcAssert.withModel(MODEL, "HR").sql("select deptId from dept\n" + "union\n" + "select deptId from emp")
-        .returnsUnordered("DEPTID=31", "DEPTID=33", "DEPTID=34", "DEPTID=35", "DEPTID=null")
-        .planContains(Union.class);
-    Assert.assertTrue(union.isDistinct());
-  }
-
-  @Test
-  public void testOrderByDescNullsFirst() throws Exception {
-    // desc nulls last
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp order by deptId desc nulls first")
-        .returns(
-            "DEPTID=null; LASTNAME=John\n" + "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n"
-                + "DEPTID=33; LASTNAME=Jones\n" + "DEPTID=33; LASTNAME=Steinberg\n" + "DEPTID=31; LASTNAME=Rafferty\n")
-        .planContains(Order.class);
-  }
-
-  @Test
-  public void testOrderByDescNullsLast() throws Exception {
-    // desc nulls first
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp order by deptId desc nulls last")
-        .returns(
-            "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n" + "DEPTID=33; LASTNAME=Jones\n"
-                + "DEPTID=33; LASTNAME=Steinberg\n" + "DEPTID=31; LASTNAME=Rafferty\n" + "DEPTID=null; LASTNAME=John\n")
-        .planContains(Order.class);
-  }
-
-  @Test @Ignore
-  public void testOrderByDesc() throws Exception {
-    // desc is implicitly "nulls first" (i.e. null sorted as +inf)
-    // Current behavior is to sort nulls last. This is wrong.
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp order by deptId desc")
-        .returns(
-            "DEPTID=null; LASTNAME=John\n" + "DEPTID=34; LASTNAME=Robinson\n" + "DEPTID=34; LASTNAME=Smith\n"
-                + "DEPTID=33; LASTNAME=Jones\n" + "DEPTID=33; LASTNAME=Steinberg\n" + "DEPTID=31; LASTNAME=Rafferty\n")
-        .planContains(Order.class);
-  }
-
-  @Test
-  public void testOrderBy() throws Exception {
-    // no sort order specified is implicitly "asc", and asc is "nulls last"
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select * from emp order by deptId")
-        .returns(
-            "DEPTID=31; LASTNAME=Rafferty\n"
-            + "DEPTID=33; LASTNAME=Jones\n"
-            + "DEPTID=33; LASTNAME=Steinberg\n"
-            + "DEPTID=34; LASTNAME=Robinson\n"
-            + "DEPTID=34; LASTNAME=Smith\n"
-            + "DEPTID=null; LASTNAME=John\n")
-        .planContains(Order.class);
-  }
-
-  @Test
-  public void testLimit() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select LASTNAME from emp limit 2")
-        .returns("LASTNAME=Rafferty\n" +
-            "LASTNAME=Jones")
-        .planContains(Limit.class);
-  }
-
-  
-  @Test
-  public void testLimitOrderBy() throws Exception {
-    TestDataConnection tdc = JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select LASTNAME from emp order by LASTNAME limit 2")
-        .returns("LASTNAME=John\n" +
-            "LASTNAME=Jones");
-        tdc.planContains(Limit.class);
-        tdc.planContains(Order.class);
-        
-  }
-  
-  @Test
-  public void testOrderByWithOffset() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select LASTNAME from emp order by LASTNAME asc offset 3")
-        .returns("LASTNAME=Robinson\n" +
-            "LASTNAME=Smith\n" +
-            "LASTNAME=Steinberg")
-        .planContains(Limit.class);
-
-  }
-
-  @Test
-  public void testOrderByWithOffsetAndFetch() throws Exception {
-    JdbcAssert
-        .withModel(MODEL, "HR")
-        .sql("select LASTNAME from emp order by LASTNAME asc offset 3 fetch next 2 rows only")
-        .returns("LASTNAME=Robinson\n" +
-            "LASTNAME=Smith")
-        .planContains(Limit.class);
-  }
-}
-
-// End JdbcTest.java