Class MvSingleValueOrNull
- All Implemented Interfaces:
NamedWriteable,Writeable,Resolvable,EvaluatorMapper
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.AbstractMultivalueFunction
AbstractMultivalueFunction.AbstractEvaluator, AbstractMultivalueFunction.AbstractNullableEvaluatorNested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
Expression.TypeResolutionNested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.tree.Node
Node.NodeStringFormatNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
EvaluatorMapper.ToEvaluatorNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NamedWriteableRegistry.Entrystatic final TransportVersionFields inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction
fieldFields inherited from class org.elasticsearch.xpack.esql.core.expression.function.scalar.ScalarFunction
MAX_BYTES_REF_RESULT_SIZEFields inherited from class org.elasticsearch.xpack.esql.core.tree.Node
TO_STRING_MAX_LINES, TO_STRING_MAX_WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionMvSingleValueOrNull(Source source, Expression field) MvSingleValueOrNull(Source source, Expression field, List<Source> warningSources) -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected ExpressionEvaluator.Factoryevaluator(ExpressionEvaluator.Factory fieldEval) Build the evaluator given the evaluator a multivalued field.inthashCode()protected NodeInfo<? extends Expression> info()Normally, you want to use one of the staticcreatemethods to implement this.replaceChildren(List<Expression> newChildren) protected Expression.TypeResolutionvoidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.AbstractMultivalueFunction
resolveType, toEvaluatorMethods inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction
dataType, field, foldableMethods inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction
foldMethods inherited from class org.elasticsearch.xpack.esql.core.expression.function.Function
arguments, functionName, nodeString, nullableMethods inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
canonical, canonicalize, childrenResolved, propertiesToString, references, resolved, semanticEquals, semanticHash, toString, toString, typeResolvedMethods inherited from class org.elasticsearch.xpack.esql.core.tree.Node
allMatch, anyMatch, children, collect, collect, collect, collectFirstChildren, collectLeaves, doCollectFirst, forEachDown, forEachDown, forEachDownMayReturnEarly, forEachProperty, forEachPropertyDown, forEachPropertyOnly, forEachPropertyUp, forEachUp, forEachUp, nodeName, nodeProperties, nodeString, replaceChildrenSameSize, source, sourceLocation, sourceText, toString, transformChildren, transformChildren, transformDown, transformDown, transformDown, transformDown, transformDownSkipBranch, transformNodeProps, transformPropertiesDown, transformPropertiesOnly, transformPropertiesUp, transformUp, transformUp, transformUpMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
fold
-
Field Details
-
MV_SINGLE_VALUE_OR_NULL_TRANSPORT_VERSION
-
ENTRY
-
-
Constructor Details
-
MvSingleValueOrNull
-
MvSingleValueOrNull
-
-
Method Details
-
warningSources
-
writeTo
- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classAbstractMultivalueFunction- Throws:
IOException
-
getWriteableName
-
resolveFieldType
- Specified by:
resolveFieldTypein classAbstractMultivalueFunction
-
evaluator
Description copied from class:AbstractMultivalueFunctionBuild the evaluator given the evaluator a multivalued field.- Specified by:
evaluatorin classAbstractMultivalueFunction
-
replaceChildren
- Specified by:
replaceChildrenin classNode<Expression>
-
hashCode
public int hashCode() -
equals
-
info
Description copied from class:NodeNormally, you want to use one of the staticcreatemethods to implement this.For
QueryPlans, it is very important that the properties contain all of the expressions and references relevant to this node, and that all the properties are used in the provided constructor; otherwise query plan transformations likeQueryPlan#transformExpressionsOnly(Function)will not have an effect.- Specified by:
infoin classNode<Expression>
-