drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [5/6] drill git commit: DRILL-3755: In DrillSqlWorker, give UserException.validationError if ValidationException is thrown from Calcite
Date Fri, 11 Sep 2015 05:20:15 GMT
DRILL-3755: In DrillSqlWorker, give UserException.validationError if ValidationException is
thrown from Calcite


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

Branch: refs/heads/master
Commit: 1b333678f3a2b32b5d6bad4ddf3b1001e33b42f7
Parents: e29a153
Author: Hsuan-Yi Chu <hsuanyi@usc.edu>
Authored: Mon Sep 7 16:47:18 2015 -0700
Committer: Jinfeng Ni <jni@apache.org>
Committed: Thu Sep 10 17:46:10 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/planner/sql/DrillSqlWorker.java  | 10 ++++----
 .../apache/drill/exec/TestWindowFunctions.java  | 27 ++++++++++++--------
 2 files changed, 21 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/1b333678/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 bc79cff..64a2e1c 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
@@ -178,15 +178,15 @@ public class DrillSqlWorker {
       return handler.getPlan(sqlNode);
     } catch(ValidationException e) {
       String errorMessage = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
-      throw UserException.parseError(e)
-        .message(errorMessage)
-        .build(logger);
+      throw UserException.validationError(e)
+          .message(errorMessage)
+          .build(logger);
     } catch (AccessControlException e) {
       throw UserException.permissionError(e)
-        .build(logger);
+          .build(logger);
     } catch(SqlUnsupportedException e) {
       throw UserException.unsupportedError(e)
-        .build(logger);
+          .build(logger);
     } catch (IOException | RelConversionException e) {
       throw new QueryInputException("Failure handling SQL.", e);
     }

http://git-wip-us.apache.org/repos/asf/drill/blob/1b333678/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
index 0efd55c..9a3bc7b 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
@@ -21,10 +21,12 @@ import org.apache.drill.BaseTestQuery;
 import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.common.util.FileUtils;
 import org.apache.drill.common.util.TestTools;
+import org.apache.drill.exec.proto.UserBitShared;
 import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
 import org.apache.drill.exec.work.foreman.UnsupportedFunctionException;
 import org.apache.drill.PlanTestBase;
 
+import org.apache.drill.test.UserExceptionMatcher;
 import org.junit.Test;
 
 public class TestWindowFunctions extends BaseTestQuery {
@@ -211,16 +213,18 @@ public class TestWindowFunctions extends BaseTestQuery {
 
   @Test // DRILL-3344
   public void testWindowGroupBy() throws Exception {
+    thrownException.expect(new UserExceptionMatcher(UserBitShared.DrillPBError.ErrorType.VALIDATION));
     String query = "explain plan for SELECT max(n_nationkey) OVER (), n_name as col2 \n"
+
         "from cp.`tpch/nation.parquet` \n" +
         "group by n_name";
 
-    parseErrorHelper(query);
+    test(query);
   }
 
   @Test // DRILL-3346
   public void testWindowGroupByOnView() throws Exception {
     try {
+      thrownException.expect(new UserExceptionMatcher(UserBitShared.DrillPBError.ErrorType.VALIDATION));
       String createView = "create view testWindowGroupByOnView(a, b) as \n" +
           "select n_nationkey, n_name from cp.`tpch/nation.parquet`";
       String query = "explain plan for SELECT max(a) OVER (), b as col2 \n" +
@@ -229,7 +233,7 @@ public class TestWindowFunctions extends BaseTestQuery {
 
       test("use dfs_test.tmp");
       test(createView);
-      parseErrorHelper(query);
+      test(query);
     } finally {
       test("drop view testWindowGroupByOnView");
     }
@@ -402,15 +406,16 @@ public class TestWindowFunctions extends BaseTestQuery {
       PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, excludedPatterns);
 
       testBuilder()
-        .sqlQuery(query)
-        .ordered()
-        .baselineColumns("cnt")
-        .optionSettingQueriesForTestQuery("alter session set `planner.slice_target` = 1")
-        .baselineValues(1l)
-        .baselineValues(4l)
-        .baselineValues(4l)
-        .baselineValues(4l)
-        .build().run();
+          .sqlQuery(query)
+          .ordered()
+          .baselineColumns("cnt")
+          .optionSettingQueriesForTestQuery("alter session set `planner.slice_target` = 1")
+          .baselineValues(1l)
+          .baselineValues(4l)
+          .baselineValues(4l)
+          .baselineValues(4l)
+          .build()
+          .run();
     } finally {
       test("alter session set `planner.slice_target` = " + ExecConstants.SLICE_TARGET_DEFAULT);
     }


Mime
View raw message