Class StatValueComparator

java.lang.Object
org.elasticsearch.xpack.esql.datasources.StatValueComparator

public final class StatValueComparator extends Object
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 Details

    • INCOMPARABLE

      public static final int INCOMPARABLE
      Returned by compare(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

      public static int compare(Object a, Object b)
      Compares two stat/literal values, returning negative, zero, or positive as with Comparable.compareTo(T), or INCOMPARABLE when 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.