Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public static String print(TableHeader rowHeader, Map<String, Function<Object, S
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();
Expand Down
4 changes: 4 additions & 0 deletions hudi-cli/src/main/java/org/apache/hudi/cli/TableHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ public String get(int index) {
public int getNumFields() {
return fieldNames.size();
}

public boolean containsField(String fieldName) {
return fieldNames.contains(fieldName);
}
}