All Implemented Interfaces:
NamedWriteable, Writeable, PostAnalysisPlanVerificationAware, PostOptimizationPlanVerificationAware, TelemetryAware, Resolvable, ExecutesOn, ExecutesOn.Coordinator

public class UnionAll extends Fork implements PostOptimizationPlanVerificationAware
  • Constructor Details

  • Method Details

    • replaceChildren

      public LogicalPlan replaceChildren(List<LogicalPlan> newChildren)
      Overrides:
      replaceChildren in class Fork
    • info

      protected NodeInfo<? extends LogicalPlan> info()
      Overrides:
      info in class Fork
    • replaceSubPlans

      public UnionAll replaceSubPlans(List<LogicalPlan> subPlans)
      Overrides:
      replaceSubPlans in class Fork
    • replaceSubPlansAndOutput

      public Fork replaceSubPlansAndOutput(List<LogicalPlan> subPlans, List<Attribute> output)
      Overrides:
      replaceSubPlansAndOutput in class Fork
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Fork
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Fork
    • postAnalysisPlanVerification

      public BiConsumer<LogicalPlan,Failures> postAnalysisPlanVerification()
      Description copied from interface: PostAnalysisPlanVerificationAware
      Allows the implementer to return a consumer that will perform self-validation in the context of the tree structure the implementer is part of. This usually involves checking the type and configuration of the children or that of the parent.

      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: a GroupingFunction instance, which models a function to group documents to aggregate over, can only be used in the context of the STATS command, modeled by the Aggregate class. This is how this verification is performed:

           
            @Override
            public BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification() {
                return (p, failures) -> {
                    if (p instanceof Aggregate == false) {
                        p.forEachExpression(
                            GroupingFunction.class,
                            gf -> failures.add(fail(gf, "cannot use grouping function [{}] outside of a STATS command", gf.sourceText()))
                        );
                    }
                };
            }
           
           
      Specified by:
      postAnalysisPlanVerification in interface PostAnalysisPlanVerificationAware
      Overrides:
      postAnalysisPlanVerification in class Fork
      Returns:
      a consumer that will receive a tree to check and an accumulator of failures found during inspection.
    • postOptimizationPlanVerification

      public BiConsumer<LogicalPlan,Failures> postOptimizationPlanVerification()
      Description copied from interface: PostOptimizationPlanVerificationAware
      Validates the implementing expression - discovered failures are reported to the given Failures class.

      Example: the SORT command, OrderBy, can only be executed currently if it can be associated with a LIMIT Limit and together transformed into a TopN (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 PostOptimizationVerificationAware interface, which would simply check if there is an instance of OrderBy in the plan.

      Specified by:
      postOptimizationPlanVerification in interface PostOptimizationPlanVerificationAware
      Returns:
      a consumer that will receive a tree to check and an accumulator of failures found during inspection.