final public void validatePartColumnNames(
Map<String, String> spec, boolean shouldBeFull) throws SemanticException {
List<FieldSchema> partCols = tTable.getPartitionKeys();
if (partCols == null || (partCols.size() == 0)) {
if (spec != null) {
throw new SemanticException("table is not partitioned but partition spec exists: " + spec);
}
return;
} else if (spec == null) {
if (shouldBeFull) {
throw new SemanticException("table is partitioned but partition spec is not specified");
}
return;
}
int columnsFound = 0;
for (FieldSchema fs : partCols) {
if (spec.containsKey(fs.getName())) {
++columnsFound;
}
if (columnsFound == spec.size()) break;
}
if (columnsFound < spec.size()) {
throw new SemanticException("Partition spec " + spec + " contains non-partition columns");
}
if (shouldBeFull && (spec.size() != partCols.size())) {
throw new SemanticException("partition spec " + spec
+ " doesn't contain all (" + partCols.size() + ") partition columns");
}
}