drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [1/9] drill git commit: DRILL-4031: Log warning and ignore columns returned from JDBC source that are unsupported.
Date Thu, 05 Nov 2015 05:56:39 GMT
Repository: drill
Updated Branches:
  refs/heads/master ef1cb7288 -> 3dedc158f


DRILL-4031: Log warning and ignore columns returned from JDBC source that are unsupported.

This closes #240


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

Branch: refs/heads/master
Commit: 18a1ae4d31cd502d2f792b331fefeb0ed2106c53
Parents: 745bcd1
Author: Jacques Nadeau <jacques@apache.org>
Authored: Wed Nov 4 10:46:36 2015 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Wed Nov 4 20:55:53 2015 -0800

----------------------------------------------------------------------
 .../drill/exec/store/jdbc/JdbcRecordReader.java | 33 +++++++++++++++++---
 .../exec/store/jdbc/JdbcStoragePlugin.java      | 24 ++++++++++----
 2 files changed, 47 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/18a1ae4d/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
----------------------------------------------------------------------
diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
index 436f065..e749c79 100755
--- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
+++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcRecordReader.java
@@ -17,6 +17,7 @@
  */
 package org.apache.drill.exec.store.jdbc;
 
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.sql.Connection;
 import java.sql.Date;
@@ -122,6 +123,23 @@ class JdbcRecordReader extends AbstractRecordReader {
         .build();
   }
 
+  private static String nameFromType(int javaSqlType) {
+    try {
+      for (Field f : java.sql.Types.class.getFields()) {
+        if (java.lang.reflect.Modifier.isStatic(f.getModifiers()) &&
+            f.getType() == int.class &&
+            f.getInt(null) == javaSqlType) {
+          return f.getName();
+
+        }
+      }
+    } catch (IllegalArgumentException | IllegalAccessException e) {
+    }
+
+    return Integer.toString(javaSqlType);
+
+  }
+
   private Copier<?> getCopier(int jdbcType, int offset, ResultSet result, ValueVector
v) {
 
     if (v instanceof NullableBigIntVector) {
@@ -170,13 +188,20 @@ class JdbcRecordReader extends AbstractRecordReader {
         final int scale = meta.getScale(i);
         MinorType minorType = JDBC_TYPE_MAPPINGS.get(jdbcType);
         if (minorType == null) {
-          throw UserException.dataReadError()
-              .message("The JDBC storage plugin failed while trying to execute a query. "
-                  + "The JDBC data type %d is not currently supported.", jdbcType)
 
+          logger.warn("Ignoring column that is unsupported.", UserException
+              .unsupportedError()
+              .message(
+                  "A column you queried has a data type that is not currently supported by
the JDBC storage plugin. "
+                      + "The column's name was %s and its JDBC data type was %s. ",
+                  name,
+                  nameFromType(jdbcType))
               .addContext("sql", sql)
+              .addContext("column Name", name)
               .addContext("plugin", storagePluginName)
-              .build(logger);
+              .build(logger));
+
+          continue;
         }
 
         final MajorType type = Types.optional(minorType);

http://git-wip-us.apache.org/repos/asf/drill/blob/18a1ae4d/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
----------------------------------------------------------------------
diff --git a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
index 24d1f9d..c22979f 100755
--- a/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
+++ b/contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
@@ -61,6 +61,7 @@ import org.apache.drill.exec.store.SchemaConfig;
 import org.apache.drill.exec.store.jdbc.DrillJdbcRuleBase.DrillJdbcFilterRule;
 import org.apache.drill.exec.store.jdbc.DrillJdbcRuleBase.DrillJdbcProjectRule;
 
+import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
@@ -281,6 +282,10 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
       return inner.getTableNames();
     }
 
+    public String toString() {
+      return Joiner.on(".").join(getSchemaPath());
+    }
+
     @Override
     public Table getTable(String name) {
       Table table = inner.getTable(name);
@@ -395,15 +400,22 @@ public class JdbcStoragePlugin extends AbstractStoragePlugin {
     @Override
     public Table getTable(String name) {
       Schema schema = getDefaultSchema();
+
       if (schema != null) {
-        Table t = schema.getTable(name);
-        if (t != null) {
-          return t;
+        try {
+          Table t = schema.getTable(name);
+          if (t != null) {
+            return t;
+          }
+          return schema.getTable(name.toUpperCase());
+        } catch (RuntimeException e) {
+          logger.warn("Failure while attempting to read table '{}' from JDBC source.", name,
e);
+
         }
-        return schema.getTable(name.toUpperCase());
-      } else {
-        return null;
       }
+
+      // no table was found.
+      return null;
     }
 
     @Override


Mime
View raw message