You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ar...@apache.org on 2017/07/21 13:30:50 UTC

[2/4] drill git commit: DRILL-4755: Fix IOBE for convert_from/convert_to functions with incorrect encoding type

DRILL-4755: Fix IOBE for convert_from/convert_to functions with incorrect encoding type

closes #867


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

Branch: refs/heads/master
Commit: 34d736e6dabea7d3d4bb8fb699e956f72bcdbfb8
Parents: a3f9dff
Author: Volodymyr Vysotskyi <vv...@gmail.com>
Authored: Tue Jul 4 18:19:23 2017 +0000
Committer: Arina Ielchiieva <ar...@gmail.com>
Committed: Fri Jul 21 15:48:07 2017 +0300

----------------------------------------------------------------------
 .../planner/logical/PreProcessLogicalRel.java   |  5 ++--
 .../exec/planner/sql/DrillOperatorTable.java    |  4 ++--
 .../test/TestExecutionExceptionsToClient.java   | 24 +++++++++++++++++++-
 3 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/34d736e6/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
index 10c131d..1230498 100644
--- 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
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -28,7 +28,6 @@ import org.apache.calcite.rex.RexUtil;
 import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.exec.exception.UnsupportedOperatorCollector;
 import org.apache.drill.exec.planner.StarColumnHelper;
-import org.apache.drill.exec.planner.sql.DrillCalciteSqlWrapper;
 import org.apache.drill.exec.planner.sql.DrillOperatorTable;
 import org.apache.drill.exec.planner.sql.parser.DrillCalciteWrapperUtility;
 import org.apache.drill.exec.util.ApproximateStringMatcher;
@@ -240,7 +239,7 @@ public class PreProcessLogicalRel extends RelShuttleImpl {
         ops.add(op.getName());
       }
       final String bestMatch = ApproximateStringMatcher.getBestMatch(ops, newFunctionName);
-      if (bestMatch != null && bestMatch.length() > 0 && bestMatch.toLowerCase().startsWith("convert")) {
+      if (bestMatch != null && bestMatch.length() > functionName.length() && bestMatch.toLowerCase().startsWith("convert")) {
         final StringBuilder s = new StringBuilder("Did you mean ")
                 .append(bestMatch.substring(functionName.length()))
                 .append("?");

http://git-wip-us.apache.org/repos/asf/drill/blob/34d736e6/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillOperatorTable.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillOperatorTable.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillOperatorTable.java
index 5102ae8..cf858d3 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillOperatorTable.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillOperatorTable.java
@@ -148,9 +148,9 @@ public class DrillOperatorTable extends SqlStdOperatorTable {
     final List<SqlOperator> sqlOperators = Lists.newArrayList();
     sqlOperators.addAll(calciteOperators);
     if(isInferenceEnabled()) {
-      sqlOperators.addAll(calciteOperators);
+      sqlOperators.addAll(drillOperatorsWithInference);
     } else {
-      sqlOperators.addAll(calciteOperators);
+      sqlOperators.addAll(drillOperatorsWithoutInference);
     }
 
     return sqlOperators;

http://git-wip-us.apache.org/repos/asf/drill/blob/34d736e6/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestExecutionExceptionsToClient.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestExecutionExceptionsToClient.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestExecutionExceptionsToClient.java
index 749312f..1eaf6d2 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestExecutionExceptionsToClient.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestExecutionExceptionsToClient.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -19,6 +19,7 @@ package org.apache.drill.jdbc.test;
 
 import static org.junit.Assert.assertThat;
 import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -192,4 +193,25 @@ public class TestExecutionExceptionsToClient extends JdbcTestBase {
       throw e;
     }
   }
+
+  @Test(expected = SQLException.class)
+  public void testConvertFromError() throws Exception {
+    final Statement statement = connection.createStatement();
+    try {
+      statement.executeUpdate("select CONVERT_FROM('1','INTEGER') from (values(1))");
+    } catch (SQLException e) {
+      assertThat("Null getCause(); missing expected wrapped exception",
+        e.getCause(), notNullValue());
+
+      assertThat("Unexpectedly wrapped another SQLException",
+        e.getCause(), not(instanceOf(SQLException.class)));
+
+      assertThat("getCause() not UserRemoteException as expected",
+        e.getCause(), instanceOf(UserRemoteException.class));
+
+      assertTrue("No expected current \"UNSUPPORTED_OPERATION ERROR\" and/or \"Did you mean\"",
+        e.getMessage().matches("^UNSUPPORTED_OPERATION ERROR(.|\\n)*Did you mean(.|\\n)*"));
+      throw e;
+    }
+  }
 }