Skip to content

Commit

Permalink
ISSUE-84: the check for column agreement between the dataset and csv was
Browse files Browse the repository at this point in the history
neglecting the synthetically generated columns
  • Loading branch information
ayn leslie committed Oct 22, 2014
1 parent cc8aeee commit 1337755
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.socrata.datasync.job.JobStatus;
import com.socrata.model.importer.Dataset;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.entity.ContentType;
import org.codehaus.jackson.map.ObjectMapper;
Expand Down Expand Up @@ -112,7 +113,8 @@ public static JobStatus validateJobParams(SocrataConnectionInfo connectionInfo,
return noHeaders;
}

JobStatus csvDatasetAgreement = checkColumnAgreement(schema, headers, fileControl.ignoreColumns, publishFile.getName());
Set<String> synthetics = fileControl.syntheticLocations.keySet();
JobStatus csvDatasetAgreement = checkColumnAgreement(schema, headers, synthetics, publishFile.getName());
if (csvDatasetAgreement.isError())
return csvDatasetAgreement;

Expand Down Expand Up @@ -554,10 +556,11 @@ private static String getUnsupportedType(String component, String[] supportedTyp
* @param schema the soda-java Dataset that provides dataset info
* @param headers the columns that will be uploaded; taken from either the file or the control
* file and minus the ignoredColumns
* @param synthetics the synthetic columns that will be generated from the csv
* @param csvFilename the file name, for printing purposes.
* @return
*/
private static JobStatus checkColumnAgreement(Dataset schema, String[] headers, String[] ignoredColumns, String csvFilename) {
private static JobStatus checkColumnAgreement(Dataset schema, String[] headers, Set<String> synthetics, String csvFilename) {

if (schema == null) return JobStatus.VALID;

Expand All @@ -581,9 +584,9 @@ private static JobStatus checkColumnAgreement(Dataset schema, String[] headers,
columnNames.remove(field);
}
}
for (String ignored : ignoredColumns) {
if (columnNames.contains(ignored))
columnNames.remove(ignored);
for (String synth : synthetics) {
if (columnNames.contains(synth))
columnNames.remove(synth);
}
if (columnNames.size() > 0) {
if (rowIdentifier == null) {
Expand Down

0 comments on commit 1337755

Please sign in to comment.