Skip to content

Commit

Permalink
returning negative ints as empty string earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhawvipul committed Jun 11, 2024
1 parent ab0655b commit ff10fe3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core/src/execution/datafusion/expressions/scalar_funcs/chr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ pub fn chr(args: &[ArrayRef]) -> Result<ArrayRef> {
.map(|integer: Option<i64>| {
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.")
}
}
})
Expand Down

0 comments on commit ff10fe3

Please sign in to comment.