cecemei commented on code in PR #18250:
URL: https://github.com/apache/druid/pull/18250#discussion_r2216589723
##########
processing/src/main/java/org/apache/druid/query/filter/RangeFilter.java:
##########
@@ -926,10 +950,25 @@ public static DruidDoublePredicate makeDoublePredicate(
return DruidPredicateMatch.of((lowerComparing >= 0) &&
(upperComparing > 0));
};
case CLOSED:
+ if (Double.compare(lowerDoubleBound, upperDoubleBound) == 0) {
+ final long dblBits = Double.doubleToLongBits(lowerDoubleBound);
+ final int fltBits = Float.floatToIntBits((float) lowerDoubleBound);
+
+ return input -> {
+ long inDblBits = Double.doubleToLongBits(input);
+ if (inDblBits == dblBits) {
+ return DruidPredicateMatch.TRUE;
+ }
+ return DruidPredicateMatch.of(
+ Float.floatToIntBits((float) input) == fltBits
+ );
Review Comment:
Comparing `float` and `double` values is a well known challenge due to their
binary representation. The current change appears to be quite limited, it only
addresses scenarios where the upper and lower bounds are exactly equal. But
what about cases where the upper bound is just slightly greater than the lower
bound, such as `new RangeFilter("d0", ColumnType.FLOAT, 120.0244f, 120.0245f,
false, false, null)`?
--
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]