diff --git a/fe/fe-core/src/main/java/com/starrocks/server/OlapTableFactory.java b/fe/fe-core/src/main/java/com/starrocks/server/OlapTableFactory.java index ad21d6c7f819b7..187f171f3d848e 100644 --- a/fe/fe-core/src/main/java/com/starrocks/server/OlapTableFactory.java +++ b/fe/fe-core/src/main/java/com/starrocks/server/OlapTableFactory.java @@ -81,6 +81,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.IntStream; import javax.validation.constraints.NotNull; public class OlapTableFactory implements AbstractTableFactory { @@ -179,7 +180,9 @@ public Table createTable(LocalMetastore metastore, Database db, CreateTableStmt Set addedSortKey = new HashSet<>(); List baseSchemaNames = baseSchema.stream().map(Column::getName).collect(Collectors.toList()); for (String column : stmt.getSortKeys()) { - int idx = baseSchemaNames.indexOf(column); + int idx = IntStream.range(0, baseSchemaNames.size()) + .filter(i -> baseSchemaNames.get(i).equalsIgnoreCase(column)) + .findFirst().orElse(-1); if (idx == -1) { throw new DdlException("Invalid column '" + column + "': not exists in all columns."); }