Class PromqlFoldingUtils

java.lang.Object
org.elasticsearch.xpack.esql.parser.promql.PromqlFoldingUtils

public class PromqlFoldingUtils extends Object
Utility class for evaluating scalar arithmetic operations at parse time. Handles operations between: - Numbers (delegates to Arithmetics) - Durations and numbers (converts to seconds, computes, converts back) - Durations and durations (only for ADD/SUB)
  • Constructor Details

    • PromqlFoldingUtils

      public PromqlFoldingUtils()
  • Method Details

    • evaluate

      public static Object evaluate(Source source, Object left, Object right, VectorBinaryArithmetic.ArithmeticOp operation)
      Evaluate arithmetic operation between two scalar values at parse time.
      Parameters:
      source - Source location for error messages
      left - Left operand (Number or Duration)
      right - Right operand (Number or Duration)
      operation - The arithmetic operation
      Returns:
      Result value (Number or Duration)
    • evaluate

      public static boolean evaluate(Source source, Object left, Object right, VectorBinaryComparison.ComparisonOp operation)
      Evaluate comparison operation between two numbers at parse time.
      Parameters:
      left - Left operand (Number)
      right - Right operand (Number)
      operation - The comparison operation
      Returns:
      true if comparison holds, false otherwise