andygrove commented on code in PR #552:
URL: https://github.com/apache/datafusion-comet/pull/552#discussion_r1634870782
##########
core/src/execution/datafusion/expressions/scalar_funcs/chr.rs:
##########
@@ -44,10 +44,18 @@ pub fn chr(args: &[ArrayRef]) -> Result<ArrayRef> {
.iter()
.map(|integer: Option<i64>| {
integer
- .map(|integer| match core::char::from_u32(integer as u32) {
- Some(integer) => Ok(integer.to_string()),
- None => {
- exec_err!("requested character too large for
encoding.")
+ .map(|integer| {
+ let adjusted_integer = if integer >= 0 { integer % 256 }
else { integer };
+
+ match core::char::from_u32(adjusted_integer as u32) {
+ Some(integer) => Ok(integer.to_string()),
+ None => {
+ if integer < 0 {
Review Comment:
nit: could you check for negative integers earlier, before calling
`core::char::from_u32(adjusted_integer as u32)`. If the input is a negative
number then we should not attempt to convert to a char.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]