You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2014/05/21 22:44:56 UTC

git commit: DRILL-797: Fix Sql type returned for TimeStamp

Repository: incubator-drill
Updated Branches:
  refs/heads/master ae570aad8 -> 2fad21d5a


DRILL-797: Fix Sql type returned for TimeStamp


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

Branch: refs/heads/master
Commit: 2fad21d5a6ec43bb68fb989e48b6da180f23f73a
Parents: ae570aa
Author: Mehant Baid <me...@gmail.com>
Authored: Wed May 21 11:51:00 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed May 21 13:44:25 2014 -0700

----------------------------------------------------------------------
 .../org/apache/drill/common/types/Types.java    |  3 +--
 .../apache/drill/jdbc/test/TestJdbcQuery.java   | 25 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2fad21d5/common/src/main/java/org/apache/drill/common/types/Types.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/types/Types.java b/common/src/main/java/org/apache/drill/common/types/Types.java
index 5d0812f..66ed87c 100644
--- a/common/src/main/java/org/apache/drill/common/types/Types.java
+++ b/common/src/main/java/org/apache/drill/common/types/Types.java
@@ -83,8 +83,6 @@ public class Types {
       return java.sql.Types.BOOLEAN;
     case DATE:
       return java.sql.Types.DATE;
-    case TIMESTAMP:
-      return java.sql.Types.DATE;
     case DECIMAL9:
     case DECIMAL18:
     case DECIMAL28DENSE:
@@ -120,6 +118,7 @@ public class Types {
     case TIME:
       return java.sql.Types.TIME;
     case TIMESTAMPTZ:
+    case TIMESTAMP:
       return java.sql.Types.TIMESTAMP;
     case TIMETZ:
       return java.sql.Types.DATE;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/2fad21d5/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
index 9ef5cc4..8783897 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
@@ -27,6 +27,7 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Types;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.drill.common.util.TestTools;
@@ -816,6 +817,30 @@ import static org.junit.Assert.fail;
   }
 
   @Test
+  public void testVerifyMetadata() throws Exception{
+    JdbcAssert.withNoDefaultSchema().withConnection(new Function<Connection, Void>() {
+      public Void apply(Connection connection) {
+        try {
+          Statement statement = connection.createStatement();
+
+          // show files
+          ResultSet resultSet = statement.executeQuery("select timestamp '2008-2-23 12:23:23', date '2001-01-01', timestamptztype('2008-2-23 1:20:23 US/Pacific') from cp.`employee.json` limit 1");
+
+          assert (resultSet.getMetaData().getColumnType(1) == Types.TIMESTAMP);
+          assert (resultSet.getMetaData().getColumnType(2) == Types.DATE);
+          assert (resultSet.getMetaData().getColumnType(3) == Types.TIMESTAMP);
+
+          System.out.println(JdbcAssert.toString(resultSet));
+          statement.close();
+          return null;
+        } catch (Exception e) {
+          throw new RuntimeException(e);
+        }
+      }
+    });
+  }
+
+  @Test
   public void testViewWithFullSchemaIdentifier() throws Exception{
     JdbcAssert.withNoDefaultSchema().withConnection(new Function<Connection, Void>() {
       public Void apply(Connection connection) {