Interface PostOptimizationPlanVerificationAware
- All Known Implementing Classes:
OrderBy
PostOptimizationVerificationAware, but focused on individual expressions or plans, typically
covering semantic checks. Generally, whenever one needs to check the plan structure leading to a certain node, which is the node of
interest, this node's class needs to implement this interface. Otherwise it may implement PostOptimizationVerificationAware,
as more convenient.-
Method Summary
Modifier and TypeMethodDescriptionValidates the implementing expression - discovered failures are reported to the givenFailuresclass.
-
Method Details
-
postOptimizationPlanVerification
BiConsumer<LogicalPlan,Failures> postOptimizationPlanVerification()Validates 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.- Returns:
- a consumer that will receive a tree to check and an accumulator of failures found during inspection.
-