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/09/16 14:28:55 UTC

sqoop git commit: SQOOP-2572: MODEL_004:Usage of unsupported data type when using DateTime type

Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 00ada83b7 -> df6d5cb9a


SQOOP-2572: MODEL_004:Usage of unsupported data type when using DateTime type

(Dian Fu 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/df6d5cb9
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/df6d5cb9
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/df6d5cb9

Branch: refs/heads/sqoop2
Commit: df6d5cb9ad5d6be31a12f3c8683576e3f298a9e8
Parents: 00ada83
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Wed Sep 16 05:28:20 2015 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Wed Sep 16 05:28:20 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/sqoop/model/ConfigUtils.java     | 12 ++++++++++--
 .../java/org/apache/sqoop/model/TestConfigUtils.java | 15 +++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/df6d5cb9/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
index cf48425..282a024 100644
--- a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
@@ -453,7 +453,11 @@ public class  ConfigUtils {
             jsonConfig.put(inputName, value.toString());
           } else if(type == Boolean.class) {
             jsonConfig.put(inputName, value);
-          }else {
+          } else if (type.isAssignableFrom(List.class)) {
+            jsonConfig.put(inputName, value);
+          } else if (type.isAssignableFrom(DateTime.class) ) {
+            jsonConfig.put(inputName, ((DateTime) value).getMillis());
+          } else {
             throw new SqoopException(ModelError.MODEL_004,
               "Unsupported type " + type.getName() + " for input " + configName + "." + inputName);
           }
@@ -548,7 +552,11 @@ public class  ConfigUtils {
             inputField.set(configValue, Enum.valueOf((Class<? extends Enum>) inputField.getType(), (String) jsonInputs.get(inputName)));
           } else if(type == Boolean.class) {
             inputField.set(configValue, (Boolean) jsonInputs.get(inputName));
-          }else {
+          } else if (type.isAssignableFrom(List.class)) {
+            inputField.set(configValue, (List)jsonInputs.get(inputName));
+          } else if (type.isAssignableFrom(DateTime.class)) {
+            inputField.set(configValue, new DateTime((long)jsonInputs.get(inputName)));
+          } else {
             throw new SqoopException(ModelError.MODEL_004,
               "Unsupported type " + type.getName() + " for input " + configName + "." + inputName);
           }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/df6d5cb9/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
index 61599d5..7052841 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
@@ -23,6 +23,8 @@ import org.testng.annotations.Test;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
+
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -30,6 +32,7 @@ import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.sqoop.common.SqoopException;
+import org.joda.time.DateTime;
 
 /**
  * Test config utils
@@ -183,6 +186,8 @@ public class TestConfigUtils {
     config.cConfig.longValue = 4L;
     config.cConfig.map.put("C", "D");
     config.cConfig.enumeration = Enumeration.X;
+    config.cConfig.list.addAll(Arrays.asList("E", "F"));
+    config.cConfig.dt = new DateTime(10000);
 
     String json = ConfigUtils.toJson(config);
 
@@ -207,6 +212,9 @@ public class TestConfigUtils {
     assertTrue(targetConfig.cConfig.map.containsKey("C"));
     assertEquals("D", targetConfig.cConfig.map.get("C"));
     assertEquals(Enumeration.X, targetConfig.cConfig.enumeration);
+    assertEquals("E", targetConfig.cConfig.list.get(0));
+    assertEquals("F", targetConfig.cConfig.list.get(1));
+    assertEquals(10000, targetConfig.cConfig.dt.getMillis());
   }
 
   /**
@@ -240,6 +248,8 @@ public class TestConfigUtils {
     inputs.add(new MMapInput("cConfig.map", false, InputEditable.ANY, StringUtils.EMPTY));
     inputs.add(new MEnumInput("cConfig.enumeration", false, InputEditable.ANY, StringUtils.EMPTY,
         new String[] { "X", "Y" }));
+    inputs.add(new MListInput("cConfig.list", false, InputEditable.ANY, StringUtils.EMPTY));
+    inputs.add(new MDateTimeInput("cConfig.dt", false, InputEditable.ANY, StringUtils.EMPTY));
     ret.add(new MConfig("cConfig", inputs));
 
     return ret;
@@ -421,9 +431,14 @@ public class TestConfigUtils {
     Map<String, String> map;
     @Input
     Enumeration enumeration;
+    @Input
+    List<String> list;
+    @Input
+    DateTime dt;
 
     public CConfig() {
       map = new HashMap<String, String>();
+      list = new LinkedList<String>();
     }
   }