Class MMR
- All Implemented Interfaces:
NamedWriteable,Writeable,PostAnalysisVerificationAware,PostOptimizationPlanVerificationAware,TelemetryAware,Resolvable,ExecutesOn,ExecutesOn.Coordinator
-
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.plan.logical.ExecutesOn
ExecutesOn.Coordinator, ExecutesOn.ExecuteLocation, ExecutesOn.RemoteNested 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
ConstructorsConstructorDescriptionMMR(Source source, LogicalPlan child, Attribute diversifyField, Expression limit, Expression queryVector, MapExpression options) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleaninthashCode()protected NodeInfo<? extends LogicalPlan> info()Normally, you want to use one of the staticcreatemethods to implement this.limit()options()voidpostAnalysisVerification(Failures failures) Allows the implementer to validate itself.Validates the implementing expression - discovered failures are reported to the givenFailuresclass.replaceChild(LogicalPlan newChild) voidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.plan.logical.UnaryPlan
child, inputSet, output, 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, computeReferences, 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, nodeString, propertiesToString, replaceChildrenSameSize, source, sourceLocation, sourceText, 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.plan.logical.ExecutesOn.Coordinator
executesOnMethods inherited from interface org.elasticsearch.xpack.esql.capabilities.TelemetryAware
telemetryLabel
-
Field Details
-
LAMBDA_OPTION_NAME
- See Also:
-
DEFAULT_LAMBDA
public static final float DEFAULT_LAMBDA- See Also:
-
-
Constructor Details
-
MMR
public MMR(Source source, LogicalPlan child, Attribute diversifyField, Expression limit, @Nullable Expression queryVector, @Nullable MapExpression options)
-
-
Method Details
-
diversifyField
-
limit
-
queryVector
-
options
-
replaceChild
- Specified by:
replaceChildin classUnaryPlan
-
expressionsResolved
public boolean expressionsResolved()- Specified by:
expressionsResolvedin classLogicalPlan
-
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>
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
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.
-
postOptimizationPlanVerification
Description copied from interface:PostOptimizationPlanVerificationAwareValidates the implementing expression - discovered failures are reported to the givenFailuresclass.Example: the SORT command,
OrderBy, can only be executed currently if it can be associated with a LIMITLimitand together transformed into aTopN(which is executable). The replacement of the LIMIT+SORT into a TopN is done at the end of the optimization phase. This means that any SORT still existing in the plan post optimization is an error. However, there can be a LIMIT in the plan, but separated from the SORT by an INLINE STATS; in this case, the LIMIT cannot be pushed down near the SORT. To inform the user how they need to modify the query so it can be run, we implement this:@Override public BiConsumer<LogicalPlan, Failures> postOptimizationPlanVerification() { return (p, failures) -> { if (p instanceof InlineJoin inlineJoin) { inlineJoin.forEachUp(OrderBy.class, orderBy -> { failures.add( fail( inlineJoin, "unbounded SORT [{}] not supported before INLINE STATS [{}], move the sort after the INLINE STATS", orderBy.sourceText(), inlineJoin.sourceText() ) ); }); } else if (p instanceof OrderBy) { failures.add(fail(p, "Unbounded SORT not supported yet [{}] please add a LIMIT", p.sourceText())); } }; }If we didn't need to check the structure of the plan, it would have sufficed to implement the
PostOptimizationVerificationAwareinterface, which would simply check if there is an instance ofOrderByin the plan.- Specified by:
postOptimizationPlanVerificationin interfacePostOptimizationPlanVerificationAware- Returns:
- a consumer that will receive a tree to check and an accumulator of failures found during inspection.
-