@@ -166,36 +166,16 @@ impl<'de> Deserialize<'de> for Datum {
166166
167167// Compare following iceberg float ordering rules:
168168// -NaN < -Infinity < -value < -0 < 0 < value < Infinity < NaN
169- fn iceberg_float_cmp < T : Float > ( a : T , b : T ) -> Option < Ordering > {
170- if a. is_nan ( ) && b. is_nan ( ) {
171- return match ( a. is_sign_negative ( ) , b. is_sign_negative ( ) ) {
172- ( true , false ) => Some ( Ordering :: Less ) ,
173- ( false , true ) => Some ( Ordering :: Greater ) ,
174- _ => Some ( Ordering :: Equal ) ,
175- } ;
176- }
177-
178- if a. is_nan ( ) {
179- return Some ( if a. is_sign_negative ( ) {
180- Ordering :: Less
181- } else {
182- Ordering :: Greater
183- } ) ;
184- }
185-
186- if b. is_nan ( ) {
187- return Some ( if b. is_sign_negative ( ) {
188- Ordering :: Greater
189- } else {
190- Ordering :: Less
191- } ) ;
192- }
169+ fn iceberg_float_cmp_f32 ( a : OrderedFloat < f32 > , b : OrderedFloat < f32 > ) -> Option < Ordering > {
170+ Some ( a. total_cmp ( & b) )
171+ }
193172
194- a. partial_cmp ( & b)
173+ fn iceberg_float_cmp_f64 ( a : OrderedFloat < f64 > , b : OrderedFloat < f64 > ) -> Option < Ordering > {
174+ Some ( a. total_cmp ( & b) )
195175}
196176
197177impl PartialOrd for Datum {
198- fn partial_cmp ( & self , other : & Self ) -> Option < std :: cmp :: Ordering > {
178+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
199179 match ( & self . literal , & other. literal , & self . r#type , & other. r#type ) {
200180 // generate the arm with same type and same literal
201181 (
@@ -221,13 +201,13 @@ impl PartialOrd for Datum {
221201 PrimitiveLiteral :: Float ( other_val) ,
222202 PrimitiveType :: Float ,
223203 PrimitiveType :: Float ,
224- ) => iceberg_float_cmp ( * val, * other_val) ,
204+ ) => iceberg_float_cmp_f32 ( * val, * other_val) ,
225205 (
226206 PrimitiveLiteral :: Double ( val) ,
227207 PrimitiveLiteral :: Double ( other_val) ,
228208 PrimitiveType :: Double ,
229209 PrimitiveType :: Double ,
230- ) => iceberg_float_cmp ( * val, * other_val) ,
210+ ) => iceberg_float_cmp_f64 ( * val, * other_val) ,
231211 (
232212 PrimitiveLiteral :: Int ( val) ,
233213 PrimitiveLiteral :: Int ( other_val) ,
0 commit comments