diff --git a/core/src/execution/datafusion/expressions/scalar_funcs/chr.rs b/core/src/execution/datafusion/expressions/scalar_funcs/chr.rs index 6bd64c1cd..24f5aa5fd 100644 --- a/core/src/execution/datafusion/expressions/scalar_funcs/chr.rs +++ b/core/src/execution/datafusion/expressions/scalar_funcs/chr.rs @@ -45,16 +45,14 @@ pub fn chr(args: &[ArrayRef]) -> Result { .map(|integer: Option| { integer .map(|integer| { + if integer < 0 { + return Ok("".to_string()); // Return empty string for negative integers + } let adjusted_integer = if integer >= 0 { integer % 256 } else { integer }; - match core::char::from_u32(adjusted_integer as u32) { Some(ch) => Ok(ch.to_string()), None => { - if integer < 0 { - Ok("".to_string()) - } else { - exec_err!("requested character not compatible for encoding.") - } + exec_err!("requested character not compatible for encoding.") } } })