1
0

[HUDI-362] Adds a check for the existence of field (#1047)

This commit is contained in:
hongdd
2019-11-26 03:31:07 +08:00
committed by vinoth chandar
parent 845a0509b3
commit 44823041a3
2 changed files with 8 additions and 0 deletions

View File

@@ -59,6 +59,10 @@ public class HoodiePrintHelper {
return HoodiePrintHelper.print(rowHeader);
}
if (!sortByField.isEmpty() && !rowHeader.containsField(sortByField)) {
return String.format("Field[%s] is not in table, given columns[%s]", sortByField, rowHeader.getFieldNames());
}
Table table =
new Table(rowHeader, fieldNameToConverterMap, Option.ofNullable(sortByField.isEmpty() ? null : sortByField),
Option.ofNullable(isDescending), Option.ofNullable(limit <= 0 ? null : limit)).addAllRows(rows).flip();

View File

@@ -68,4 +68,8 @@ public class TableHeader {
public int getNumFields() {
return fieldNames.size();
}
public boolean containsField(String fieldName) {
return fieldNames.contains(fieldName);
}
}