Class Literal
- All Implemented Interfaces:
org.apache.lucene.util.Accountable,NamedWriteable,Writeable,Resolvable,EvaluatorMapper
-
Nested Class Summary
Nested 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 Literalstatic final Literalstatic final LiteralFields inherited from class org.elasticsearch.xpack.esql.core.tree.Node
TO_STRING_MAX_LINES, TO_STRING_MAX_WIDTHFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondataType()TheDataTypereturned by executing the tree rooted at this expression.static Literalbooleanfold(FoldContext ctx) Evaluate this expression statically to a constant.booleanfoldable()Whether the expression can be evaluated statically, aka "folded", or not.static ExpressionfromBoolean(Source source, Boolean literal) static LiteralfromDouble(Source source, Double literal) static LiteralinthashCode()info()Normally, you want to use one of the staticcreatemethods to implement this.static Literalstatic LiteralvoidnodeString(StringBuilder sb, Node.NodeStringFormat format) Append thisNode's string representation tosb.nullable()static Literalof(Expression source, Object value) static Literalof(FoldContext ctx, Expression foldable) Utility method for creating a literal out of a foldable expression.longbooleanresolved()static Literalstatic LiteraltimeDuration(Source source, Duration literal) toEvaluator(EvaluatorMapper.ToEvaluator toEvaluator) Convert this into anExpressionEvaluator.toString()toString(Node.NodeStringFormat format) value()voidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.core.expression.LeafExpression
canonicalize, references, replaceChildrenMethods inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
canonical, childrenResolved, propertiesToString, resolveType, semanticEquals, semanticHash, 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, 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.apache.lucene.util.Accountable
getChildResourcesMethods inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
fold
-
Field Details
-
ENTRY
-
TRUE
-
FALSE
-
NULL
-
-
Constructor Details
-
Literal
-
-
Method Details
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
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>
-
value
-
foldable
public boolean foldable()Description copied from class:ExpressionWhether the expression can be evaluated statically, aka "folded", or not.- Overrides:
foldablein classExpression
-
nullable
- Specified by:
nullablein classExpression
-
dataType
Description copied from class:ExpressionTheDataTypereturned by executing the tree rooted at this expression. IfExpression.typeResolved()returns an error then the behavior of this method is undefined. It may return a valid type. Or it may throw an exception. Or it may return a totally nonsensical type.- Specified by:
dataTypein classExpression
-
resolved
public boolean resolved()- Specified by:
resolvedin interfaceResolvable- Overrides:
resolvedin classExpression
-
fold
Description copied from class:ExpressionEvaluate this expression statically to a constant. It is an error to call this ifExpression.foldable()returns false.- Overrides:
foldin classExpression
-
hashCode
public int hashCode()- Overrides:
hashCodein classNode<Expression>
-
equals
- Overrides:
equalsin classNode<Expression>
-
toString
- Overrides:
toStringin classExpression
-
toString
- Overrides:
toStringin classExpression
-
nodeString
Description copied from class:Node- Overrides:
nodeStringin classNode<Expression>- Parameters:
sb- target for the stringformat- configuration for rendering the string representation
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
toEvaluator
Description copied from interface:EvaluatorMapperConvert this into anExpressionEvaluator.Note for implementors: If you are implementing this function, you should call the passed-in lambda on your children, after doing any other manipulation (casting, etc.) necessary.
Note for Callers: If you are attempting to call this method, and you have an
Expressionand aLayout, you likely want to callEvalMapper.toEvaluator(org.elasticsearch.xpack.esql.core.expression.FoldContext, org.elasticsearch.xpack.esql.core.expression.Expression, org.elasticsearch.xpack.esql.planner.Layout)instead. On the other hand, if you already have something that looks like the parameter for this method, you should call this method with that function.Build an
ExpressionEvaluator.Factoryfor the tree of expressions rooted at this node. This is only guaranteed to return a sensible evaluator if this node has a valid type. If this node is a subclass ofExpressionthen "valid type" means thatExpression.typeResolved()returns a non-error resolution. If Expression.typeResolved() returns an error then this method may throw. Or return an evaluator that produces garbage. Or return an evaluator that throws when run.- Specified by:
toEvaluatorin interfaceEvaluatorMapper
-
of
Utility method for creating a literal out of a foldable expression. Throws an exception if the expression is not foldable. -
of
-
keyword
-
text
-
timeDuration
-
dateTime
-
integer
-
fromDouble
-
fromLong
-
fromBoolean
-