andygrove commented on code in PR #23766:
URL: https://github.com/apache/datafusion/pull/23766#discussion_r3650307726
##########
datafusion/spark/src/function/math/hex.rs:
##########
@@ -233,7 +184,7 @@ fn hex_encode_int64(
for v in iter {
if let Some(num) = v {
let mut temp = [0u8; 16];
- let slice = hex_int64(num, &mut temp);
+ let slice = encode_u64(num as u64, HexCase::Upper, &mut temp);
Review Comment:
Negative input still works — the `u64` here is the two's-complement bit
pattern, not a range restriction.
`num as u64` on an `i64` reinterprets the bits rather than saturating, so
`-2` becomes `0xFFFFFFFFFFFFFFFE` and prints as `FFFFFFFFFFFFFFFE`, matching
the Spark output you posted. This is the same cast the previous `hex_int64`
did, so behaviour is unchanged by this PR — only the digit-writing loop moved.
`test_hex_int64` already pins it, and still passes:
```rust
(i64::MAX, "7FFFFFFFFFFFFFFF"),
(i64::MIN, "8000000000000000"),
(-1, "FFFFFFFFFFFFFFFF"),
```
The `i64::MIN` and `-1` cases are the interesting ones: they only produce
those strings if the full 64-bit pattern survives the cast.
--
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]