Class NumericAggregateInput

java.lang.Object
dev.frostlake.functions.aggregate.NumericAggregateInput

public final class NumericAggregateInput extends Object
One value on its way INTO a numeric aggregate, converted the way live converts it — which for text that is not a number means a refusal, not a zero.
   SUM / AVG / MEDIAN / PERCENTILE_CONT / PERCENTILE_DISC / STDDEV / VARIANCE over 'a'
       Numeric value 'a' is not recognized
   SUM over a VARIANT holding "a"
       Failed to cast variant value "a" to REAL
 

★ NEITHER SENTENCE CARRIES A COMPILATION PREFIX, which is the tell that this is the CONVERSION failing as the rows are read rather than the plan being rejected. It follows that an empty group is never refused, and that a value the column merely COULD hold is not enough — the rule is per value.

★ THE VALUE NAMED IS THE FIRST IN SCAN ORDER, even for the aggregates that sort. Over a column holding 'z' then 'a' every one of them names 'z'; written the other way round they all name 'a'. So the conversion happens as the rows arrive, before any ordering, which is why this is called from the accumulating loop and not from a comparator.

★ THE CONVERSION ITSELF IS THE ORDINARY ONE. Surrounding spaces are trimmed and an exponent is read, so ' 2 ' and '1e2' are 2 and 100; an EMPTY string and a lone sign are not numbers and are refused like any other text.

★ WHAT IS DELIBERATELY NOT REFUSED HERE: a BOOLEAN or a DATE argument, which live rejects at COMPILE time in the function's own vocabulary — a different surface, and giving it this sentence would be inventing one. Inside a VARIANT a boolean IS converted, to 1 and 0.

MIN, MAX, COUNT, MODE and ARRAY_AGG never come here: they hand back an input rather than computing over it, and live answers all five over text.

  • Method Details

    • asDouble

      public static double asDouble(Object value)
      One aggregated value as a double, refusing text that is not a number.
      Parameters:
      value - the value, never null
      Returns:
      its double value
    • requireNumeric

      public static void requireNumeric(Object value)
      Read a value for its side effect only — the refusal. PERCENTILE_DISC hands back one of its inputs unconverted, but live still refuses a set it cannot order numerically, so every value is put through the conversion in scan order and the result thrown away.
      Parameters:
      value - the value, never null