Skip to content

fix issue where upper and lower functions only work correctly on ascii character #9054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datafusion/physical-expr/src/string_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ pub fn instr<T: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
/// Converts the string to all lower case.
/// lower('TOM') = 'tom'
pub fn lower(args: &[ColumnarValue]) -> Result<ColumnarValue> {
handle(args, |string| string.to_ascii_lowercase(), "lower")
handle(args, |string| string.to_lowercase(), "lower")
}

enum TrimType {
Expand Down Expand Up @@ -555,7 +555,7 @@ where
/// Converts the string to all upper case.
/// upper('tom') = 'TOM'
pub fn upper(args: &[ColumnarValue]) -> Result<ColumnarValue> {
handle(args, |string| string.to_ascii_uppercase(), "upper")
handle(args, |string| string.to_uppercase(), "upper")
}

/// Prints random (v4) uuid values per row
Expand Down
22 changes: 21 additions & 1 deletion datafusion/sqllogictest/test_files/functions.slt
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,20 @@ SELECT upper('foo')
FOO

query T
select upper(arrow_cast('foo', 'Dictionary(Int32, Utf8)'))
SELECT upper(arrow_cast('foo', 'Dictionary(Int32, Utf8)'))
----
FOO

query T
SELECT upper('árvore ação αβγ')
----
ÁRVORE AÇÃO ΑΒΓ

query T
SELECT upper(arrow_cast('árvore ação αβγ', 'Dictionary(Int32, Utf8)'))
----
ÁRVORE AÇÃO ΑΒΓ

query T
SELECT btrim(' foo ')
----
Expand Down Expand Up @@ -672,6 +682,16 @@ SELECT lower(arrow_cast('FOObar', 'Dictionary(Int32, Utf8)'))
----
foobar

query T
SELECT lower('ÁRVORE AÇÃO ΑΒΓ')
----
árvore ação αβγ

query T
SELECT lower(arrow_cast('ÁRVORE AÇÃO ΑΒΓ', 'Dictionary(Int32, Utf8)'))
----
árvore ação αβγ

query T
SELECT ltrim(' foo')
----
Expand Down