diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java index 3a6dcd6094..9761a43725 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java @@ -96,9 +96,9 @@ public class StringLiteral extends LiteralExpr { int minLength = Math.min(thisBytes.length, otherBytes.length); int i = 0; for (i = 0; i < minLength; i++) { - if (thisBytes[i] < otherBytes[i]) { + if (Byte.toUnsignedInt(thisBytes[i]) < Byte.toUnsignedInt(otherBytes[i])) { return -1; - } else if (thisBytes[i] > otherBytes[i]) { + } else if (Byte.toUnsignedInt(thisBytes[i]) > Byte.toUnsignedInt(otherBytes[i])) { return 1; } } diff --git a/regression-test/data/query_p0/sort/sort.out b/regression-test/data/query_p0/sort/sort.out index b4a5c9ee01..4e898a3f62 100644 --- a/regression-test/data/query_p0/sort/sort.out +++ b/regression-test/data/query_p0/sort/sort.out @@ -7,3 +7,6 @@ 2022-01-01 1 汇总 1 +-- !sort_string_on_fe -- +true + diff --git a/regression-test/suites/query_p0/sort/sort.groovy b/regression-test/suites/query_p0/sort/sort.groovy index b967c93137..2d41adf192 100644 --- a/regression-test/suites/query_p0/sort/sort.groovy +++ b/regression-test/suites/query_p0/sort/sort.groovy @@ -22,4 +22,5 @@ suite("sort") { qt_sort_string_single_column """ select * from ( select '汇总' as a union all select '2022-01-01' as a ) a order by 1 """ qt_sort_string_multiple_columns """ select * from ( select '汇总' as a,1 as b union all select '2022-01-01' as a,1 as b ) a order by 1,2 """ + qt_sort_string_on_fe """ select '汇总' > '2022-01-01' """ }