java.lang.Object
java.lang.Enum<FunctionType>
org.elasticsearch.xpack.esql.expression.promql.function.FunctionType
All Implemented Interfaces:
Serializable, Comparable<FunctionType>, Constable

public enum FunctionType extends Enum<FunctionType>
Classifies PromQL functions by their input vector type and aggregation behavior.

This classification is independent of how the function is transformed to ESQL.

  • Enum Constant Details

    • WITHIN_SERIES_AGGREGATION

      public static final FunctionType WITHIN_SERIES_AGGREGATION
      Aggregates data within each time series over a time window.

      Input: Range vector (multiple samples per series over time range)
      Output: Instant vector (one aggregated value per series)
      Grouping: Implicit by time series (_tsid)

      Examples:

      • Rate functions: rate(), irate(), increase(), delta(), idelta()
      • Aggregations: avg_over_time(), sum_over_time(), max_over_time(), min_over_time(), count_over_time()
      • Selection: first_over_time(), last_over_time()
      • Presence: present_over_time(), absent_over_time()
    • ACROSS_SERIES_AGGREGATION

      public static final FunctionType ACROSS_SERIES_AGGREGATION
      Aggregates data across multiple time series at a single point in time.

      Input: Instant vector (one sample per series at evaluation time)
      Output: Instant vector (aggregated across series)
      Grouping: Explicit by labels (by/without)

      Examples:

      • Basic: sum(), avg(), max(), min(), count()
      • Statistical: stddev(), stdvar(), quantile()
      • Top-k: topk(), bottomk()
      • Grouping: group(), count_values()
    • VALUE_TRANSFORMATION

      public static final FunctionType VALUE_TRANSFORMATION
      Transforms each sample in a vector independently (element-wise operations).

      Input: Instant vector
      Output: Instant vector (same cardinality, transformed values)

      Examples:

      • Math: abs(), ceil(), floor(), round(), sqrt(), exp(), ln(), log2(), log10()
      • Trigonometric: sin(), cos(), tan(), asin(), acos(), atan(), sinh(), cosh(), tanh()
      • Clamping: clamp(), clamp_max(), clamp_min()
      • Sign: sgn()
    • METADATA_MANIPULATION

      public static final FunctionType METADATA_MANIPULATION
      Manipulates or queries the label set of time series.

      Input: Instant vector
      Output: Instant vector (modified labels or label-based filtering)

      Examples:

      • Manipulation: label_replace(), label_join()
      • Querying: absent()
    • TIME_EXTRACTION

      public static final FunctionType TIME_EXTRACTION
      Extracts or computes time-based values from timestamps.

      Input: Instant vector
      Output: Instant vector (timestamp replaced with time component)

      Examples: day_of_month(), day_of_week(), hour(), minute(), month(), year(), timestamp()

    • HISTOGRAM

      public static final FunctionType HISTOGRAM
      Operates on native histogram data types.

      Input: Instant vector (histogram samples)
      Output: Instant vector or scalar

      Examples: histogram_quantile(), histogram_avg(), histogram_count(), histogram_sum()

    • VECTOR_CONVERSION

      public static final FunctionType VECTOR_CONVERSION
      Converts a scalar to a vector.

      Input: Scalar
      Output: Instant vector (single sample with no labels)

      Example: vector(42) produces an instant vector with one sample with value 42

    • SCALAR_CONVERSION

      public static final FunctionType SCALAR_CONVERSION
      Converts a vector that contains only a single element to a scalar. If the vector does not contain exactly one element, NaN is returned.

      Input: Instant vector (single sample)
      Output: Scalar

      Example: scalar(vector(42)) produces 42

    • SCALAR

      public static final FunctionType SCALAR
      Produces a scalar value.

      Input: None
      Output: Scalar

      Examples: pi(), time()

  • Method Details

    • values

      public static FunctionType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static FunctionType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isRangeVector

      public boolean isRangeVector()
      Returns whether this function operates on range vectors.
    • isInstantVector

      public boolean isInstantVector()
      Returns whether this function operates on instant vectors.
    • isAggregation

      public boolean isAggregation()
      Returns whether this function performs aggregation.
    • isElementWise

      public boolean isElementWise()
      Returns whether this function transforms values element-wise.
    • outputType

      public PromqlDataType outputType()
    • inputType

      public PromqlDataType inputType()