sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-829: Error Messages For --map-column-java Should Be More Useful
Date Tue, 15 Jan 2013 12:27:05 GMT
Updated Branches:
  refs/heads/trunk 79f941b7e -> 2b0456d6c


SQOOP-829: Error Messages For --map-column-java Should Be More Useful

(Nick White 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/2b0456d6
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/2b0456d6
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/2b0456d6

Branch: refs/heads/trunk
Commit: 2b0456d6ce4b1e20bdd292c992efe231965372ae
Parents: 79f941b
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Jan 15 04:15:30 2013 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Jan 15 04:15:30 2013 -0800

----------------------------------------------------------------------
 src/java/org/apache/sqoop/orm/ClassWriter.java     |   11 +++++---
 .../com/cloudera/sqoop/orm/TestClassWriter.java    |   20 +++++++++++++++
 2 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/2b0456d6/src/java/org/apache/sqoop/orm/ClassWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/orm/ClassWriter.java b/src/java/org/apache/sqoop/orm/ClassWriter.java
index b73711e..47e1221 100644
--- a/src/java/org/apache/sqoop/orm/ClassWriter.java
+++ b/src/java/org/apache/sqoop/orm/ClassWriter.java
@@ -443,8 +443,8 @@ public class ClassWriter {
       return "    " + LobSerializer.class.getCanonicalName()
           + ".writeBlob(this." + colName + ", " + outputObj + ");\n";
     } else {
-      LOG.error("No ResultSet method for Java type " + javaType);
-      return null;
+      throw new IllegalArgumentException(
+          "No ResultSet method for Java type " + javaType);
     }
   }
 
@@ -1101,8 +1101,11 @@ public class ClassWriter {
     if (mapping != null && !mapping.isEmpty()) {
       for(Object column : mapping.keySet()) {
         if (!uniqColNames.contains((String)column)) {
-        throw new IllegalArgumentException("No column by the name " + column
-                + "found while importing data");
+        throw new IllegalArgumentException(
+            "No column by the name "
+            + column
+            + "found while importing data; expecting one of "
+            + uniqColNames);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/2b0456d6/src/test/com/cloudera/sqoop/orm/TestClassWriter.java
----------------------------------------------------------------------
diff --git a/src/test/com/cloudera/sqoop/orm/TestClassWriter.java b/src/test/com/cloudera/sqoop/orm/TestClassWriter.java
index a10b5ae..3b77571 100644
--- a/src/test/com/cloudera/sqoop/orm/TestClassWriter.java
+++ b/src/test/com/cloudera/sqoop/orm/TestClassWriter.java
@@ -465,4 +465,24 @@ public class TestClassWriter extends TestCase {
       ClassLoaderStack.setCurrentClassLoader(prevClassLoader);
     }
   }
+
+  @Test
+  public void testBrokenUserMapping() throws Exception {
+
+    String [] argv = {
+        "--bindir", JAR_GEN_DIR,
+        "--outdir", CODE_GEN_DIR,
+        "--class-name", USERMAPPING_CLASS_AND_PACKAGE_NAME,
+        "--map-column-java", "INTFIELD1=NotARealClass",
+    };
+
+    try {
+      runGenerationTest(
+        argv,
+        USERMAPPING_CLASS_AND_PACKAGE_NAME);
+    } catch(IllegalArgumentException e) {
+      return;
+    }
+    fail("we shouldn't successfully generate code");
+  }
 }


Mime
View raw message