drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansi...@apache.org
Subject drill git commit: DRILL-1937: Disable the query pattern where logical expressions are applied on non-scalar result of sub-query
Date Sat, 14 Feb 2015 00:38:18 GMT
Repository: drill
Updated Branches:
  refs/heads/master 4ed0a8d68 -> fe265059a


DRILL-1937: Disable the query pattern where logical expressions are applied on non-scalar
result of sub-query


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

Branch: refs/heads/master
Commit: fe265059a412d3f034dd19d8da9ed195a18ab0c2
Parents: 4ed0a8d
Author: Hsuan-Yi Chu <hsuanyi@usc.edu>
Authored: Sat Feb 7 21:25:50 2015 -0800
Committer: Aman Sinha <asinha@maprtech.com>
Committed: Fri Feb 13 16:34:56 2015 -0800

----------------------------------------------------------------------
 .../exception/UnsupportedOperatorCollector.java |  61 ++++----
 .../planner/logical/PreProcessLogicalRel.java   | 143 +++++++++++++++++++
 .../exec/planner/logical/RewriteProjectRel.java | 106 --------------
 .../planner/sql/handlers/DefaultSqlHandler.java |  35 ++++-
 .../planner/sql/handlers/ExplainHandler.java    |   2 +
 .../sql/parser/UnsupportedOperatorsVisitor.java |   1 -
 .../work/foreman/SqlUnsupportedException.java   |  30 +++-
 .../apache/drill/TestDisabledFunctionality.java | 139 ++++++++++++++----
 8 files changed, 349 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/exec/java-exec/src/main/java/org/apache/drill/exec/exception/UnsupportedOperatorCollector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/exception/UnsupportedOperatorCollector.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/exception/UnsupportedOperatorCollector.java
index aec792b..1a01d1d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/exception/UnsupportedOperatorCollector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/exception/UnsupportedOperatorCollector.java
@@ -23,40 +23,47 @@ import org.apache.drill.exec.work.foreman.UnsupportedFunctionException;
 import org.apache.drill.exec.work.foreman.UnsupportedRelOperatorException;
 
 public class UnsupportedOperatorCollector {
-    private SqlUnsupportedException.ExceptionType exceptionType;
-    private String jiraNumber;
-    private String message;
+  private SqlUnsupportedException.ExceptionType exceptionType;
+  private String jiraNumber;
+  private String message;
 
-    public UnsupportedOperatorCollector() {
-        exceptionType = SqlUnsupportedException.ExceptionType.NONE;
-    }
+  public UnsupportedOperatorCollector() {
+    exceptionType = SqlUnsupportedException.ExceptionType.NONE;
+  }
 
-    public boolean convertException() throws SqlUnsupportedException {
-      switch (exceptionType) {
-        case RELATIONAL:
-          throw new UnsupportedRelOperatorException(jiraNumber, message);
-        case DATA_TYPE:
-          throw new UnsupportedDataTypeException(jiraNumber, message);
-        case FUNCTION:
-          throw new UnsupportedFunctionException(jiraNumber, message);
-        default:
-          break;
-      }
-
-      return false;
+  public boolean convertException() throws SqlUnsupportedException {
+    switch (exceptionType) {
+      case RELATIONAL:
+        clean();
+        throw new UnsupportedRelOperatorException(jiraNumber, message);
+      case DATA_TYPE:
+        clean();
+        throw new UnsupportedDataTypeException(jiraNumber, message);
+      case FUNCTION:
+        clean();
+        throw new UnsupportedFunctionException(jiraNumber, message);
+      default:
+        break;
     }
 
-    public void setException(SqlUnsupportedException.ExceptionType exceptionType, String
jiraNumber, String message) {
-      if(this.exceptionType != SqlUnsupportedException.ExceptionType.NONE) {
-        throw new IllegalStateException("Exception was set already");
-      }
+    return false;
+  }
 
-      this.exceptionType = exceptionType;
-      this.jiraNumber = jiraNumber;
-      this.message = message;
+  public void setException(SqlUnsupportedException.ExceptionType exceptionType, String jiraNumber,
String message) {
+    if(this.exceptionType != SqlUnsupportedException.ExceptionType.NONE) {
+      throw new IllegalStateException("Exception was set already");
     }
 
-    public void clean() {
+    this.exceptionType = exceptionType;
+    this.jiraNumber = jiraNumber;
+    this.message = message;
+  }
+
+  public void setException(SqlUnsupportedException.ExceptionType exceptionType) {
+    setException(exceptionType, "", "");
+  }
+
+   public void clean() {
       exceptionType = SqlUnsupportedException.ExceptionType.NONE;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/PreProcessLogicalRel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/PreProcessLogicalRel.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/PreProcessLogicalRel.java
new file mode 100644
index 0000000..4c9d301
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/PreProcessLogicalRel.java
@@ -0,0 +1,143 @@
+/**
+ * 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.logical;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.drill.exec.exception.UnsupportedOperatorCollector;
+import org.apache.drill.exec.planner.sql.DrillOperatorTable;
+import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
+import org.eigenbase.rel.AggregateCall;
+import org.eigenbase.rel.AggregateRel;
+import org.eigenbase.rel.ProjectRel;
+import org.eigenbase.rel.RelNode;
+import org.eigenbase.rel.RelShuttleImpl;
+import org.eigenbase.reltype.RelDataTypeFactory;
+import org.eigenbase.rex.RexBuilder;
+import org.eigenbase.rex.RexCall;
+import org.eigenbase.rex.RexLiteral;
+import org.eigenbase.rex.RexNode;
+import org.eigenbase.sql.SqlFunction;
+import org.eigenbase.sql.SqlOperator;
+import org.eigenbase.sql.fun.SqlSingleValueAggFunction;
+import org.eigenbase.util.NlsString;
+
+/**
+ * This class rewrites all the project expression that contain convert_to/ convert_from
+ * to actual implementations.
+ * Eg: convert_from(EXPR, 'JSON') is rewritten as convert_fromjson(EXPR)
+ *
+ * With the actual method name we can find out if the function has a complex
+ * output type and we will fire/ ignore certain rules (merge project rule) based on this
fact.
+ */
+public class PreProcessLogicalRel extends RelShuttleImpl {
+  private RelDataTypeFactory factory;
+  private DrillOperatorTable table;
+  private UnsupportedOperatorCollector unsupportedOperatorCollector;
+  private static PreProcessLogicalRel INSTANCE = null;
+
+  public static void initialize(RelDataTypeFactory factory, DrillOperatorTable table) {
+    if(INSTANCE == null) {
+      INSTANCE = new PreProcessLogicalRel(factory, table);
+    }
+  }
+
+  public static PreProcessLogicalRel getVisitor() {
+    if(INSTANCE == null) {
+      throw new IllegalStateException("RewriteProjectRel is not initialized properly");
+    }
+
+    return INSTANCE;
+  }
+
+  private PreProcessLogicalRel(RelDataTypeFactory factory, DrillOperatorTable table) {
+    super();
+    this.factory = factory;
+    this.table = table;
+    this.unsupportedOperatorCollector = new UnsupportedOperatorCollector();
+  }
+
+  @Override
+  public RelNode visit(AggregateRel aggregate) {
+    for(AggregateCall aggregateCall : aggregate.getAggCallList()) {
+      if(aggregateCall.getAggregation() instanceof SqlSingleValueAggFunction) {
+        unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.FUNCTION,
+            "1937", "Non-scalar sub-query used in an expression");
+        throw new UnsupportedOperationException();
+      }
+    }
+
+    return visitChild(aggregate, 0, aggregate.getChild());
+  }
+
+  @Override
+  public RelNode visit(ProjectRel project) {
+    List<RexNode> exprList = new ArrayList<>();
+    boolean rewrite = false;
+
+    for (RexNode rex : project.getChildExps()) {
+      RexNode newExpr = rex;
+      if (rex instanceof RexCall) {
+        RexCall function = (RexCall) rex;
+        String functionName = function.getOperator().getName();
+        int nArgs = function.getOperands().size();
+
+        // check if its a convert_from or convert_to function
+        if (functionName.equalsIgnoreCase("convert_from") || functionName.equalsIgnoreCase("convert_to"))
{
+          assert nArgs == 2 && function.getOperands().get(1) instanceof RexLiteral;
+          String literal = ((NlsString) (((RexLiteral) function.getOperands().get(1)).getValue())).getValue();
+          RexBuilder builder = new RexBuilder(factory);
+
+          // construct the new function name based on the input argument
+          String newFunctionName = functionName + literal;
+
+          // Look up the new function name in the drill operator table
+          List<SqlOperator> operatorList = table.getSqlOperator(newFunctionName);
+          assert operatorList.size() > 0;
+          SqlFunction newFunction = null;
+
+          // Find the SqlFunction with the correct args
+          for (SqlOperator op : operatorList) {
+            if (op.getOperandTypeChecker().getOperandCountRange().isValidCount(nArgs - 1))
{
+              newFunction = (SqlFunction) op;
+              break;
+            }
+          }
+          assert newFunction != null;
+
+          // create the new expression to be used in the rewritten project
+          newExpr = builder.makeCall(newFunction, function.getOperands().subList(0, 1));
+          rewrite = true;
+        }
+      }
+      exprList.add(newExpr);
+    }
+
+    if (rewrite == true) {
+      ProjectRel newProject = project.copy(project.getTraitSet(), project.getInput(0), exprList,
project.getRowType());
+      return visitChild(newProject, 0, project.getChild());
+    }
+
+    return visitChild(project, 0, project.getChild());
+  }
+
+  public void convertException() throws SqlUnsupportedException {
+    unsupportedOperatorCollector.convertException();
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/RewriteProjectRel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/RewriteProjectRel.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/RewriteProjectRel.java
deleted file mode 100644
index f0ff70c..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/RewriteProjectRel.java
+++ /dev/null
@@ -1,106 +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.exec.planner.logical;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.drill.exec.planner.sql.DrillOperatorTable;
-import org.eigenbase.rel.ProjectRel;
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.rel.RelShuttleImpl;
-import org.eigenbase.reltype.RelDataTypeFactory;
-import org.eigenbase.rex.RexBuilder;
-import org.eigenbase.rex.RexCall;
-import org.eigenbase.rex.RexLiteral;
-import org.eigenbase.rex.RexNode;
-import org.eigenbase.sql.SqlFunction;
-import org.eigenbase.sql.SqlOperator;
-import org.eigenbase.util.NlsString;
-
-/**
- * This class rewrites all the project expression that contain convert_to/ convert_from
- * to actual implementations.
- * Eg: convert_from(EXPR, 'JSON') is rewritten as convert_fromjson(EXPR)
- *
- * With the actual method name we can find out if the function has a complex
- * output type and we will fire/ ignore certain rules (merge project rule) based on this
fact.
- */
-public class RewriteProjectRel extends RelShuttleImpl {
-
-  RelDataTypeFactory factory;
-  DrillOperatorTable table;
-
-  public RewriteProjectRel(RelDataTypeFactory factory, DrillOperatorTable table) {
-    super();
-    this.factory = factory;
-    this.table = table;
-  }
-
-  @Override
-  public RelNode visit(ProjectRel project) {
-
-    List<RexNode> exprList = new ArrayList<>();
-    boolean rewrite = false;
-
-    for (RexNode rex : project.getChildExps()) {
-      RexNode newExpr = rex;
-      if (rex instanceof RexCall) {
-        RexCall function = (RexCall) rex;
-        String functionName = function.getOperator().getName();
-        int nArgs = function.getOperands().size();
-
-        // check if its a convert_from or convert_to function
-        if (functionName.equalsIgnoreCase("convert_from") || functionName.equalsIgnoreCase("convert_to"))
{
-          assert nArgs == 2 && function.getOperands().get(1) instanceof RexLiteral;
-          String literal = ((NlsString) (((RexLiteral) function.getOperands().get(1)).getValue())).getValue();
-          RexBuilder builder = new RexBuilder(factory);
-
-          // construct the new function name based on the input argument
-          String newFunctionName = functionName + literal;
-
-          // Look up the new function name in the drill operator table
-          List<SqlOperator> operatorList = table.getSqlOperator(newFunctionName);
-          assert operatorList.size() > 0;
-          SqlFunction newFunction = null;
-
-          // Find the SqlFunction with the correct args
-          for (SqlOperator op : operatorList) {
-            if (op.getOperandTypeChecker().getOperandCountRange().isValidCount(nArgs - 1))
{
-              newFunction = (SqlFunction) op;
-              break;
-            }
-          }
-          assert newFunction != null;
-
-          // create the new expression to be used in the rewritten project
-          newExpr = builder.makeCall(newFunction, function.getOperands().subList(0, 1));
-          rewrite = true;
-        }
-      }
-      exprList.add(newExpr);
-    }
-
-    if (rewrite == true) {
-      ProjectRel newProject = project.copy(project.getTraitSet(), project.getInput(0), exprList,
project.getRowType());
-      return visitChild(newProject, 0, project.getChild());
-    }
-
-    return visitChild(project, 0, project.getChild());
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/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 6b3d301..0ac7c97 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
@@ -38,7 +38,7 @@ import org.apache.drill.exec.physical.base.PhysicalOperator;
 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.logical.PreProcessLogicalRel;
 import org.apache.drill.exec.planner.physical.DrillDistributionTrait;
 import org.apache.drill.exec.planner.physical.PhysicalPlanCreator;
 import org.apache.drill.exec.planner.physical.PlannerSettings;
@@ -60,6 +60,7 @@ 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.apache.drill.exec.work.foreman.SqlUnsupportedException;
 import org.eigenbase.rel.RelNode;
 import org.eigenbase.relopt.RelOptUtil;
 import org.eigenbase.relopt.RelTraitSet;
@@ -124,12 +125,8 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
     SqlNode rewrittenSqlNode = rewrite(sqlNode);
     SqlNode validated = validateNode(rewrittenSqlNode);
     RelNode rel = convertToRel(validated);
+    rel = preprocessNode(rel);
 
-    /* Traverse the tree and replace the convert_from, convert_to function to actual implementations
-     * Eg: convert_from(EXPR, 'JSON') be converted to convert_fromjson(EXPR);
-     * TODO: Ideally all function rewrites would move here instead of DrillOptiq
-     */
-    rel = rel.accept(new RewriteProjectRel(planner.getTypeFactory(), context.getDrillOperatorTable()));
     log("Optiq Logical", rel);
     DrillRel drel = convertToDrel(rel);
     log("Drill Logical", drel);
@@ -162,7 +159,31 @@ public class DefaultSqlHandler extends AbstractSqlHandler {
   protected RelNode convertToRel(SqlNode node) throws RelConversionException {
     RelNode convertedNode = planner.convert(node);
     hepPlanner.setRoot(convertedNode);
-    return hepPlanner.findBestExp();
+    RelNode rel = hepPlanner.findBestExp();
+
+    return rel;
+  }
+
+  protected RelNode preprocessNode(RelNode rel) throws SqlUnsupportedException{
+     /* Traverse the tree to do the following pre-processing tasks:
+     * 1. replace the convert_from, convert_to function to actual implementations
+     * Eg: convert_from(EXPR, 'JSON') be converted to convert_fromjson(EXPR);
+     * TODO: Ideally all function rewrites would move here instead of DrillOptiq
+     *
+     * 2. see where the tree contains unsupported functions;
+     * throw SqlUnsupportedException if there is
+     */
+
+     PreProcessLogicalRel.initialize(planner.getTypeFactory(), context.getDrillOperatorTable());
+     PreProcessLogicalRel visitor =  PreProcessLogicalRel.getVisitor();
+     try {
+        rel = rel.accept(visitor);
+     } catch(UnsupportedOperationException ex) {
+        visitor.convertException();
+       throw ex;
+     }
+
+    return rel;
   }
 
   protected DrillRel convertToDrel(RelNode relNode) throws RelConversionException {

http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/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 8d57aee..1cce6a5 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
@@ -55,6 +55,8 @@ public class ExplainHandler extends DefaultSqlHandler {
     SqlNode sqlNode = rewrite(node);
     SqlNode validated = validateNode(sqlNode);
     RelNode rel = convertToRel(validated);
+    rel = preprocessNode(rel);
+
     log("Optiq Logical", rel);
     DrillRel drel = convertToDrel(rel);
     log("Drill Logical", drel);

http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
index 8fedcce..dcd5ebf 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
@@ -50,7 +50,6 @@ public class UnsupportedOperatorsVisitor extends SqlShuttle {
   }
 
   public static UnsupportedOperatorsVisitor getVisitor() {
-    visitor.unsupportedOperatorCollector.clean();
     return visitor;
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/SqlUnsupportedException.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/SqlUnsupportedException.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/SqlUnsupportedException.java
index c5ba683..65e9d2d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/SqlUnsupportedException.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/SqlUnsupportedException.java
@@ -18,15 +18,41 @@
 
 package org.apache.drill.exec.work.foreman;
 
+import org.apache.drill.exec.exception.UnsupportedOperatorCollector;
+
 public abstract class SqlUnsupportedException extends ForemanSetupException {
-  public enum ExceptionType {
-    NONE, RELATIONAL, DATA_TYPE, FUNCTION
+  public static enum ExceptionType {
+    NONE("NONE"),
+    RELATIONAL(UnsupportedRelOperatorException.class.getSimpleName()),
+    DATA_TYPE(UnsupportedDataTypeException.class.getSimpleName()),
+    FUNCTION(UnsupportedFunctionException.class.getSimpleName());
+
+    private String exceptionType;
+    ExceptionType(String exceptionType) {
+      this.exceptionType = exceptionType;
+    }
+
+    @Override
+    public String toString() {
+      return exceptionType;
+    }
   }
 
   public SqlUnsupportedException(String jiraNumber, String disabledFunctionality) {
     super(disabledFunctionality + " is not supported\n" +
         "See Apache Drill JIRA: DRILL-" + jiraNumber);
   }
+
+  public static void errorMessageToException(String errorMessage) throws SqlUnsupportedException
{
+    UnsupportedOperatorCollector collector = new UnsupportedOperatorCollector();
+    for(ExceptionType ex : ExceptionType.values()) {
+      if(errorMessage.startsWith(ex.toString())) {
+        collector.setException(ex);
+        collector.convertException();
+        collector.clean();
+      }
+    }
+  }
 }
 
 

http://git-wip-us.apache.org/repos/asf/drill/blob/fe265059/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
b/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
index 241ee15..c88badd 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestDisabledFunctionality.java
@@ -16,69 +16,158 @@
  * limitations under the License.
  */
 package org.apache.drill;
-import org.apache.drill.exec.rpc.RpcException;
+import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
+import org.apache.drill.exec.work.foreman.UnsupportedDataTypeException;
+import org.apache.drill.exec.work.foreman.UnsupportedFunctionException;
+import org.apache.drill.exec.work.foreman.UnsupportedRelOperatorException;
 import org.junit.Test;
 
 public class TestDisabledFunctionality extends BaseTestQuery{
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestExampleQueries.class);
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedFunctionException.class)  // see DRILL-1937
+  public void testDisabledExplainplanForComparisonWithNonscalarSubquery() throws Exception
{
+    try {
+      test("explain plan for select n_name from cp.`tpch/nation.parquet` " +
+           "where n_nationkey = " +
+           "(select r_regionkey from cp.`tpch/region.parquet` " +
+           "where r_regionkey = 1)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
+  }
+
+  @Test(expected = UnsupportedFunctionException.class)  // see DRILL-1937
+  public void testDisabledComparisonWithNonscalarSubquery() throws Exception {
+    try {
+      test("select n_name from cp.`tpch/nation.parquet` " +
+           "where n_nationkey = " +
+           "(select r_regionkey from cp.`tpch/region.parquet` " +
+           "where r_regionkey = 1)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
+  }
+
+  @Test(expected = UnsupportedRelOperatorException.class)  // see DRILL-1921
   public void testDisabledUnion() throws Exception {
-    test("(select n_name as name from cp.`tpch/nation.parquet`) UNION (select r_name as name
from cp.`tpch/region.parquet`)");
+    try {
+      test("(select n_name as name from cp.`tpch/nation.parquet`) UNION (select r_name as
name from cp.`tpch/region.parquet`)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedRelOperatorException.class) // see DRILL-1921
   public void testDisabledUnionDistinct() throws Exception {
-    test("(select n_name as name from cp.`tpch/nation.parquet`) UNION DISTINCT (select r_name
as name from cp.`tpch/region.parquet`)");
+    try {
+      test("(select n_name as name from cp.`tpch/nation.parquet`) UNION DISTINCT (select
r_name as name from cp.`tpch/region.parquet`)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedRelOperatorException.class) // see DRILL-1921
   public void testDisabledIntersect() throws Exception {
-    test("(select n_name as name from cp.`tpch/nation.parquet`) INTERSECT (select r_name
as name from cp.`tpch/region.parquet`)");
+    try {
+      test("(select n_name as name from cp.`tpch/nation.parquet`) INTERSECT (select r_name
as name from cp.`tpch/region.parquet`)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedRelOperatorException.class) // see DRILL-1921
   public void testDisabledIntersectALL() throws Exception {
-    test("(select n_name as name from cp.`tpch/nation.parquet`) INTERSECT ALL (select r_name
as name from cp.`tpch/region.parquet`)");
+    try {
+      test("(select n_name as name from cp.`tpch/nation.parquet`) INTERSECT ALL (select r_name
as name from cp.`tpch/region.parquet`)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedRelOperatorException.class) // see DRILL-1921
   public void testDisabledExceptALL() throws Exception {
-    test("(select n_name as name from cp.`tpch/nation.parquet`) EXCEPT ALL (select r_name
as name from cp.`tpch/region.parquet`)");
+    try {
+      test("(select n_name as name from cp.`tpch/nation.parquet`) EXCEPT ALL (select r_name
as name from cp.`tpch/region.parquet`)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedRelOperatorException.class) // see DRILL-1921
   public void testDisabledExcept() throws Exception {
-    test("(select n_name as name from cp.`tpch/nation.parquet`) EXCEPT (select r_name as
name from cp.`tpch/region.parquet`)");
+    try {
+      test("(select n_name as name from cp.`tpch/nation.parquet`) EXCEPT (select r_name as
name from cp.`tpch/region.parquet`)");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedRelOperatorException.class) // see DRILL-1921
   public void testDisabledNaturalJoin() throws Exception {
-    test("select * from cp.`tpch/nation.parquet` NATURAL JOIN cp.`tpch/region.parquet`");
+    try {
+      test("select * from cp.`tpch/nation.parquet` NATURAL JOIN cp.`tpch/region.parquet`");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1921
+  @Test(expected = UnsupportedRelOperatorException.class) // see DRILL-1921
   public void testDisabledCrossJoin() throws Exception {
-    test("select * from cp.`tpch/nation.parquet` CROSS JOIN cp.`tpch/region.parquet`");
+    try {
+      test("select * from cp.`tpch/nation.parquet` CROSS JOIN cp.`tpch/region.parquet`");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1959
+  @Test(expected = UnsupportedDataTypeException.class) // see DRILL-1959
   public void testDisabledCastTINYINT() throws Exception {
-    test("select cast(n_name as tinyint) from cp.`tpch/nation.parquet`;");
+    try {
+      test("select cast(n_name as tinyint) from cp.`tpch/nation.parquet`;");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1959
+  @Test(expected = UnsupportedDataTypeException.class) // see DRILL-1959
   public void testDisabledCastSMALLINT() throws Exception {
-    test("select cast(n_name as smallint) from cp.`tpch/nation.parquet`;");
+    try {
+      test("select cast(n_name as smallint) from cp.`tpch/nation.parquet`;");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-1959
+  @Test(expected = UnsupportedDataTypeException.class) // see DRILL-1959
   public void testDisabledCastREAL() throws Exception {
-    test("select cast(n_name as real) from cp.`tpch/nation.parquet`;");
+    try {
+      test("select cast(n_name as real) from cp.`tpch/nation.parquet`;");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 
-  @Test(expected = RpcException.class) // see DRILL-2115
+  @Test(expected = UnsupportedFunctionException.class) // see DRILL-2115
   public void testDisabledCardinality() throws Exception {
-    test("select cardinality(employee_id) from cp.`employee.json`;");
+    try {
+      test("select cardinality(employee_id) from cp.`employee.json`;");
+    } catch(Exception ex) {
+      SqlUnsupportedException.errorMessageToException(ex.getMessage());
+      throw ex;
+    }
   }
 }
\ No newline at end of file


Mime
View raw message