Record Class ColumnStatTypeSupport

java.lang.Object
java.lang.Record
org.elasticsearch.xpack.esql.datasources.ColumnStatTypeSupport

public record ColumnStatTypeSupport(ColumnStatTypeSupport.StatBlockKind blockKind, boolean harvestable, ColumnStatTypeSupport.StatCoercion coercion) extends Record
The single source of truth for how a column's ESQL DataType participates in the external-source per-column statistics pipeline (harvest, cache classification, warm-path serving, and block construction). Five DataType-keyed switches used to encode this mapping independently and drifted against one another; they now all dispatch on of(DataType).

Three orthogonal facts per type:

  • blockKind — the block flavour a served MIN/MAX extremum is materialized into. null means the type is NOT servable (no buildBlock arm exists); servable() is exactly blockKind != null.
  • harvestable — whether the cold-scan ColumnStatsAccumulator tracks min/max for this type (i.e. the type is "text-pushable"). Text-format warm stats exist for a column ONLY if the accumulator harvested them, so a non-harvestable type can never produce a warm extremum even though it may still be servable (see the WARNING below).
  • coercion — how a stat Number is normalized to the column's resolved type before it is folded/served.

WARNING — the three flags are ORTHOGONAL; do not derive one from another. They carry genuinely independent facts:

  • The counters (COUNTER_LONG/COUNTER_DOUBLE) ARE servable (they carry a blockKind) yet are NOT coercible (coercion == NONE) and NOT harvestable — so servability implies neither coercibility nor harvestability.
  • UNSIGNED_LONG is servable (blockKind == LONG: Parquet sign-flip-encodes its stat into ESQL's wire form via ParquetColumnDecoding#encodeUnsignedLong, exactly as the scan does, so the LONG arm serves the encoded value verbatim — byte-identical to the scan) AND coercible (coercion == EXACT_LONG, which still neutralizes a stale committed extremum that cannot be represented in the resolved type) yet NOT harvestable (the text accumulator never tracks it).
Deriving coercibility from servability (or vice versa) would break the stale-extremum neutralization that UNSIGNED_LONG depends on.
  • Constructor Details

    • ColumnStatTypeSupport

      public ColumnStatTypeSupport(@Nullable ColumnStatTypeSupport.StatBlockKind blockKind, boolean harvestable, ColumnStatTypeSupport.StatCoercion coercion)
      Creates an instance of a ColumnStatTypeSupport record class.
      Parameters:
      blockKind - the value for the blockKind record component
      harvestable - the value for the harvestable record component
      coercion - the value for the coercion record component
  • Method Details

    • servable

      public boolean servable()
      True iff a served MIN/MAX extremum can be materialized into a block for this type (i.e. blockKind != null).
    • of

      @Nullable public static ColumnStatTypeSupport of(DataType type)
      The support record for type, or null if the type does not participate in the external-source per-column statistics pipeline at all (neither servable, harvestable, nor coercible).
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • blockKind

      Returns the value of the blockKind record component.
      Returns:
      the value of the blockKind record component
    • harvestable

      public boolean harvestable()
      Returns the value of the harvestable record component.
      Returns:
      the value of the harvestable record component
    • coercion

      Returns the value of the coercion record component.
      Returns:
      the value of the coercion record component