Class FoldablesConvertFunction
java.lang.Object
org.elasticsearch.xpack.esql.core.tree.Node<Expression>
org.elasticsearch.xpack.esql.core.expression.Expression
org.elasticsearch.xpack.esql.core.expression.function.Function
org.elasticsearch.xpack.esql.core.expression.function.scalar.ScalarFunction
org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction
org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction
org.elasticsearch.xpack.esql.expression.function.scalar.convert.AbstractConvertFunction
org.elasticsearch.xpack.esql.expression.function.scalar.convert.FoldablesConvertFunction
- All Implemented Interfaces:
NamedWriteable,Writeable,PostOptimizationVerificationAware,Resolvable,EvaluatorMapper
- Direct Known Subclasses:
ToDatePeriod,ToTimeDuration
public abstract class FoldablesConvertFunction
extends AbstractConvertFunction
implements PostOptimizationVerificationAware
Base class for functions that converts a constant into an interval type - DATE_PERIOD or TIME_DURATION.
The functions will be folded at the end of LogicalPlanOptimizer by the coordinator, it does not reach data node.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.convert.AbstractConvertFunction
AbstractConvertFunction.AbstractEvaluatorNested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
Expression.TypeResolutionNested 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
Fields inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction
field -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFoldablesConvertFunction(Source source, Expression field) -
Method Summary
Modifier and TypeMethodDescriptionprotected final Map<DataType, org.elasticsearch.xpack.esql.expression.function.scalar.convert.AbstractConvertFunction.BuildFactory> A map from input type toEvalOperator.ExpressionEvaluatorctor.final Objectfold(FoldContext ctx) final Stringfinal voidpostOptimizationVerification(Failures failures) Validates the implementing expression - discovered failures are reported to the givenFailuresclass.protected final Expression.TypeResolutionfinal voidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.convert.AbstractConvertFunction
evaluator, supportedTypes, toEvaluatorMethods inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction
dataType, field, foldableMethods inherited from class org.elasticsearch.xpack.esql.core.expression.function.Function
arguments, equals, functionName, hashCode, nodeString, nullableMethods inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
canonical, canonicalize, childrenResolved, propertiesToString, references, resolved, semanticEquals, semanticHash, toString, typeResolvedMethods inherited from class org.elasticsearch.xpack.esql.core.tree.Node
anyMatch, children, collect, collectFirstChildren, collectLeaves, doCollectFirst, forEachDown, forEachDown, forEachProperty, forEachPropertyDown, forEachPropertyOnly, forEachPropertyUp, forEachUp, forEachUp, info, nodeName, nodeProperties, replaceChildren, replaceChildrenSameSize, source, sourceLocation, sourceText, transformChildren, transformDown, transformDown, transformNodeProps, transformPropertiesDown, transformPropertiesOnly, transformPropertiesUp, 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
-
Constructor Details
-
FoldablesConvertFunction
-
-
Method Details
-
writeTo
- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classUnaryScalarFunction
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
resolveType
- Overrides:
resolveTypein classAbstractConvertFunction
-
factories
protected final Map<DataType,org.elasticsearch.xpack.esql.expression.function.scalar.convert.AbstractConvertFunction.BuildFactory> factories()Description copied from class:AbstractConvertFunctionA map from input type toEvalOperator.ExpressionEvaluatorctor. Usually implemented like:private static final Map<DataType, BuildFactory> EVALUATORS = Map.ofEntries( Map.entry(BOOLEAN, (field, source) -> field), Map.entry(KEYWORD, ToBooleanFromStringEvaluator.Factory::new), ... ); @Override protected Map<DataType, BuildFactory> factories() { return EVALUATORS; }- Specified by:
factoriesin classAbstractConvertFunction
-
fold
- Overrides:
foldin classEsqlScalarFunction
-
postOptimizationVerification
Description copied from interface:PostOptimizationVerificationAwareValidates the implementing expression - discovered failures are reported to the givenFailuresclass.Example: the
Bucketfunction, which produces buckets over a numerical or date field, based on a number of literal arguments needs to check if its arguments are all indeed literals. This is how this verification is performed:@Override public void postOptimizationVerification(Failures failures) { String operation = sourceText(); failures.add(isFoldable(buckets, operation, SECOND)) .add(from != null ? isFoldable(from, operation, THIRD) : null) .add(to != null ? isFoldable(to, operation, FOURTH) : null); }- Specified by:
postOptimizationVerificationin interfacePostOptimizationVerificationAware
-