Skip to content

Commit f2a0adf

Browse files
[fix](fe) Inconsistent behavior for string comparison in FE and BE (#13604)
1 parent 6f3db8b commit f2a0adf

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

fe/fe-core/src/main/java/org/apache/doris/analysis/StringLiteral.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public int compareLiteral(LiteralExpr expr) {
9696
int minLength = Math.min(thisBytes.length, otherBytes.length);
9797
int i = 0;
9898
for (i = 0; i < minLength; i++) {
99-
if (thisBytes[i] < otherBytes[i]) {
99+
if (Byte.toUnsignedInt(thisBytes[i]) < Byte.toUnsignedInt(otherBytes[i])) {
100100
return -1;
101-
} else if (thisBytes[i] > otherBytes[i]) {
101+
} else if (Byte.toUnsignedInt(thisBytes[i]) > Byte.toUnsignedInt(otherBytes[i])) {
102102
return 1;
103103
}
104104
}

regression-test/data/query_p0/sort/sort.out

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
2022-01-01 1
88
汇总 1
99

10+
-- !sort_string_on_fe --
11+
true
12+

regression-test/suites/query_p0/sort/sort.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
suite("sort") {
2323
qt_sort_string_single_column """ select * from ( select '汇总' as a union all select '2022-01-01' as a ) a order by 1 """
2424
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 """
25+
qt_sort_string_on_fe """ select '汇总' > '2022-01-01' """
2526
}

0 commit comments

Comments
 (0)