You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2015/04/10 20:35:51 UTC

sqoop git commit: SQOOP-2197: Add concrete DatabaseType to MySQL provider

Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 7d9f6c840 -> 1a23aac29


SQOOP-2197: Add concrete DatabaseType to MySQL provider

(Syed A. Hashmi 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/1a23aac2
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/1a23aac2
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/1a23aac2

Branch: refs/heads/sqoop2
Commit: 1a23aac290b2c16d4d7279c0d3098c60502f1bec
Parents: 7d9f6c8
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Fri Apr 10 11:33:13 2015 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Fri Apr 10 11:33:13 2015 -0700

----------------------------------------------------------------------
 .../sqoop/common/test/db/MySQLProvider.java     |  7 ++
 .../common/test/db/types/MySQLTypeList.java     | 75 ++++++++++++++++++++
 2 files changed, 82 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a23aac2/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
----------------------------------------------------------------------
diff --git a/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java b/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
index 9814ac8..3083ee6 100644
--- a/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
+++ b/common-test/src/main/java/org/apache/sqoop/common/test/db/MySQLProvider.java
@@ -17,6 +17,9 @@
  */
 package org.apache.sqoop.common.test.db;
 
+import org.apache.sqoop.common.test.db.types.DatabaseTypeList;
+import org.apache.sqoop.common.test.db.types.MySQLTypeList;
+
 /**
  * MySQL Provider that will connect to remote MySQL server.
  *
@@ -77,6 +80,10 @@ public class MySQLProvider extends DatabaseProvider {
     return DRIVER;
   }
 
+  @Override
+  public DatabaseTypeList getDatabaseTypes() {
+    return new MySQLTypeList();
+  }
   public String escape(String entity) {
     return "`" + entity + "`";
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a23aac2/common-test/src/main/java/org/apache/sqoop/common/test/db/types/MySQLTypeList.java
----------------------------------------------------------------------
diff --git a/common-test/src/main/java/org/apache/sqoop/common/test/db/types/MySQLTypeList.java b/common-test/src/main/java/org/apache/sqoop/common/test/db/types/MySQLTypeList.java
new file mode 100644
index 0000000..a11872a
--- /dev/null
+++ b/common-test/src/main/java/org/apache/sqoop/common/test/db/types/MySQLTypeList.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sqoop.common.test.db.types;
+
+/**
+ * Minimal tests to avoid NPE in AllTypesTest as TestNG is not handling empty
+ * List.
+ *
+ * Current types and tests are imported from Derby tests. In future will be expanded
+ * to include all supported types.
+ * The list of all datatypes can be found here:
+ * https://dev.mysql.com/doc/refman/5.6/en/data-types.html
+ *
+ */
+public class MySQLTypeList extends DatabaseTypeList{
+
+  public MySQLTypeList() {
+    super();
+
+    // Numeric types
+    add(DatabaseType.builder("SMALLINT")
+        .addExample("-32768", new Integer(-32768), "-32768")
+        .addExample("-1", new Integer(-1), "-1")
+        .addExample("0", new Integer(0), "0")
+        .addExample("1", new Integer(1), "1")
+        .addExample("32767", new Integer(32767), "32767")
+        .build());
+    add(DatabaseType.builder("INT")
+        .addExample("-2147483648", new Integer(-2147483648), "-2147483648")
+        .addExample("-1", new Integer(-1), "-1")
+        .addExample("0", new Integer(0), "0")
+        .addExample("1", new Integer(1), "1")
+        .addExample("2147483647", new Integer(2147483647), "2147483647")
+        .build());
+    add(DatabaseType.builder("BIGINT")
+        .addExample("-9223372036854775808", new Long(-9223372036854775808L), "-9223372036854775808")
+        .addExample("-1", new Long(-1L), "-1")
+        .addExample("0", new Long(0L), "0")
+        .addExample("1", new Long(1L), "1")
+        .addExample("9223372036854775807", new Long(9223372036854775807L), "9223372036854775807")
+        .build());
+
+    // Floating points
+    add(DatabaseType.builder("DOUBLE")
+        .addExample("-1.79769E+308", new Double(-1.79769E+308), "-1.79769E308")
+        .addExample("1.79769E+308", new Double(1.79769E+308), "1.79769E308")
+        .addExample("0", new Double(0), "0.0")
+        .addExample("2.225E-307", new Double(2.225E-307), "2.225E-307")
+        .addExample("-2.225E-307", new Double(-2.225E-307), "-2.225E-307")
+        .build());
+
+    // Boolean
+    add(DatabaseType.builder("BOOLEAN")
+        .addExample("true", Boolean.TRUE, "true")
+        .addExample("false", Boolean.FALSE, "false")
+        .build());
+
+  }
+}