All Implemented Interfaces:
NamedWriteable, Writeable, Resolvable, EvaluatorMapper

public class MvSingleValueOrNull extends AbstractMultivalueFunction
Internal optimizer function that returns an expression's value if it is single-valued, or null if it is multi-valued.

This is not a user-visible function; it is injected by the query planner to enable rewrites such as:

   | STATS s1 = SUM(expr + c1), s2 = SUM(expr + c2)
   →
   | STATS svSum = SUM(SINGLE_VALUE_OR_NULL(expr)), svCount = COUNT(SINGLE_VALUE_OR_NULL(expr))
   | EVAL s1 = svSum + c1 * svCount, s2 = svSum + c2 * svCount
 

which applies when two or more SUM(expr ± c) expressions share the same expr. The wrapped expression is not limited to field references — it can be any expression whose result may be multi-valued.

A single node may carry multiple Source entries in warningSources, one per original expression that the node represents. On encountering a multi-valued position the evaluator emits a separate warning for each source, so callers that share one node across several expressions still get a distinct warning per expression.