drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [12/12] incubator-drill git commit: DRILL-1517: Update Foreman to improve state management.
Date Thu, 20 Nov 2014 16:44:48 GMT
DRILL-1517: Update Foreman to improve state management.


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

Branch: refs/heads/master
Commit: fc58c693ae0cd9234e5e62a7602b4cc216b8549d
Parents: f2180b8
Author: Jacques Nadeau <jacques@apache.org>
Authored: Wed Nov 19 09:08:12 2014 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Thu Nov 20 08:40:25 2014 -0800

----------------------------------------------------------------------
 .../exceptions/ExecutionSetupException.java     |  11 +-
 .../PhysicalOperatorSetupException.java         |  45 --
 .../drill/exec/store/mongo/MongoGroupScan.java  |   2 +-
 .../exec/coord/zk/ZKClusterCoordinator.java     |  19 +-
 .../exec/exception/FragmentSetupException.java  |   4 +-
 .../exec/exception/OptimizerException.java      |   4 +-
 .../apache/drill/exec/ops/FragmentContext.java  |   2 +-
 .../apache/drill/exec/opt/BasicOptimizer.java   |   2 +
 .../PhysicalOperatorSetupException.java         |  48 ++
 .../exec/physical/base/AbstractExchange.java    |   2 +-
 .../drill/exec/physical/base/Exchange.java      |   2 +-
 .../drill/exec/physical/base/GroupScan.java     |   2 +-
 .../apache/drill/exec/physical/base/Store.java  |   2 +-
 .../exec/physical/config/BroadcastExchange.java |   2 +-
 .../drill/exec/physical/config/Screen.java      |   2 +-
 .../physical/config/SingleMergeExchange.java    |   2 +-
 .../exec/physical/config/UnionExchange.java     |   2 +-
 .../drill/exec/physical/impl/BatchCreator.java  |   1 +
 .../physical/impl/MergingReceiverCreator.java   |   3 +-
 .../drill/exec/planner/fragment/Fragment.java   |   6 +-
 .../planner/fragment/MakeFragmentsVisitor.java  |  14 +-
 .../exec/planner/fragment/Materializer.java     |   3 +-
 .../planner/fragment/SimpleParallelizer.java    |  12 +-
 .../drill/exec/planner/fragment/Wrapper.java    |   4 +-
 .../exec/planner/logical/DirPathBuilder.java    |   2 +-
 .../drill/exec/planner/logical/DrillOptiq.java  |   2 +-
 .../drill/exec/planner/sql/DrillSqlWorker.java  |  24 +-
 .../exec/planner/sql/QueryInputException.java   |  51 ++
 .../sql/handlers/AbstractSqlHandler.java        |   7 +-
 .../sql/handlers/CreateTableHandler.java        |   3 +-
 .../planner/sql/handlers/DefaultSqlHandler.java |  10 +-
 .../sql/handlers/DescribeTableHandler.java      |   3 +-
 .../planner/sql/handlers/ExplainHandler.java    |  10 +-
 .../planner/sql/handlers/SetOptionHandler.java  |   3 +-
 .../sql/handlers/ShowSchemasHandler.java        |   6 +-
 .../planner/sql/handlers/ShowTablesHandler.java |   6 +-
 .../planner/sql/handlers/UseSchemaHandler.java  |   3 +-
 .../exec/planner/sql/handlers/ViewHandler.java  |   5 +-
 .../drill/exec/rpc/control/WorkEventBus.java    |   5 +-
 .../apache/drill/exec/rpc/user/UserServer.java  |   9 -
 .../exec/store/direct/DirectGroupScan.java      |   2 +-
 .../exec/store/ischema/InfoSchemaGroupScan.java |   2 +-
 .../exec/store/parquet/ParquetGroupScan.java    |   2 +-
 .../drill/exec/store/sys/SystemTableScan.java   |   2 +-
 .../org/apache/drill/exec/work/ErrorHelper.java |   4 +-
 .../apache/drill/exec/work/foreman/Foreman.java | 620 +++++++++++++------
 .../exec/work/foreman/ForemanException.java     |  57 ++
 .../work/foreman/ForemanSetupException.java     |  45 ++
 .../drill/exec/work/foreman/QueryManager.java   | 302 ++-------
 .../drill/exec/work/foreman/QueryStatus.java    |  16 +-
 .../exec/work/foreman/RootStatusReporter.java   |  39 --
 .../exec/work/fragment/FragmentExecutor.java    |   9 +-
 .../work/fragment/NonRootFragmentManager.java   |   5 +-
 .../apache/drill/exec/work/user/UserWorker.java |  31 +-
 .../apache/drill/exec/pop/PopUnitTestBase.java  |   3 +-
 .../apache/drill/exec/pop/TestFragmenter.java   |   5 +-
 56 files changed, 814 insertions(+), 675 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java b/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java
index b9c16ad..ae70ffa 100644
--- a/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java
+++ b/common/src/main/java/org/apache/drill/common/exceptions/ExecutionSetupException.java
@@ -19,9 +19,7 @@ package org.apache.drill.common.exceptions;
 
 import java.lang.reflect.InvocationTargetException;
 
-public class ExecutionSetupException extends DrillException{
-  private static final long serialVersionUID = -6943409010231014085L;
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExecutionSetupException.class);
+public class ExecutionSetupException extends DrillException {
 
   public static ExecutionSetupException fromThrowable(String message, Throwable cause) {
     Throwable t = cause instanceof InvocationTargetException
@@ -31,25 +29,28 @@ public class ExecutionSetupException extends DrillException{
     }
     return new ExecutionSetupException(message, t);
   }
-
   public ExecutionSetupException() {
     super();
+
   }
 
   public ExecutionSetupException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
     super(message, cause, enableSuppression, writableStackTrace);
+
   }
 
   public ExecutionSetupException(String message, Throwable cause) {
     super(message, cause);
+
   }
 
   public ExecutionSetupException(String message) {
     super(message);
+
   }
 
   public ExecutionSetupException(Throwable cause) {
     super(cause);
-  }
 
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/common/src/main/java/org/apache/drill/common/exceptions/PhysicalOperatorSetupException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/exceptions/PhysicalOperatorSetupException.java b/common/src/main/java/org/apache/drill/common/exceptions/PhysicalOperatorSetupException.java
deleted file mode 100644
index cc6ba54..0000000
--- a/common/src/main/java/org/apache/drill/common/exceptions/PhysicalOperatorSetupException.java
+++ /dev/null
@@ -1,45 +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.common.exceptions;
-
-public class PhysicalOperatorSetupException extends ExecutionSetupException{
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PhysicalOperatorSetupException.class);
-
-  public PhysicalOperatorSetupException() {
-    super();
-  }
-
-  public PhysicalOperatorSetupException(String message, Throwable cause, boolean enableSuppression,
-      boolean writableStackTrace) {
-    super(message, cause, enableSuppression, writableStackTrace);
-  }
-
-  public PhysicalOperatorSetupException(String message, Throwable cause) {
-    super(message, cause);
-  }
-
-  public PhysicalOperatorSetupException(String message) {
-    super(message);
-  }
-
-  public PhysicalOperatorSetupException(Throwable cause) {
-    super(cause);
-  }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java
----------------------------------------------------------------------
diff --git a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java
index ccce3d5..f6b449b 100644
--- a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java
+++ b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java
@@ -35,9 +35,9 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.drill.common.exceptions.DrillRuntimeException;
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractGroupScan;
 import org.apache.drill.exec.physical.base.GroupScan;
 import org.apache.drill.exec.physical.base.PhysicalOperator;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java
index dab6318..b831852 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java
@@ -207,7 +207,7 @@ public class ZKClusterCoordinator extends ClusterCoordinator {
   }
 
 
-  private void updateEndpoints() {
+  private synchronized void updateEndpoints() {
     try {
       Collection<DrillbitEndpoint> newDrillbitSet =
       transform(discovery.queryForInstances(serviceName),
@@ -226,12 +226,21 @@ public class ZKClusterCoordinator extends ClusterCoordinator {
 
       if (logger.isDebugEnabled()) {
         StringBuilder builder = new StringBuilder();
-        builder.append("# of active drillbits : " + newDrillbitSet.size() + "");
-        builder.append("Active drillbits : ");
+        builder.append("Active drillbit set changed.  Now includes ");
+        builder.append(newDrillbitSet.size());
+        builder.append(" total bits.  New active drillbits: \n");
         for (DrillbitEndpoint bit: newDrillbitSet) {
-          builder.append(bit.toString() + "\t");
+          builder.append('\t');
+          builder.append(bit.getAddress());
+          builder.append(':');
+          builder.append(bit.getUserPort());
+          builder.append(':');
+          builder.append(bit.getControlPort());
+          builder.append(':');
+          builder.append(bit.getDataPort());
+          builder.append('\n');
         }
-        logger.debug("Active drillbits set changed: {}", builder.toString());
+        logger.debug(builder.toString());
       }
 
       // Notify the drillbit listener for newly unregistered bits. For now, we only care when drillbits are down / unregistered.

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/exception/FragmentSetupException.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/exception/FragmentSetupException.java b/exec/java-exec/src/main/java/org/apache/drill/exec/exception/FragmentSetupException.java
index 67e6e40..c276846 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/exception/FragmentSetupException.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/exception/FragmentSetupException.java
@@ -17,9 +17,9 @@
  */
 package org.apache.drill.exec.exception;
 
-import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.exec.work.foreman.ForemanException;
 
-public class FragmentSetupException extends ExecutionSetupException{
+public class FragmentSetupException extends ForemanException{
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(FragmentSetupException.class);
 
   public FragmentSetupException() {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/exception/OptimizerException.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/exception/OptimizerException.java b/exec/java-exec/src/main/java/org/apache/drill/exec/exception/OptimizerException.java
index fe3973d..0e7d21a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/exception/OptimizerException.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/exception/OptimizerException.java
@@ -17,9 +17,9 @@
  */
 package org.apache.drill.exec.exception;
 
-import org.apache.drill.common.exceptions.DrillException;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 
-public class OptimizerException extends DrillException {
+public class OptimizerException extends ForemanSetupException {
   public OptimizerException(String message, Throwable cause) {
     super(message, cause);
   }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
index e7beb40..0b99fc4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java
@@ -171,7 +171,7 @@ public class FragmentContext implements Closeable {
     return this.rootFragmentTimeZone;
   }
 
-  public DrillbitEndpoint getForemanDrillbitEndPoint() {return fragment.getForeman();}
+  public DrillbitEndpoint getForemanEndpoint() {return fragment.getForeman();}
 
   /**
    * The FragmentHandle for this Fragment

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/opt/BasicOptimizer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/opt/BasicOptimizer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/opt/BasicOptimizer.java
index 98202ac..5288f5d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/opt/BasicOptimizer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/opt/BasicOptimizer.java
@@ -18,6 +18,7 @@
 package org.apache.drill.exec.opt;
 
 import com.google.common.collect.Lists;
+
 import org.apache.drill.common.JSONOptions;
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.exceptions.ExecutionSetupException;
@@ -54,6 +55,7 @@ import org.apache.drill.exec.physical.config.WindowPOP;
 import org.apache.drill.exec.rpc.user.UserServer;
 import org.apache.drill.exec.server.options.OptionManager;
 import org.apache.drill.exec.store.StoragePlugin;
+import org.apache.drill.exec.work.foreman.ForemanException;
 import org.eigenbase.rel.RelFieldCollation.Direction;
 import org.eigenbase.rel.RelFieldCollation.NullDirection;
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/PhysicalOperatorSetupException.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/PhysicalOperatorSetupException.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/PhysicalOperatorSetupException.java
new file mode 100644
index 0000000..e8b0799
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/PhysicalOperatorSetupException.java
@@ -0,0 +1,48 @@
+/**
+ * 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.exec.physical;
+
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+
+
+public class PhysicalOperatorSetupException extends ExecutionSetupException {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PhysicalOperatorSetupException.class);
+
+  public PhysicalOperatorSetupException() {
+    super();
+  }
+
+  public PhysicalOperatorSetupException(String message, Throwable cause, boolean enableSuppression,
+      boolean writableStackTrace) {
+    super(message, cause, enableSuppression, writableStackTrace);
+  }
+
+  public PhysicalOperatorSetupException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public PhysicalOperatorSetupException(String message) {
+    super(message);
+  }
+
+  public PhysicalOperatorSetupException(Throwable cause) {
+    super(cause);
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/AbstractExchange.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/AbstractExchange.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/AbstractExchange.java
index 8009ede..af5b0c2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/AbstractExchange.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/AbstractExchange.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.physical.base;
 
 import java.util.List;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 
 public abstract class AbstractExchange extends AbstractSingle implements Exchange {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Exchange.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Exchange.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Exchange.java
index afbdac9..f2fa4dc 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Exchange.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Exchange.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.physical.base;
 
 import java.util.List;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/GroupScan.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/GroupScan.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/GroupScan.java
index 3e5e408..935d817 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/GroupScan.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/GroupScan.java
@@ -20,8 +20,8 @@ package org.apache.drill.exec.physical.base;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Store.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Store.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Store.java
index acf53f2..94411ea 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Store.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/base/Store.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.physical.base;
 
 import java.util.List;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/BroadcastExchange.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/BroadcastExchange.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/BroadcastExchange.java
index 2eed4c4..73a1d20 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/BroadcastExchange.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/BroadcastExchange.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.physical.config;
 
 import java.util.List;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractExchange;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.base.Receiver;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/Screen.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/Screen.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/Screen.java
index 980b413..58c8e29 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/Screen.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/Screen.java
@@ -20,8 +20,8 @@ package org.apache.drill.exec.physical.config;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractStore;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.base.PhysicalVisitor;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/SingleMergeExchange.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/SingleMergeExchange.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/SingleMergeExchange.java
index f6e11c4..6470734 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/SingleMergeExchange.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/SingleMergeExchange.java
@@ -20,8 +20,8 @@ package org.apache.drill.exec.physical.config;
 
 import java.util.List;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.logical.data.Order.Ordering;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractExchange;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.base.Receiver;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/UnionExchange.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/UnionExchange.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/UnionExchange.java
index bf2b4a1..d58048c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/UnionExchange.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/UnionExchange.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.physical.config;
 
 import java.util.List;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractExchange;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.base.Receiver;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BatchCreator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BatchCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BatchCreator.java
index 8dc0a6b..1cf7da7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BatchCreator.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/BatchCreator.java
@@ -20,6 +20,7 @@ package org.apache.drill.exec.physical.impl;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.exec.memory.OutOfMemoryException;
 import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.record.RecordBatch;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/MergingReceiverCreator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/MergingReceiverCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/MergingReceiverCreator.java
index 528611e..daef44c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/MergingReceiverCreator.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/MergingReceiverCreator.java
@@ -20,6 +20,7 @@ package org.apache.drill.exec.physical.impl;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.exec.memory.OutOfMemoryException;
 import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.physical.config.MergingReceiverPOP;
 import org.apache.drill.exec.physical.impl.mergereceiver.MergingRecordBatch;
@@ -34,7 +35,7 @@ public class MergingReceiverCreator implements BatchCreator<MergingReceiverPOP>
   public RecordBatch getBatch(FragmentContext context,
                               MergingReceiverPOP receiver,
                               List<RecordBatch> children)
-      throws ExecutionSetupException {
+      throws ExecutionSetupException, OutOfMemoryException {
 
     assert children == null || children.isEmpty();
     IncomingBuffers bufHolder = context.getBuffers();

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java
index e527960..ac63bde 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java
@@ -20,9 +20,9 @@ package org.apache.drill.exec.planner.fragment;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.drill.exec.exception.FragmentSetupException;
 import org.apache.drill.exec.physical.base.Exchange;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 
 import com.google.common.collect.Lists;
 
@@ -40,9 +40,9 @@ public class Fragment implements Iterable<Fragment.ExchangeFragmentPair> {
     }
   }
 
-  public void addSendExchange(Exchange e) throws FragmentSetupException{
+  public void addSendExchange(Exchange e) throws ForemanSetupException{
     if (sendingExchange != null) {
-      throw new FragmentSetupException("Fragment was trying to add a second SendExchange.  ");
+      throw new ForemanSetupException("Fragment was trying to add a second SendExchange.  ");
     }
     addOperator(e);
     sendingExchange = e;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java
index 594356a..8756e5b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java
@@ -17,16 +17,16 @@
  */
 package org.apache.drill.exec.planner.fragment;
 
-import org.apache.drill.exec.exception.FragmentSetupException;
 import org.apache.drill.exec.physical.base.AbstractPhysicalVisitor;
 import org.apache.drill.exec.physical.base.Exchange;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.base.SubScan;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 
 /**
  * Responsible for breaking a plan into its constituent Fragments.
  */
-public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Fragment, FragmentSetupException> {
+public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Fragment, ForemanSetupException> {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MakeFragmentsVisitor.class);
 
 
@@ -34,10 +34,10 @@ public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Frag
   }
 
   @Override
-  public Fragment visitExchange(Exchange exchange, Fragment value) throws FragmentSetupException {
+  public Fragment visitExchange(Exchange exchange, Fragment value) throws ForemanSetupException {
 //    logger.debug("Visiting Exchange {}", exchange);
     if (value == null) {
-      throw new FragmentSetupException("The simple fragmenter was called without a FragmentBuilder value.  This will only happen if the initial call to SimpleFragmenter is by a Exchange node.  This should never happen since an Exchange node should never be the root node of a plan.");
+      throw new ForemanSetupException("The simple fragmenter was called without a FragmentBuilder value.  This will only happen if the initial call to SimpleFragmenter is by a Exchange node.  This should never happen since an Exchange node should never be the root node of a plan.");
     }
     Fragment next = getNextBuilder();
     value.addReceiveExchange(exchange, next);
@@ -47,13 +47,13 @@ public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Frag
   }
 
   @Override
-  public Fragment visitSubScan(SubScan subScan, Fragment value) throws FragmentSetupException {
+  public Fragment visitSubScan(SubScan subScan, Fragment value) throws ForemanSetupException {
     // TODO - implement this
     return super.visitOp(subScan, value);
   }
 
   @Override
-  public Fragment visitOp(PhysicalOperator op, Fragment value)  throws FragmentSetupException{
+  public Fragment visitOp(PhysicalOperator op, Fragment value)  throws ForemanSetupException{
 //    logger.debug("Visiting Other {}", op);
     value = ensureBuilder(value);
     value.addOperator(op);
@@ -63,7 +63,7 @@ public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Frag
     return value;
   }
 
-  private Fragment ensureBuilder(Fragment value) throws FragmentSetupException{
+  private Fragment ensureBuilder(Fragment value) throws ForemanSetupException{
     if (value != null) {
       return value;
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Materializer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Materializer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Materializer.java
index add29c1..961b603 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Materializer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Materializer.java
@@ -20,14 +20,15 @@ package org.apache.drill.exec.planner.fragment;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.exec.exception.FragmentSetupException;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractPhysicalVisitor;
 import org.apache.drill.exec.physical.base.Exchange;
 import org.apache.drill.exec.physical.base.GroupScan;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.physical.base.Store;
 import org.apache.drill.exec.physical.base.SubScan;
+import org.apache.drill.exec.work.foreman.ForemanException;
 
 import com.google.common.collect.Lists;
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
index cd37c17..434cdd4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
@@ -21,12 +21,11 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.util.DrillStringUtils;
 import org.apache.drill.exec.ExecConstants;
-import org.apache.drill.exec.exception.FragmentSetupException;
 import org.apache.drill.exec.expr.fn.impl.DateUtility;
 import org.apache.drill.exec.ops.QueryContext;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.FragmentRoot;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
 import org.apache.drill.exec.planner.PhysicalPlanReader;
@@ -34,11 +33,12 @@ import org.apache.drill.exec.planner.fragment.Materializer.IndexedFragmentNode;
 import org.apache.drill.exec.proto.BitControl.PlanFragment;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
-import org.apache.drill.exec.proto.UserBitShared;
 import org.apache.drill.exec.proto.UserBitShared.QueryId;
 import org.apache.drill.exec.rpc.user.UserSession;
 import org.apache.drill.exec.server.options.OptionList;
 import org.apache.drill.exec.work.QueryWorkUnit;
+import org.apache.drill.exec.work.foreman.ForemanException;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.google.common.base.Preconditions;
@@ -88,7 +88,7 @@ public class SimpleParallelizer {
    * @param rootNode        The root node of the PhysicalPlan that we will parallelizing.
    * @param planningSet     The set of queries with collected statistics that we'll work with.
    * @return The list of generated PlanFragment protobuf objects to be assigned out to the individual nodes.
-   * @throws ExecutionSetupException
+   * @throws ForemanException
    */
   public QueryWorkUnit getFragments(OptionList options, DrillbitEndpoint foremanNode, QueryId queryId, Collection<DrillbitEndpoint> activeEndpoints,
       PhysicalPlanReader reader, Fragment rootNode, PlanningSet planningSet, UserSession session) throws ExecutionSetupException {
@@ -116,7 +116,7 @@ public class SimpleParallelizer {
       boolean isRootNode = rootNode == node;
 
       if (isRootNode && wrapper.getWidth() != 1) {
-        throw new FragmentSetupException(
+        throw new ForemanSetupException(
             String.format(
                 "Failure while trying to setup fragment.  The root fragment must always have parallelization one.  In the current case, the width was set to %d.",
                 wrapper.getWidth()));
@@ -139,7 +139,7 @@ public class SimpleParallelizer {
           plan = reader.writeJson(root);
           optionsData = reader.writeJson(options);
         } catch (JsonProcessingException e) {
-          throw new FragmentSetupException("Failure while trying to convert fragment into json.", e);
+          throw new ForemanSetupException("Failure while trying to convert fragment into json.", e);
         }
 
         FragmentHandle handle = FragmentHandle //

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Wrapper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Wrapper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Wrapper.java
index 78b813d..86b395e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Wrapper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Wrapper.java
@@ -24,8 +24,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ThreadLocalRandom;
 
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractPhysicalVisitor;
 import org.apache.drill.exec.physical.base.Exchange;
 import org.apache.drill.exec.physical.base.GroupScan;
@@ -120,7 +120,7 @@ public class Wrapper {
 
   public void addAllocation(PhysicalOperator pop) {
     initialAllocation += pop.getInitialAllocation();
-    logger.debug("Incrementing initialAllocation by {} to {}. Pop: {}", pop.getInitialAllocation(), initialAllocation, pop);
+//    logger.debug("Incrementing initialAllocation by {} to {}. Pop: {}", pop.getInitialAllocation(), initialAllocation, pop);
     maxAllocation += pop.getMaxAllocation();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java
index da883e4..cb38da9 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DirPathBuilder.java
@@ -170,7 +170,7 @@ public class DirPathBuilder extends RexVisitorImpl <SchemaPath> {
 
   @Override
   public SchemaPath visitCall(RexCall call) {
-    logger.debug("RexCall {}, {}", call);
+//    logger.debug("RexCall {}, {}", call);
     final SqlSyntax syntax = call.getOperator().getSyntax();
     switch (syntax) {
     case BINARY:

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
index 0627dcd..796f0f7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
@@ -89,7 +89,7 @@ public class DrillOptiq {
 
     @Override
     public LogicalExpression visitCall(RexCall call) {
-      logger.debug("RexCall {}, {}", call);
+//      logger.debug("RexCall {}, {}", call);
       final SqlSyntax syntax = call.getOperator().getSyntax();
       switch (syntax) {
       case BINARY:

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
index 2de46ee..863a6dc 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
@@ -28,6 +28,7 @@ import net.hydromatic.optiq.tools.Planner;
 import net.hydromatic.optiq.tools.RelConversionException;
 import net.hydromatic.optiq.tools.RuleSet;
 import net.hydromatic.optiq.tools.ValidationException;
+
 import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.physical.PhysicalPlan;
 import org.apache.drill.exec.planner.cost.DrillCostBase;
@@ -42,6 +43,7 @@ import org.apache.drill.exec.planner.sql.parser.DrillSqlCall;
 import org.apache.drill.exec.planner.sql.parser.impl.DrillParserWithCompoundIdConverter;
 import org.apache.drill.exec.store.StoragePluginRegistry;
 import org.apache.drill.exec.util.Pointer;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.rel.RelCollationTraitDef;
 import org.eigenbase.rel.rules.ReduceExpressionsRule;
 import org.eigenbase.rel.rules.WindowedAggSplitterRule;
@@ -63,7 +65,7 @@ public class DrillSqlWorker {
   private final QueryContext context;
 
 
-  public DrillSqlWorker(QueryContext context) throws Exception {
+  public DrillSqlWorker(QueryContext context) {
     final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();
 
     traitDefs.add(ConventionTraitDef.INSTANCE);
@@ -101,12 +103,17 @@ public class DrillSqlWorker {
     return allRules;
   }
 
-  public PhysicalPlan getPlan(String sql) throws SqlParseException, ValidationException, RelConversionException, IOException{
+  public PhysicalPlan getPlan(String sql) throws SqlParseException, ValidationException, ForemanSetupException{
     return getPlan(sql, null);
   }
 
-  public PhysicalPlan getPlan(String sql, Pointer<String> textPlan) throws SqlParseException, ValidationException, RelConversionException, IOException{
-    SqlNode sqlNode = planner.parse(sql);
+  public PhysicalPlan getPlan(String sql, Pointer<String> textPlan) throws ForemanSetupException {
+    SqlNode sqlNode;
+    try {
+      sqlNode = planner.parse(sql);
+    } catch (SqlParseException e) {
+      throw new QueryInputException("Failure parsing SQL.", e);
+    }
 
     AbstractSqlHandler handler;
     SqlHandlerConfig config = new SqlHandlerConfig(hepPlanner, planner, context);
@@ -129,7 +136,14 @@ public class DrillSqlWorker {
       handler = new DefaultSqlHandler(config, textPlan);
     }
 
-    return handler.getPlan(sqlNode);
+    try{
+      return handler.getPlan(sqlNode);
+    }catch(ValidationException e){
+      throw new QueryInputException("Failure validating SQL.", e);
+    } catch (IOException | RelConversionException e) {
+      throw new QueryInputException("Failure handling SQL.", e);
+    }
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/QueryInputException.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/QueryInputException.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/QueryInputException.java
new file mode 100644
index 0000000..22727f0
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/QueryInputException.java
@@ -0,0 +1,51 @@
+/**
+ * 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.exec.planner.sql;
+
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
+
+public class QueryInputException extends ForemanSetupException {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(QueryInputException.class);
+
+  public QueryInputException() {
+    super();
+
+  }
+
+  public QueryInputException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+    super(message, cause, enableSuppression, writableStackTrace);
+
+  }
+
+  public QueryInputException(String message, Throwable cause) {
+    super(message, cause);
+
+  }
+
+  public QueryInputException(String message) {
+    super(message);
+
+  }
+
+  public QueryInputException(Throwable cause) {
+    super(cause);
+
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/AbstractSqlHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/AbstractSqlHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/AbstractSqlHandler.java
index 99f597c..56c2a42 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/AbstractSqlHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/AbstractSqlHandler.java
@@ -26,6 +26,7 @@ import net.hydromatic.optiq.tools.ValidationException;
 
 import org.apache.drill.exec.physical.PhysicalPlan;
 import org.apache.drill.exec.store.AbstractSchema;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.sql.SqlNode;
 
 import com.google.common.base.Joiner;
@@ -33,13 +34,13 @@ import com.google.common.base.Joiner;
 public abstract class AbstractSqlHandler {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractSqlHandler.class);
 
-  public abstract PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException;
+  public abstract PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException;
 
-  public static <T> T unwrap(Object o, Class<T> clazz) throws RelConversionException {
+  public static <T> T unwrap(Object o, Class<T> clazz) throws ForemanSetupException {
     if (clazz.isAssignableFrom(o.getClass())) {
       return (T) o;
     } else {
-      throw new RelConversionException(String.format("Failure trying to treat %s as type %s.", o.getClass().getSimpleName(), clazz.getSimpleName()));
+      throw new ForemanSetupException(String.format("Failure trying to treat %s as type %s.", o.getClass().getSimpleName(), clazz.getSimpleName()));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
index df2f807..111222e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
@@ -38,6 +38,7 @@ import org.apache.drill.exec.planner.sql.DrillSqlWorker;
 import org.apache.drill.exec.planner.sql.parser.SqlCreateTable;
 import org.apache.drill.exec.planner.types.DrillFixedRelDataTypeImpl;
 import org.apache.drill.exec.store.AbstractSchema;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.rel.RelNode;
 import org.eigenbase.relopt.RelOptUtil;
 import org.eigenbase.relopt.hep.HepPlanner;
@@ -51,7 +52,7 @@ public class CreateTableHandler extends DefaultSqlHandler {
   }
 
   @Override
-  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
+  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
     SqlCreateTable sqlCreateTable = unwrap(sqlNode, SqlCreateTable.class);
 
     try {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
index 58c80a6..bacee08 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
@@ -39,7 +39,6 @@ import org.apache.drill.exec.planner.logical.DrillRel;
 import org.apache.drill.exec.planner.logical.DrillScreenRel;
 import org.apache.drill.exec.planner.logical.DrillStoreRel;
 import org.apache.drill.exec.planner.logical.RewriteProjectRel;
-import org.apache.drill.exec.planner.physical.visitor.RewriteProjectToFlatten;
 import org.apache.drill.exec.planner.physical.DrillDistributionTrait;
 import org.apache.drill.exec.planner.physical.PhysicalPlanCreator;
 import org.apache.drill.exec.planner.physical.PlannerSettings;
@@ -50,8 +49,8 @@ import org.apache.drill.exec.planner.physical.visitor.ExcessiveExchangeIdentifie
 import org.apache.drill.exec.planner.physical.visitor.FinalColumnReorderer;
 import org.apache.drill.exec.planner.physical.visitor.JoinPrelRenameVisitor;
 import org.apache.drill.exec.planner.physical.visitor.MemoryEstimationVisitor;
-import org.apache.drill.exec.planner.physical.visitor.ProducerConsumerPrelVisitor;
 import org.apache.drill.exec.planner.physical.visitor.RelUniqifier;
+import org.apache.drill.exec.planner.physical.visitor.RewriteProjectToFlatten;
 import org.apache.drill.exec.planner.physical.visitor.SelectionVectorPrelVisitor;
 import org.apache.drill.exec.planner.physical.visitor.SplitUpComplexExpressions;
 import org.apache.drill.exec.planner.physical.visitor.StarColumnConverter;
@@ -59,6 +58,7 @@ import org.apache.drill.exec.planner.sql.DrillSqlWorker;
 import org.apache.drill.exec.server.options.OptionManager;
 import org.apache.drill.exec.server.options.OptionValue;
 import org.apache.drill.exec.util.Pointer;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.rel.RelNode;
 import org.eigenbase.relopt.RelOptUtil;
 import org.eigenbase.relopt.RelTraitSet;
@@ -119,7 +119,7 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
   }
 
   @Override
-  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
+  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
 
     SqlNode rewrittenSqlNode = rewrite(sqlNode);
     SqlNode validated = validateNode(rewrittenSqlNode);
@@ -141,7 +141,7 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
     return plan;
   }
 
-  protected SqlNode validateNode(SqlNode sqlNode) throws ValidationException, RelConversionException {
+  protected SqlNode validateNode(SqlNode sqlNode) throws ValidationException, RelConversionException, ForemanSetupException {
     return planner.validate(sqlNode);
   }
 
@@ -301,7 +301,7 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
    * @return Rewritten sql parse tree
    * @throws RelConversionException
    */
-  public SqlNode rewrite(SqlNode node) throws RelConversionException {
+  public SqlNode rewrite(SqlNode node) throws RelConversionException, ForemanSetupException {
     return node;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DescribeTableHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DescribeTableHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DescribeTableHandler.java
index 84082e3..e61e0fe 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DescribeTableHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DescribeTableHandler.java
@@ -30,6 +30,7 @@ import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.planner.sql.parser.DrillParserUtil;
 import org.apache.drill.exec.planner.sql.parser.SqlDescribeTable;
 import org.apache.drill.exec.store.AbstractSchema;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.relopt.hep.HepPlanner;
 import org.eigenbase.sql.SqlIdentifier;
 import org.eigenbase.sql.SqlLiteral;
@@ -48,7 +49,7 @@ public class DescribeTableHandler extends DefaultSqlHandler {
 
   /** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.COLUMNS ... */
   @Override
-  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException {
+  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
     SqlDescribeTable node = unwrap(sqlNode, SqlDescribeTable.class);
 
     try {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
index 8beed34..8d57aee 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ExplainHandler.java
@@ -17,8 +17,11 @@
  */
 package org.apache.drill.exec.planner.sql.handlers;
 
+import java.io.IOException;
+
 import net.hydromatic.optiq.tools.RelConversionException;
 import net.hydromatic.optiq.tools.ValidationException;
+
 import org.apache.drill.common.logical.LogicalPlan;
 import org.apache.drill.common.logical.PlanProperties.Generator.ResultMode;
 import org.apache.drill.exec.ops.QueryContext;
@@ -30,6 +33,7 @@ import org.apache.drill.exec.planner.logical.DrillRel;
 import org.apache.drill.exec.planner.physical.Prel;
 import org.apache.drill.exec.planner.physical.explain.PrelSequencer;
 import org.apache.drill.exec.planner.sql.DirectPlan;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.rel.RelNode;
 import org.eigenbase.relopt.RelOptUtil;
 import org.eigenbase.sql.SqlExplain;
@@ -37,8 +41,6 @@ import org.eigenbase.sql.SqlExplainLevel;
 import org.eigenbase.sql.SqlLiteral;
 import org.eigenbase.sql.SqlNode;
 
-import java.io.IOException;
-
 public class ExplainHandler extends DefaultSqlHandler {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExplainHandler.class);
 
@@ -49,7 +51,7 @@ public class ExplainHandler extends DefaultSqlHandler {
   }
 
   @Override
-  public PhysicalPlan getPlan(SqlNode node) throws ValidationException, RelConversionException, IOException {
+  public PhysicalPlan getPlan(SqlNode node) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
     SqlNode sqlNode = rewrite(node);
     SqlNode validated = validateNode(sqlNode);
     RelNode rel = convertToRel(validated);
@@ -72,7 +74,7 @@ public class ExplainHandler extends DefaultSqlHandler {
   }
 
   @Override
-  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException{
+  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
     SqlExplain node = unwrap(sqlNode, SqlExplain.class);
     SqlLiteral op = node.operand(2);
     SqlExplain.Depth depth = (SqlExplain.Depth) op.getValue();

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
index da85a31..b5d3f4a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
@@ -26,6 +26,7 @@ import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.physical.PhysicalPlan;
 import org.apache.drill.exec.planner.sql.DirectPlan;
 import org.apache.drill.exec.server.options.OptionValue;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.sql.SqlLiteral;
 import org.eigenbase.sql.SqlNode;
 import org.eigenbase.sql.SqlSetOption;
@@ -43,7 +44,7 @@ public class SetOptionHandler extends AbstractSqlHandler{
 
 
   @Override
-  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
+  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
     SqlSetOption option = unwrap(sqlNode, SqlSetOption.class);
     String scope = option.getScope();
     String name = option.getName();

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowSchemasHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowSchemasHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowSchemasHandler.java
index b055218..21d563c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowSchemasHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowSchemasHandler.java
@@ -20,13 +20,11 @@ package org.apache.drill.exec.planner.sql.handlers;
 
 import java.util.List;
 
-import net.hydromatic.optiq.tools.Planner;
 import net.hydromatic.optiq.tools.RelConversionException;
 
-import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.planner.sql.parser.DrillParserUtil;
 import org.apache.drill.exec.planner.sql.parser.SqlShowSchemas;
-import org.eigenbase.relopt.hep.HepPlanner;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.sql.SqlIdentifier;
 import org.eigenbase.sql.SqlNode;
 import org.eigenbase.sql.SqlNodeList;
@@ -42,7 +40,7 @@ public class ShowSchemasHandler extends DefaultSqlHandler {
 
   /** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */
   @Override
-  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException{
+  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
     SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class);
     List<SqlNode> selectList = ImmutableList.of((SqlNode) new SqlIdentifier("SCHEMA_NAME", SqlParserPos.ZERO));
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowTablesHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowTablesHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowTablesHandler.java
index 0a029f7..ba901a8 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowTablesHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ShowTablesHandler.java
@@ -23,19 +23,17 @@ import static org.apache.drill.exec.planner.sql.parser.DrillParserUtil.CHARSET;
 import java.util.List;
 
 import net.hydromatic.optiq.SchemaPlus;
-import net.hydromatic.optiq.tools.Planner;
 import net.hydromatic.optiq.tools.RelConversionException;
 
-import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.planner.sql.parser.DrillParserUtil;
 import org.apache.drill.exec.planner.sql.parser.SqlShowTables;
 import org.apache.drill.exec.store.AbstractSchema;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.sql.SqlIdentifier;
 import org.eigenbase.sql.SqlLiteral;
 import org.eigenbase.sql.SqlNode;
 import org.eigenbase.sql.SqlNodeList;
 import org.eigenbase.sql.SqlSelect;
-import org.eigenbase.relopt.hep.HepPlanner;
 import org.eigenbase.sql.fun.SqlStdOperatorTable;
 import org.eigenbase.sql.parser.SqlParserPos;
 
@@ -48,7 +46,7 @@ public class ShowTablesHandler extends DefaultSqlHandler {
 
   /** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.`TABLES` ... */
   @Override
-  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException{
+  public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
     SqlShowTables node = unwrap(sqlNode, SqlShowTables.class);
     List<SqlNode> selectList = Lists.newArrayList();
     SqlNode fromClause;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/UseSchemaHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/UseSchemaHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/UseSchemaHandler.java
index 06ed28b..f99aea3 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/UseSchemaHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/UseSchemaHandler.java
@@ -26,6 +26,7 @@ import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.physical.PhysicalPlan;
 import org.apache.drill.exec.planner.sql.DirectPlan;
 import org.apache.drill.exec.planner.sql.parser.SqlUseSchema;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.sql.SqlNode;
 
 public class UseSchemaHandler extends AbstractSqlHandler {
@@ -36,7 +37,7 @@ public class UseSchemaHandler extends AbstractSqlHandler {
   }
 
   @Override
-  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
+  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
     SqlUseSchema useSchema = unwrap(sqlNode, SqlUseSchema.class);
 
     String defaultSchema = useSchema.getSchema();

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
index 8eca21e..4347249 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/ViewHandler.java
@@ -34,6 +34,7 @@ import org.apache.drill.exec.planner.sql.parser.SqlDropView;
 import org.apache.drill.exec.planner.types.DrillFixedRelDataTypeImpl;
 import org.apache.drill.exec.store.AbstractSchema;
 import org.apache.drill.exec.store.dfs.WorkspaceSchemaFactory.WorkspaceSchema;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.eigenbase.rel.RelNode;
 import org.eigenbase.reltype.RelDataType;
 import org.eigenbase.sql.SqlNode;
@@ -59,7 +60,7 @@ public abstract class ViewHandler extends AbstractSqlHandler {
     }
 
     @Override
-    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
+    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
       SqlCreateView createView = unwrap(sqlNode, SqlCreateView.class);
 
       try {
@@ -137,7 +138,7 @@ public abstract class ViewHandler extends AbstractSqlHandler {
     }
 
     @Override
-    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {
+    public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
       SqlDropView dropView = unwrap(sqlNode, SqlDropView.class);
 
       try {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/WorkEventBus.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/WorkEventBus.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/WorkEventBus.java
index eae7b5e..b9f0a26 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/WorkEventBus.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/WorkEventBus.java
@@ -29,6 +29,7 @@ import org.apache.drill.exec.proto.helper.QueryIdHelper;
 import org.apache.drill.exec.rpc.RpcException;
 import org.apache.drill.exec.work.WorkManager.WorkerBee;
 import org.apache.drill.exec.work.foreman.FragmentStatusListener;
+import org.apache.drill.exec.work.foreman.ForemanSetupException;
 import org.apache.drill.exec.work.fragment.FragmentManager;
 
 import com.google.common.cache.Cache;
@@ -57,11 +58,11 @@ public class WorkEventBus {
     listeners.remove(queryId);
   }
 
-  public void setFragmentStatusListener(QueryId queryId, FragmentStatusListener listener) throws RpcException {
+  public void setFragmentStatusListener(QueryId queryId, FragmentStatusListener listener) throws ForemanSetupException {
     logger.debug("Adding fragment status listener for queryId {}.", queryId);
     FragmentStatusListener old = listeners.putIfAbsent(queryId, listener);
     if (old != null) {
-      throw new RpcException(
+      throw new ForemanSetupException (
           "Failure.  The provided handle already exists in the listener pool.  You need to remove one listener before adding another.");
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
index e386ad3..dffb9a1 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
@@ -82,15 +82,6 @@ public class UserServer extends BasicServer<RpcType, UserServer.UserClientConnec
         throw new RpcException("Failure while decoding RunQuery body.", e);
       }
 
-    case RpcType.REQUEST_RESULTS_VALUE:
-      logger.debug("Received results requests.  Returning empty query result.");
-      try {
-        RequestResults req = RequestResults.PARSER.parseFrom(new ByteBufInputStream(pBody));
-        return new Response(RpcType.QUERY_RESULT, worker.getResult(connection, req));
-      } catch (InvalidProtocolBufferException e) {
-        throw new RpcException("Failure while decoding RequestResults body.", e);
-      }
-
     case RpcType.CANCEL_QUERY_VALUE:
       try {
         QueryId queryId = QueryId.PARSER.parseFrom(new ByteBufInputStream(pBody));

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/store/direct/DirectGroupScan.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/direct/DirectGroupScan.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/direct/DirectGroupScan.java
index cc8386d..aa1609d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/direct/DirectGroupScan.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/direct/DirectGroupScan.java
@@ -21,9 +21,9 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractGroupScan;
 import org.apache.drill.exec.physical.base.GroupScan;
 import org.apache.drill.exec.physical.base.PhysicalOperator;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaGroupScan.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaGroupScan.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaGroupScan.java
index 5a9a74c..5a18033 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaGroupScan.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaGroupScan.java
@@ -21,9 +21,9 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractGroupScan;
 import org.apache.drill.exec.physical.base.GroupScan;
 import org.apache.drill.exec.physical.base.PhysicalOperator;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java
index 07532d1..8ddf5fd 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java
@@ -25,12 +25,12 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.logical.FormatPluginConfig;
 import org.apache.drill.common.logical.StoragePluginConfig;
 import org.apache.drill.exec.metrics.DrillMetrics;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractFileGroupScan;
 import org.apache.drill.exec.physical.base.FileGroupScan;
 import org.apache.drill.exec.physical.base.GroupScan;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTableScan.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTableScan.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTableScan.java
index 76da554..053f5de 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTableScan.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/SystemTableScan.java
@@ -22,9 +22,9 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.exceptions.PhysicalOperatorSetupException;
 import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
 import org.apache.drill.exec.physical.base.AbstractGroupScan;
 import org.apache.drill.exec.physical.base.GroupScan;
 import org.apache.drill.exec.physical.base.PhysicalOperator;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fc58c693/exec/java-exec/src/main/java/org/apache/drill/exec/work/ErrorHelper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/ErrorHelper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/ErrorHelper.java
index 025a8de..0773d6c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/ErrorHelper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/ErrorHelper.java
@@ -61,7 +61,9 @@ public class ErrorHelper {
     DrillPBError.Builder builder = DrillPBError.newBuilder();
     builder.setEndpoint(endpoint);
     builder.setErrorId(id);
-    builder.setMessage(message);
+    if(message != null){
+      builder.setMessage(message);
+    }
     if(t == null){
       t = new DrillException("Undefined failure occurred.");
     }


Mime
View raw message