drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject drill git commit: DRILL-3791: Fix bugs in JDBC storage plugin
Date Wed, 07 Oct 2015 23:37:35 GMT
Repository: drill
Updated Branches:
  refs/heads/master aa63e1f48 -> 5d4167c6e


DRILL-3791: Fix bugs in JDBC storage plugin

Fixes issues with bit, date, time and timestamp types in MySQL.


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

Branch: refs/heads/master
Commit: 5d4167c6e1b9b64edd617caea96ee80dbae0e18f
Parents: aa63e1f
Author: aleph-zero <andrew@primer.org>
Authored: Thu Oct 1 13:23:41 2015 -0700
Committer: Jason Altekruse <altekrusejason@gmail.com>
Committed: Wed Oct 7 16:08:35 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/store/jdbc/JdbcRecordReader.java    | 17 ++++++++++++++---
 .../main/resources/bootstrap-storage-plugins.json  | 10 ----------
 .../drill/exec/server/rest/StorageResources.java   |  6 +++---
 3 files changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/5d4167c6/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 463ae67..2fa647f 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
@@ -26,6 +26,8 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Time;
 import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.TimeZone;
 
 import javax.sql.DataSource;
 
@@ -113,6 +115,8 @@ class JdbcRecordReader extends AbstractRecordReader {
 
         .put(java.sql.Types.BOOLEAN, MinorType.BIT)
 
+        .put(java.sql.Types.BIT, MinorType.BIT)
+
         .build();
   }
 
@@ -364,13 +368,15 @@ class JdbcRecordReader extends AbstractRecordReader {
 
   private class DateCopier extends Copier<NullableDateVector.Mutator> {
 
+    private final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+
     public DateCopier(int columnIndex, ResultSet result, NullableDateVector.Mutator mutator)
{
       super(columnIndex, result, mutator);
     }
 
     @Override
     void copy(int index) throws SQLException {
-      Date date = result.getDate(columnIndex);
+      Date date = result.getDate(columnIndex, calendar);
       if (date != null) {
         mutator.setSafe(index, date.getTime());
       }
@@ -380,13 +386,15 @@ class JdbcRecordReader extends AbstractRecordReader {
 
   private class TimeCopier extends Copier<NullableTimeVector.Mutator> {
 
+    private final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+
     public TimeCopier(int columnIndex, ResultSet result, NullableTimeVector.Mutator mutator)
{
       super(columnIndex, result, mutator);
     }
 
     @Override
     void copy(int index) throws SQLException {
-      Time time = result.getTime(columnIndex);
+      Time time = result.getTime(columnIndex, calendar);
       if (time != null) {
         mutator.setSafe(index, (int) time.getTime());
       }
@@ -395,15 +403,18 @@ class JdbcRecordReader extends AbstractRecordReader {
 
   }
 
+
   private class TimeStampCopier extends Copier<NullableTimeStampVector.Mutator> {
 
+    private final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+
     public TimeStampCopier(int columnIndex, ResultSet result, NullableTimeStampVector.Mutator
mutator) {
       super(columnIndex, result, mutator);
     }
 
     @Override
     void copy(int index) throws SQLException {
-      Timestamp stamp = result.getTimestamp(columnIndex);
+      Timestamp stamp = result.getTimestamp(columnIndex, calendar);
       if (stamp != null) {
         mutator.setSafe(index, stamp.getTime());
       }

http://git-wip-us.apache.org/repos/asf/drill/blob/5d4167c6/contrib/storage-jdbc/src/main/resources/bootstrap-storage-plugins.json
----------------------------------------------------------------------
diff --git a/contrib/storage-jdbc/src/main/resources/bootstrap-storage-plugins.json b/contrib/storage-jdbc/src/main/resources/bootstrap-storage-plugins.json
deleted file mode 100755
index 7d88052..0000000
--- a/contrib/storage-jdbc/src/main/resources/bootstrap-storage-plugins.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
-  "storage":{
-    "jdbc" : {
-      type:"jdbc",
-      enabled: false,
-      driver:"org.apache.derby.jdbc.ClientDriver",
-      url:"jdbc:derby://localhost:20000/memory:testDB;"
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/5d4167c6/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
index 49f387c..1cff961 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
@@ -171,13 +171,13 @@ public class StorageResources {
       StoragePluginConfig config = mapper.readValue(new StringReader(storagePluginConfig),
StoragePluginConfig.class);
       return createOrUpdatePluginJSON(new PluginConfigWrapper(name, config));
     } catch (JsonMappingException e) {
-      logger.debug("Error in JSON mapping: " + storagePluginConfig);
+      logger.debug("Error in JSON mapping: {}", storagePluginConfig, e);
       return message("error (invalid JSON mapping)");
     } catch (JsonParseException e) {
-      logger.debug("Error parsing JSON: " + storagePluginConfig);
+      logger.debug("Error parsing JSON: {}", storagePluginConfig, e);
       return message("error (unable to parse JSON)");
     } catch (IOException e) {
-      logger.debug("Failed to read: " + storagePluginConfig);
+      logger.debug("Failed to read: {}", storagePluginConfig, e);
       return message("error (unable to read)");
     }
   }


Mime
View raw message