[HUDI-362] Adds a check for the existence of field (#1047)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -68,4 +68,8 @@ public class TableHeader {
|
||||
public int getNumFields() {
|
||||
return fieldNames.size();
|
||||
}
|
||||
|
||||
public boolean containsField(String fieldName) {
|
||||
return fieldNames.contains(fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user