5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-02 18:42:47 +08:00
This commit is contained in:
belugabehr 2021-03-17 22:31:25 +08:00 committed by GitHub
commit a9fd6c9f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 13 deletions

View File

@ -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;

View File

@ -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);
}