Expand description
Float semantics for DataFusion.
Arrow’s comparison kernels work on the bit pattern of a float,
i.e. IEEE 754 totalOrder. DataFusion deviates from that in one
respect: +0.0 and -0.0 are equal, hash the same and fall into the same
group. See normalize_float, normalize_floats and
ScalarValue::normalize. Ordering still follows totalOrder, so
compare_floats sorts -0.0 before +0.0.
Every comparison, hash or grouping boundary should be built from these helpers rather than inspecting float bits itself:
- Equality and grouping: normalize first (
normalize_float,normalize_floats,ScalarValue::normalize), then compare bits or call Arrow’seq,RowConverterormake_comparator. Hashhash_input. - Ordering: use
compare_floats,float_ltorfloat_gt. Sorting does not normalize yet, so-0.0still sorts before+0.0.
Traits§
- Float
Semantics - The floating point types the functions in this module are defined for:
f16,f32andf64.
Functions§
- compare_
floats - Compares two values in the order DataFusion sorts them.
- float_
gt - Whether
leftsorts afterright, the same ascompare_floats(left, right).is_gt(). - float_
lt - Whether
leftsorts beforeright, the same ascompare_floats(left, right).is_lt(). - has_
float_ leaf - Whether
data_typeis a float or contains a float at any depth of its nested children. - hash_
input - The value that DataFusion hashes in place of a float. Values that DataFusion
treats as equal hash the same, so this is the value
normalize_floatreturns. - normalize_
float -0.0becomes0.0, so two values that DataFusion treats as equal also have the same bits. All other values, including NaN payloads, are kept as they are.- normalize_
floats - Applies
normalize_floatto every float inarray, including floats nested inside lists, structs, maps, unions, dictionaries and run-end encoded arrays. Arrays without floats are returned unchanged.