5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-03 06:21:11 +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.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Date; import java.util.Date;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import org.apache.avro.Schema; import org.apache.avro.Schema;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -151,19 +154,15 @@ public String getCreateTableStmt() throws IOException {
sb.append(outputTableName).append("` ( "); sb.append(outputTableName).append("` ( ");
// Check that all explicitly mapped columns are present in result set // Check that all explicitly mapped columns are present in result set
for(Object column : userMapping.keySet()) { final Set<Object> userMappingKeys = new LinkedHashSet<>(userMapping.keySet());
boolean found = false; final List<String> colNamesSet = Arrays.asList(colNames);
for(String c : colNames) {
if (c.equals(column)) {
found = true;
break;
}
}
if (!found) { userMappingKeys.removeAll(colNamesSet);
throw new IllegalArgumentException("No column by the name " + column
+ "found while importing data"); if (!userMappingKeys.isEmpty()) {
} throw new IllegalArgumentException(
"No user mappings found for columns " + userMappingKeys
+ " while importing data");
} }
boolean first = true; boolean first = true;

View File

@ -235,7 +235,7 @@ public void testHiveImportAsParquetWithMapColumnHiveAndOriginalColumnNameFails()
.build(); .build();
expectedException.expect(IllegalArgumentException.class); 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); runImportThrowingException(args);
} }