You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
signum function incompatible with Postgres and Apache Spark #11557
Comparison of the signum function between DataFusion SQL and Rust
datafusion
rust
spark
postgresql
-1
-1
-1 (-1_i32)
-1
-1
0
1
0 (0_i32)
0
0
+1
1
1 (1_i32)
1
1
-0.0
-1
-1 (-0.0_f32)
0
0
+0.0
1
1 (0.0_f32)
0
0
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
Activity
goldmedal commentedon Jul 20, 2024
take
goldmedal commentedon Jul 20, 2024
I will solve another issue first. I'll take it back if no one else works on it after I finish.
getChan commentedon Jul 20, 2024
take
getChan commentedon Jul 21, 2024
Comparison of the signum function between DataFusion SQL and Rust
-1_i32)0_i32)1_i32)-0.0_f32)0.0_f32)In Rust, the definition of the signum function for floating point types is as follows:
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
1ref) https://github.com/apache/datafusion/blob/main/datafusion/functions/src/macros.rs#L225-L254
implementation
If you have any other opinions, please let me know.
docs: fix signum documentation to say zero returns 0 (apache#24324)
docs: fix signum documentation to say zero returns 0 (apache#24324)