alamb commented on code in PR #17131: URL: https://github.com/apache/datafusion/pull/17131#discussion_r2270677545
########## datafusion/functions/src/string/chr.rs: ########## @@ -47,22 +47,14 @@ pub fn chr(args: &[ArrayRef]) -> Result<ArrayRef> { for integer in integer_array { match integer { Some(integer) => { - if integer == 0 { - return exec_err!("null character not permitted."); - } else if integer < 0 { - return exec_err!("negative input not permitted."); - } else { - match core::char::from_u32(integer as u32) { - Some(c) => { - builder.append_value(c.encode_utf8(&mut buf)); - } - None => { - return exec_err!( - "requested character too large for encoding." - ); - } + if integer >= 0 && integer <= u32::MAX as i64 { Review Comment: I think you can probably express this more succiently using try_from Something like ```suggestion let Ok(integer) = u32::try_from(integer) else { return exec_err!("invalid Unicode scalar value: {integer}"); } ``` But I don't think it is necessary -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org