getChan commented on issue #11557: URL: https://github.com/apache/datafusion/issues/11557#issuecomment-2241473321
Comparison of the signum function between DataFusion SQL and Rust | | datafusion | rust | | ---- | ---------- | --------------- | | -1 | -1 | -1 (`-1_i32`) | | 0 | 1 | 0 (`0_i32`) | | +1 | 1 | 1 (`1_i32`) | | -0.0 | -1 | -1 (`-0.0_f32`) | | +0.0 | 1 | 1 (`0.0_f32`) | In Rust, the definition of the signum function for floating point types is as follows: > Returns a number that represents the sign of self. > - 1.0 if the number is positive, +0.0 or INFINITY > - -1.0 if the number is negative, -0.0 or NEG_INFINITY > - NaN if the number is NaN My guess is that the implementation of the signum function in DataFusion only accepts floating point types as input. Consequently, if it receives 0 as input, it appears to convert it to Rust’s 0.0 and output `1` ref) https://github.com/apache/datafusion/blob/main/datafusion/functions/src/macros.rs#L225-L254 -- 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]
