Class Expression
- All Implemented Interfaces:
NamedWriteable,Writeable,Resolvable
- Direct Known Subclasses:
EntryExpression,Function,LeafExpression,MapExpression,NamedExpression,UnaryExpression
SELECT a, b, ABS(c) FROM i
a, b, ABS(c), and i are all Expressions, with ABS(c) being a Function
(which is a type of expression) with a single child, c.-
Nested Class Summary
Nested ClassesNested 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.core.tree.Node
TO_STRING_MAX_WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Expressionprotected Expressionbooleanabstract DataTypedataType()TheDataTypereturned by executing the tree rooted at this expression.fold(FoldContext ctx) Evaluate this expression statically to a constant.booleanfoldable()Whether the expression can be evaluated statically, aka "folded", or not.abstract Nullabilitynullable()propertiesToString(boolean skipIfChild) Render the properties of thisNodeone by one likefoo bar baz.booleanresolved()protected Expression.TypeResolutionThe implementation oftypeResolved(), which is just a caching wrapper around this method.booleansemanticEquals(Expression other) Whether this expression means the same asother, even if they are not exactly equal.intA hash code that is consistent withsemanticEquals(org.elasticsearch.xpack.esql.core.expression.Expression).toString()Does the tree rooted at this expression have valid types at all nodes?Methods inherited from class org.elasticsearch.xpack.esql.core.tree.Node
anyMatch, children, collect, collectFirstChildren, collectLeaves, doCollectFirst, equals, forEachDown, forEachDown, forEachDownMayReturnEarly, forEachProperty, forEachPropertyDown, forEachPropertyOnly, forEachPropertyUp, forEachUp, forEachUp, hashCode, info, nodeName, nodeProperties, nodeString, replaceChildren, replaceChildrenSameSize, source, sourceLocation, sourceText, transformChildren, transformDown, transformDown, transformDown, 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.common.io.stream.NamedWriteable
getWriteableName
-
Constructor Details
-
Expression
-
-
Method Details
-
foldable
public boolean foldable()Whether the expression can be evaluated statically, aka "folded", or not. -
fold
Evaluate this expression statically to a constant. It is an error to call this iffoldable()returns false. -
nullable
-
references
-
childrenResolved
public boolean childrenResolved() -
typeResolved
Does the tree rooted at this expression have valid types at all nodes?For example,
SIN(1.2)has a valid type and should returnExpression.TypeResolution.TYPE_RESOLVEDto signal "this type is fine". Another example,SIN("cat")has an invalid type in the tree. The value passed to theSINfunction is a string which doesn't make any sense. So this method should return a "failure" resolution which it can build by callingTypeResolution(String).Take
SIN(1.2) + COS(ATAN("cat")), this tree should also fail, specifically becauseATAN("cat")is invalid. This should fail even though+is perfectly valid when run on the results ofSINandCOS. AndCOScan operate on the results of any valid call toATAN. For this method to return a "valid" result the whole tree rooted at this expression must be valid. -
resolveType
The implementation oftypeResolved(), which is just a caching wrapper around this method. See it's javadoc for what this method should return.Implementations will rarely interact with the
Expression.TypeResolutionclass directly, instead usually calling the utility methods onTypeResolutions.Implementations should fail if
childrenResolved()returnsfalse. -
canonical
-
canonicalize
-
semanticEquals
Whether this expression means the same asother, even if they are not exactly equal. For example,a + bandb + aare not equal, but they are semantically equal.If two expressions are equal, they are also semantically equal, but the reverse is generally not true.
Caution!
Attribute.semanticEquals(Expression)is especially lenient, as it considers two attributes with the sameNameIdto be semantically equal, even if they have different data types or are represented using different classes.But this doesn't extend to expressions containing attributes as children, which is pretty inconsistent. We have to revisit this before using
semanticEquals(org.elasticsearch.xpack.esql.core.expression.Expression)in more places. -
semanticHash
public int semanticHash()A hash code that is consistent withsemanticEquals(org.elasticsearch.xpack.esql.core.expression.Expression). -
resolved
public boolean resolved()- Specified by:
resolvedin interfaceResolvable
-
dataType
TheDataTypereturned by executing the tree rooted at this expression. IftypeResolved()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. -
toString
- Overrides:
toStringin classNode<Expression>
-
propertiesToString
Description copied from class:NodeRender the properties of thisNodeone by one likefoo bar baz. These go inside the[and]of the output ofNode.treeString(java.lang.StringBuilder, int, java.util.BitSet).- Overrides:
propertiesToStringin classNode<Expression>
-