SQOOP-2833: Sqoop2: Integration Tests: Allow setting which "time type" should be...
authorJarek Jarcec Cecho <jarcec@apache.org>
Mon, 29 Feb 2016 20:32:35 +0000 (12:32 -0800)
committerJarek Jarcec Cecho <jarcec@apache.org>
Mon, 29 Feb 2016 20:32:35 +0000 (12:32 -0800)
(Abraham Fine via Jarek Jarcec Cecho)

common-test/src/main/java/org/apache/sqoop/common/test/db/DatabaseProvider.java
common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
common-test/src/main/java/org/apache/sqoop/common/test/db/SqlServerProvider.java
test/src/main/java/org/apache/sqoop/test/data/Cities.java
test/src/main/java/org/apache/sqoop/test/data/UbuntuReleases.java

index f3efa92..f21f588 100644 (file)
@@ -513,4 +513,15 @@ abstract public class DatabaseProvider {
    */
   public void dropDatabase(String databaseName) {
   }
+
+  /**
+   * Different databases handle datetimes/timestamps in different ways.
+   *
+   * This is the type we should use when creating schemas.
+   *
+   * @return A string representing a SQL datatype
+   */
+  public String getDateTimeType() {
+    return "timestamp";
+  }
 }
index 229e8c4..5ae0211 100644 (file)
@@ -116,4 +116,9 @@ public class MySQLProvider extends DatabaseProvider {
   public String escapeValue(String entity) {
     return "\'" + entity + "\'";
   }
+
+  @Override
+  public String getDateTimeType() {
+    return "datetime";
+  }
 }
index b8d037f..b501aec 100644 (file)
@@ -90,4 +90,9 @@ public class SqlServerProvider extends DatabaseProvider {
   public String escape(String entity) {
     return "[" + entity + "]";
   }
+
+  @Override
+  public String getDateTimeType() {
+    return "datetime";
+  }
 }
index 1703397..f2c69bb 100644 (file)
@@ -38,7 +38,7 @@ public class Cities extends DataSet {
       "id",
       "id", "int",
       "country", "varchar(50)",
-      "some_date", "timestamp",
+      "some_date", provider.getDateTimeType(),
       "city", "varchar(50)"
     );
 
index 9b218e9..7b5d9e5 100644 (file)
@@ -41,7 +41,7 @@ public class UbuntuReleases extends DataSet {
       "id", "int",
       "code_name", "varchar(64)",
       "version", "numeric(4,2)",
-      "release_date", "timestamp"
+      "release_date", provider.getDateTimeType()
     );
 
     return this;