in c3r-sdk-core/src/main/java/com/amazonaws/c3r/config/TableSchema.java [72:111]
public void validate() {
// Make sure we actually have a schema
if (headerRow == null && getColumns() == null) {
throw new C3rIllegalArgumentException("Schema was not initialized.");
}
// Check that headerRow is valid
if (headerRow == null) {
throw new C3rIllegalArgumentException("Schema must specify whether or not data has a header row.");
}
// Validate column information now that schema is complete
final var columns = getColumns();
if (columns == null || columns.isEmpty()) {
throw new C3rIllegalArgumentException("At least one data column must provided in the config file.");
}
if (columns.size() > Limits.ENCRYPTED_OUTPUT_COLUMN_COUNT_MAX) {
throw new C3rIllegalArgumentException(
"An encrypted table can have at most "
+ Limits.ENCRYPTED_OUTPUT_COLUMN_COUNT_MAX
+ " columns "
+ " but this schema specifies "
+ getColumns().size()
+ ".");
}
// Verify we have no duplicate target column headers
// NOTE: target column headers must have already been normalized when checking for duplicates here
// to ensure we don't get different column headers than end up being the same post-normalization.
final Set<ColumnHeader> duplicateTargets = getColumns().stream()
.collect(Collectors.groupingBy(ColumnSchema::getTargetHeader)).entrySet()
.stream().filter(e -> e.getValue().size() > 1)
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
if (!duplicateTargets.isEmpty()) {
final String duplicates = duplicateTargets.stream().map(ColumnHeader::toString)
.collect(Collectors.joining(", "));
throw new C3rIllegalArgumentException("Target header name can only be used once. Duplicates found: " + duplicates);
}
}