mapleFU opened a new issue, #1415:
URL: https://github.com/apache/iceberg-rust/issues/1415

   ### Apache Iceberg Rust version
   
   None
   
   ### Describe the bug
   
   OrderedFloat[1] says:
   
   > All NaN values are considered equal, even though they may have different 
[bits](https://doc.rust-lang.org/std/primitive.f64.html#method.to_bits), and 
therefore different 
[sign](https://doc.rust-lang.org/std/primitive.f64.html#method.is_sign_positive),
 signaling/quiet status, and NaN payload bits.
   
   And iceberg[2] requires:
   
   > Sorting floating-point numbers should produce the following behavior: -NaN 
< -Infinity < -value < -0 < 0 < value < Infinity < NaN. This aligns with the 
implementation of Java floating-point types comparisons.
   
   [1] 
https://docs.rs/ordered-float/latest/ordered_float/struct.OrderedFloat.html
   [2] https://iceberg.apache.org/spec/#sorting
   
   ### To Reproduce
   
   ```rust
   use ordered_float::OrderedFloat;
   use std::f64::{NAN, NEG_INFINITY};
   
   fn main() {
       // 创建 NAN 和 -NAN
       let nan = NAN;
       let neg_nan = -NAN;
       
       println!("原始浮点数比较:");
       println!("NAN == NAN: {}", nan == nan);
       println!("NAN == -NAN: {}", nan == neg_nan);
       println!("-NAN == -NAN: {}", neg_nan == neg_nan);
       println!();
       
       // 使用 OrderedFloat 包装
       let ordered_nan = OrderedFloat(nan);
       let ordered_neg_nan = OrderedFloat(neg_nan);
       
       println!("OrderedFloat 比较:");
       println!("OrderedFloat(NAN) == OrderedFloat(NAN): {}", ordered_nan == 
ordered_nan);
       println!("OrderedFloat(NAN) == OrderedFloat(-NAN): {}", ordered_nan == 
ordered_neg_nan);
       println!("OrderedFloat(-NAN) == OrderedFloat(-NAN): {}", ordered_neg_nan 
== ordered_neg_nan);
       println!();
   }
   ```
   
   output:
   
   ```
   原始浮点数比较:
   NAN == NAN: false
   NAN == -NAN: false
   -NAN == -NAN: false
   
   OrderedFloat 比较:
   OrderedFloat(NAN) == OrderedFloat(NAN): true
   OrderedFloat(NAN) == OrderedFloat(-NAN): true
   OrderedFloat(-NAN) == OrderedFloat(-NAN): true
   ```
   
   ### Expected behavior
   
   -NAN < NAN
   
   ### Willingness to contribute
   
   None


-- 
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: issues-unsubscr...@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to