From 4b34b731e2bd174c1165da1ce24ef1670b159378 Mon Sep 17 00:00:00 2001 From: meegoo Date: Fri, 1 Nov 2024 06:04:56 +0800 Subject: [PATCH] [BugFix] Fix create table use order by case sensitive Signed-off-by: meegoo --- .../src/main/java/com/starrocks/server/OlapTableFactory.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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."); }