Class PromqlFoldingUtils
java.lang.Object
org.elasticsearch.xpack.esql.parser.promql.PromqlFoldingUtils
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectevaluate(Source source, Object left, Object right, VectorBinaryArithmetic.ArithmeticOp operation) Evaluate arithmetic operation between two scalar values at parse time.static booleanevaluate(Source source, Object left, Object right, VectorBinaryComparison.ComparisonOp operation) Evaluate comparison operation between two numbers at parse time.
-
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 messagesleft- 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
-