Class PromqlCommand
- All Implemented Interfaces:
NamedWriteable,Writeable,PostAnalysisVerificationAware,TelemetryAware,Resolvable,TimestampAware,TimestampBoundsAware<LogicalPlan>,TimestampBoundsAware.OfLogicalPlan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.xpack.esql.plan.logical.LogicalPlan
LogicalPlan.StageNested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.tree.Node
Node.NodeStringFormatNested 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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Durationstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe name of the column containing the step value (aka time bucket) in range queries.Fields inherited from class org.elasticsearch.xpack.esql.core.tree.Node
TO_STRING_MAX_LINES, TO_STRING_MAX_WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionPromqlCommand(Source source, LogicalPlan child, LogicalPlan promqlPlan, Literal start, Literal end, Literal step, Literal buckets, Literal scrapeInterval, String valueColumnName, Expression timestamp) PromqlCommand(Source source, LogicalPlan child, LogicalPlan promqlPlan, Literal start, Literal end, Literal step, Literal buckets, Literal scrapeInterval, String valueColumnName, NameId valueId, NameId stepId, Expression timestamp) -
Method Summary
Modifier and TypeMethodDescriptionName of the synthetic column tagging each union branch with its position, used for left-preferring dedup.buckets()Number of buckets for auto-derived range-query bucket size.protected AttributeSetThis very likely needs to be overridden forQueryPlan.references()to be correct when inheriting.end()booleanbooleaninthashCode()booleanprotected NodeInfo<PromqlCommand> info()Normally, you want to use one of the staticcreatemethods to implement this.booleanbooleanbooleanBounds are only needed whenbucketsis specified without an explicit time range.voidnodeString(StringBuilder sb, Node.NodeStringFormat format, NodeStringMapper mapper) Append thisNode's string representation tosb.offset(LogicalPlan branch) The signed offset shared by the source-backed selectors inbranch, as a constant time shift to add to@timestamp.output()The ordered list of attributes (i.e.voidpostAnalysisVerification(Failures failures) Allows the implementer to validate itself.replaceChild(LogicalPlan newChild) Resolves the implicit range placeholder to a concrete duration based on step and scrape interval.Returns the TSTEP bucket step for instant queries: the max range-selector window, falling back toDEFAULT_LOOKBACKonly when no range selectors are present.The expected scrape interval used to derive implicit range selector windows.Returns the source-side timestamp lookback window.start()step()stepId()timestamp(LogicalPlan fragment) Returns the local evaluation timestamp for the current selector branch.Name of the synthetic column materialising the offset-shifted@timestamp + offsetevaluation time.valueId()voidwithPromqlPlan(LogicalPlan newPromqlPlan) 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.plan.logical.UnaryPlan
child, inputSet, outputSet, replaceChildrenMethods inherited from class org.elasticsearch.xpack.esql.plan.logical.LogicalPlan
analyzed, childrenResolved, optimized, preAnalyzed, preOptimized, resolved, setAnalyzed, setOptimized, setPreAnalyzed, setPreOptimizedMethods inherited from class org.elasticsearch.xpack.esql.plan.QueryPlan
computeExpressions, expressions, forEachExpression, forEachExpression, forEachExpressionDown, forEachExpressionUp, references, transformExpressionsDown, transformExpressionsDown, transformExpressionsOnly, transformExpressionsOnly, transformExpressionsOnlyUp, transformExpressionsUp, transformExpressionsUpMethods 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, propertiesToString, replaceChildrenSameSize, source, sourceLocation, sourceText, toString, toString, 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.capabilities.PostAnalysisVerificationAware
postAnalysisVerification
-
Field Details
-
TIME
The name of the column containing the step value (aka time bucket) in range queries.- See Also:
-
START
- See Also:
-
END
- See Also:
-
STEP
- See Also:
-
BUCKETS
- See Also:
-
SCRAPE_INTERVAL
- See Also:
-
RANGE
- See Also:
-
INDEX
- See Also:
-
DEFAULT_PROMQL_INDEX_PATTERN
- See Also:
-
PROMQL_ALLOWED_PARAMS
-
DEFAULT_LOOKBACK
-
DEFAULT_PROMQL_BUCKETS
public static final int DEFAULT_PROMQL_BUCKETS- See Also:
-
-
Constructor Details
-
PromqlCommand
public PromqlCommand(Source source, LogicalPlan child, LogicalPlan promqlPlan, Literal start, Literal end, Literal step, Literal buckets, Literal scrapeInterval, String valueColumnName, Expression timestamp) -
PromqlCommand
public PromqlCommand(Source source, LogicalPlan child, LogicalPlan promqlPlan, Literal start, Literal end, Literal step, Literal buckets, Literal scrapeInterval, String valueColumnName, NameId valueId, NameId stepId, Expression timestamp)
-
-
Method Details
-
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<LogicalPlan>
-
replaceChild
- Specified by:
replaceChildin classUnaryPlan
-
withPromqlPlan
-
needsTimestampBounds
public boolean needsTimestampBounds()Bounds are only needed whenbucketsis specified without an explicit time range. Whenstepalone is set, the query can proceed without start/end because the step directly defines the bucket size;postAnalysisVerification(org.elasticsearch.xpack.esql.common.Failures)validates that case.- Specified by:
needsTimestampBoundsin interfaceTimestampBoundsAware<LogicalPlan>
-
withTimestampBounds
Description copied from interface:TimestampBoundsAwareReturns a copy of this node with the given timestamp bounds applied.- Specified by:
withTimestampBoundsin interfaceTimestampBoundsAware<LogicalPlan>
-
expressionsResolved
public boolean expressionsResolved()- Specified by:
expressionsResolvedin classLogicalPlan
-
telemetryLabel
- Specified by:
telemetryLabelin interfaceTelemetryAware- Returns:
- the label reported in the telemetry data. Only needs to be overwritten if the label doesn't match the class name.
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
promqlPlan
-
start
-
end
-
step
-
buckets
Number of buckets for auto-derived range-query bucket size. -
scrapeInterval
The expected scrape interval used to derive implicit range selector windows. -
hasTimeRange
public boolean hasTimeRange() -
isInstantQuery
public boolean isInstantQuery() -
isRangeQuery
public boolean isRangeQuery() -
valueColumnName
-
stepColumnName
-
branchColumnName
Name of the synthetic column tagging each union branch with its position, used for left-preferring dedup. -
timestampColumnName
Name of the synthetic column materialising the offset-shifted@timestamp + offsetevaluation time. -
valueId
-
stepId
-
valueAttribute
-
stepAttribute
-
timestamp
- Specified by:
timestampin interfaceTimestampAware
-
output
Description copied from class:QueryPlanThe ordered list of attributes (i.e. columns) this plan produces when executed. Must be called only on resolved plans, otherwise may throw an exception or return wrong results. -
hashCode
public int hashCode() -
equals
-
nodeString
Description copied from class:Node- Overrides:
nodeStringin classNode<LogicalPlan>- Parameters:
sb- target for the stringformat- output-shape configuration (width / lines / property count)mapper- identifier-mapping strategy (raw viaNodeStringMapper.IDENTITY, anonymized via the failure-path anonymizer, etc.)
-
computeReferences
Description copied from class:QueryPlanThis very likely needs to be overridden forQueryPlan.references()to be correct when inheriting. This can be called on unresolved plans and therefore must not rely on calls toQueryPlan.output().- Overrides:
computeReferencesin classQueryPlan<LogicalPlan>
-
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.
-
verify
-
offset
The signed offset shared by the source-backed selectors inbranch, as a constant time shift to add to@timestamp. The verifier guarantees a merged branch is offset-uniform (heterogeneous offsets in a binary expression are rejected), so the first source-backed selector's offset is representative.Duration.ZEROwhen there is none. -
sourceFilterWindow
Returns the source-side timestamp lookback window. Explicit and implicit range selectors contribute their requested window. Instant queries extend that window to at least the Prometheus lookback delta. -
timestamp
Returns the local evaluation timestamp for the current selector branch.Unlike
timestamp(), which returns the global evaluation timestamp, this function returns the plan fragment timestamp and includes any applied offset. -
resolveInstantQueryWindow
Returns the TSTEP bucket step for instant queries: the max range-selector window, falling back toDEFAULT_LOOKBACKonly when no range selectors are present. UnlikesourceFilterWindow(), this does not floor explicit windows up to DEFAULT_LOOKBACK. -
resolveImplicitRangeWindow
Resolves the implicit range placeholder to a concrete duration based on step and scrape interval. The implicit window is calculated asmax(step, scrape_interval). -
resolveTimeBucketSize
-