Class StatValueComparator
java.lang.Object
org.elasticsearch.xpack.esql.datasources.StatValueComparator
Type-normalizing comparator for column-statistic values (min/max) against query literals.
Source plugins box an INT column's min/max with whatever Java width their reader exposes
(ORC's IntegerColumnStatistics.getMinimum() returns long, so the value
autoboxes to Long; parquet-mr returns int, so it boxes to Integer).
The ES|QL parser, meanwhile, fits small integer literals to Integer. A raw
Comparable.compareTo between two different boxed numeric types throws
ClassCastException (e.g. Long.compareTo(Integer)), so the planner must
normalize types before comparing rather than relying on each source plugin to box stats
in a planner-expected width.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intReturned bycompare(Object, Object)when the two values cannot be meaningfully compared (null operand, or differing non-numeric runtime types). -
Method Summary
Modifier and TypeMethodDescriptionstatic intCompares two stat/literal values, returning negative, zero, or positive as withComparable.compareTo(T), orINCOMPARABLEwhen the values are not comparable (type mismatch or null).
-
Field Details
-
INCOMPARABLE
public static final int INCOMPARABLEReturned bycompare(Object, Object)when the two values cannot be meaningfully compared (null operand, or differing non-numeric runtime types). Callers must treat this as "unknown" and fall back to a conservative decision rather than acting on the value.- See Also:
-
-
Method Details
-
compare
Compares two stat/literal values, returning negative, zero, or positive as withComparable.compareTo(T), orINCOMPARABLEwhen the values are not comparable (type mismatch or null). Uses exact long comparison for integral types to avoid double precision loss, and widens to double for mixed integral/floating comparisons.
-