Class TBucket
- All Implemented Interfaces:
NamedWriteable,Writeable,PostAnalysisPlanVerificationAware,PostAnalysisVerificationAware,Resolvable,EvaluatorMapper,ConfigurationFunction,TimestampAware,TimestampBoundsAware<Expression>,TimestampBoundsAware.OfExpression,TwoOptionalArguments,OnlySurrogateExpression,SurrogateExpression
@timestamp field.
The buckets parameter works like Bucket: if it's a number, it's the target number of buckets;
if it's a duration or period, it's the explicit bucket size.
When using a target number of buckets, start/end bounds are needed and can be provided explicitly
as from/to parameters or derived automatically from the query DSL @timestamp range filter
via TimestampBoundsAware.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.xpack.esql.expression.function.grouping.GroupingFunction
GroupingFunction.EvaluatableGroupingFunction, GroupingFunction.NonEvaluatableGroupingFunctionNested 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.xpack.esql.expression.function.TimestampBoundsAware
TimestampBoundsAware.OfExpression, TimestampBoundsAware.OfLogicalPlanNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsFields inherited from class org.elasticsearch.xpack.esql.core.tree.Node
TO_STRING_MAX_LINES, TO_STRING_MAX_WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionTBucket(Source source, Expression buckets, Expression from, Expression to, Expression timestamp, Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionbuckets()dataType()TheDataTypereturned by executing the tree rooted at this expression.booleanfrom()inthashCode()protected NodeInfo<? extends Expression> info()Normally, you want to use one of the staticcreatemethods to implement this.booleanReturnstrueif this node still needs timestamp bounds to be injected.voidpostAnalysisVerification(Failures failures) Allows the implementer to validate itself.replaceChildren(List<Expression> newChildren) protected Expression.TypeResolutionThe implementation ofExpression.typeResolved(), which is just a caching wrapper around this method.Returns the expression to be replaced by ornullif this cannot be replaced.to()toEvaluator(EvaluatorMapper.ToEvaluator toEvaluator) Convert this into anExpressionEvaluator.toString()withTimestampBounds(Literal start, Literal end) Returns a copy of this node with the given timestamp bounds applied.voidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.expression.function.grouping.GroupingFunction.EvaluatableGroupingFunction
foldMethods inherited from class org.elasticsearch.xpack.esql.expression.function.grouping.GroupingFunction
postAnalysisPlanVerificationMethods 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, foldable, propertiesToString, references, resolved, semanticEquals, semanticHash, 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, 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
-
NAME
- See Also:
-
DEFINITION
-
-
Constructor Details
-
TBucket
public TBucket(Source source, Expression buckets, @Nullable Expression from, @Nullable Expression to, Expression timestamp, Configuration configuration)
-
-
Method Details
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
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
-
needsTimestampBounds
public boolean needsTimestampBounds()Description copied from interface:TimestampBoundsAwareReturnstrueif this node still needs timestamp bounds to be injected.- Specified by:
needsTimestampBoundsin interfaceTimestampBoundsAware<Expression>
-
withTimestampBounds
Description copied from interface:TimestampBoundsAwareReturns a copy of this node with the given timestamp bounds applied.- Specified by:
withTimestampBoundsin interfaceTimestampBoundsAware<Expression>
-
postAnalysisVerification
Description copied from interface:PostAnalysisVerificationAwareAllows the implementer to validate itself. This usually involves checking its internal setup, which often means checking the parameters it received on construction: their data or syntactic type, class, their count, expressions' structure etc. The discovered failures are added to the givenFailuresobject.It is often more useful to perform the checks as extended as it makes sense, over stopping at the first failure. This will allow the author to progress faster to a correct query.
Example: the
Filterclass, which models the WHERE command, checks that the expression it filters on -condition- is of a Boolean or NULL type:@Override void postAnalysisVerification(Failures failures) { if (condition.dataType() != NULL && condition.dataType() != BOOLEAN) { failures.add(fail(condition, "Condition expression needs to be boolean, found [{}]", condition.dataType())); } }- Specified by:
postAnalysisVerificationin interfacePostAnalysisVerificationAware- Parameters:
failures- the object to add failures to.
-
surrogate
Description copied from interface:SurrogateExpressionReturns the expression to be replaced by ornullif this cannot be replaced.- Specified by:
surrogatein interfaceSurrogateExpression
-
resolveType
Description copied from class:ExpressionThe implementation ofExpression.typeResolved(), 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
Expression.childrenResolved()returnsfalse.- Overrides:
resolveTypein 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
-
replaceChildren
- Specified by:
replaceChildrenin classNode<Expression>
-
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>
-
timestamp
- Specified by:
timestampin interfaceTimestampAware
-
buckets
-
from
-
to
-
toString
- Overrides:
toStringin classExpression
-
hashCode
public int hashCode() -
equals
-