sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-1031: Provide default Java type mapping for MS Sql Datetimeoffset type
Date Tue, 21 May 2013 06:23:07 GMT
Updated Branches:
  refs/heads/trunk e76ee6eea -> 28af5122e


SQOOP-1031: Provide default Java type mapping for MS Sql Datetimeoffset type

(Shuaishuai Nie via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/28af5122
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/28af5122
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/28af5122

Branch: refs/heads/trunk
Commit: 28af5122ea8778b5fcd6341a492d64283c706b08
Parents: e76ee6e
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Mon May 20 23:22:04 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Mon May 20 23:22:04 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/manager/SQLServerManager.java |   25 +++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/28af5122/src/java/org/apache/sqoop/manager/SQLServerManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/SQLServerManager.java b/src/java/org/apache/sqoop/manager/SQLServerManager.java
index 88254a8..eea5a1d 100644
--- a/src/java/org/apache/sqoop/manager/SQLServerManager.java
+++ b/src/java/org/apache/sqoop/manager/SQLServerManager.java
@@ -56,6 +56,9 @@ public class SQLServerManager
   private static final String DRIVER_CLASS =
       "com.microsoft.sqlserver.jdbc.SQLServerDriver";
 
+  // Define SQL Server specific types that are not covered by parent classes
+  private static final int DATETIMEOFFSET = -155;
+
   /**
    * Schema name that we will use.
    */
@@ -77,6 +80,28 @@ public class SQLServerManager
     }
   }
 
+  /**
+   * Resolve MS SQL Server specific database type to the Java type that should
+   * contain it.
+   * @param sqlType     sql type
+   * @return the name of a Java type to hold the sql datatype, or null if none.
+   */
+  @Override
+  public String toJavaType(int sqlType) {
+    String javaType;
+
+    if (sqlType == DATETIMEOFFSET) {
+      // We cannot use the TimeStamp class to represent MS SQL Server datetimeoffset
+      // data type since it does not preserve time zone offset values, so use String
+      // instead which would work for import/export
+      javaType = "String";
+    }else {
+      //If none of the above data types match, it returns parent method's
+      //status, which can be null.
+      javaType = super.toJavaType(sqlType);
+    }
+    return javaType;
+  }
 
   /**
    * {@inheritDoc}


Mime
View raw message