[fix](fe) Inconsistent behavior for string comparison in FE and BE (#13604)

This commit is contained in:
xueweizhang
2022-11-02 15:32:13 +08:00
committed by GitHub
parent 6f3db8b4b4
commit f2a0adf34e
3 changed files with 6 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -7,3 +7,6 @@
2022-01-01 1
汇总 1
-- !sort_string_on_fe --
true

View File

@ -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' """
}