mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 18:42:47 +08:00
Merge 9df7a8ef43
into f8beae32a0
This commit is contained in:
commit
a9fd6c9f60
@ -21,14 +21,17 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Date;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -151,19 +154,15 @@ public String getCreateTableStmt() throws IOException {
|
||||
sb.append(outputTableName).append("` ( ");
|
||||
|
||||
// Check that all explicitly mapped columns are present in result set
|
||||
for(Object column : userMapping.keySet()) {
|
||||
boolean found = false;
|
||||
for(String c : colNames) {
|
||||
if (c.equals(column)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final Set<Object> userMappingKeys = new LinkedHashSet<>(userMapping.keySet());
|
||||
final List<String> colNamesSet = Arrays.asList(colNames);
|
||||
|
||||
if (!found) {
|
||||
throw new IllegalArgumentException("No column by the name " + column
|
||||
+ "found while importing data");
|
||||
}
|
||||
userMappingKeys.removeAll(colNamesSet);
|
||||
|
||||
if (!userMappingKeys.isEmpty()) {
|
||||
throw new IllegalArgumentException(
|
||||
"No user mappings found for columns " + userMappingKeys
|
||||
+ " while importing data");
|
||||
}
|
||||
|
||||
boolean first = true;
|
||||
|
@ -235,7 +235,7 @@ public void testHiveImportAsParquetWithMapColumnHiveAndOriginalColumnNameFails()
|
||||
.build();
|
||||
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
expectedException.expectMessage("No column by the name C2#INTEGERfound while importing data");
|
||||
expectedException.expectMessage("No user mappings found for columns [C2#INTEGER] while importing data");
|
||||
|
||||
runImportThrowingException(args);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user