5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-21 11:21:39 +08:00

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

(Nick White via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2013-01-15 04:15:30 -08:00
parent 79f941b7e1
commit 2b0456d6ce
2 changed files with 27 additions and 4 deletions

View File

@ -443,8 +443,8 @@ private String rpcSetterForType(String javaType, String outputObj,
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 void generate() throws IOException {
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);
}
}
}

View File

@ -465,4 +465,24 @@ public void testUserMapping() throws IOException, ClassNotFoundException,
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");
}
}