andygrove commented on code in PR #552:
URL: https://github.com/apache/datafusion-comet/pull/552#discussion_r1635460614
##########
core/src/execution/datafusion/expressions/scalar_funcs/chr.rs:
##########
@@ -44,10 +44,16 @@ 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| {
+ 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) {
Review Comment:
nit: I think you can make the same optimization here that you did for the
scalar case
```suggestion
match core::char::from_u32((integer % 256) as u32) {
```
--
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]