Class InlineStats

All Implemented Interfaces:
NamedWriteable, Writeable, PostAnalysisPlanVerificationAware, TelemetryAware, Resolvable, SortAgnostic, SurrogateLogicalPlan

Enriches the stream of data with the results of running a STATS.

Maps to a dedicated Join implementation, InlineJoin, which is a left join between the main relation and the underlying aggregate.

  • Field Details

  • Constructor Details

  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • getWriteableName

      public String getWriteableName()
      Specified by:
      getWriteableName in interface NamedWriteable
    • info

      protected NodeInfo<InlineStats> info()
      Specified by:
      info in class Node<LogicalPlan>
    • replaceChild

      public InlineStats replaceChild(LogicalPlan newChild)
      Specified by:
      replaceChild in class UnaryPlan
    • aggregate

      public Aggregate aggregate()
    • expressionsResolved

      public boolean expressionsResolved()
      Specified by:
      expressionsResolved in class LogicalPlan
    • output

      public List<Attribute> output()
      Description copied from class: QueryPlan
      The 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.
      Overrides:
      output in class UnaryPlan
    • surrogate

      public LogicalPlan surrogate()
      Description copied from interface: SurrogateLogicalPlan
      Returns the plan to be replaced with.
      Specified by:
      surrogate in interface SurrogateLogicalPlan
    • telemetryLabel

      public String telemetryLabel()
      Specified by:
      telemetryLabel in interface TelemetryAware
      Returns:
      the label reported in the telemetry data. Only needs to be overwritten if the label doesn't match the class name.
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class UnaryPlan
    • 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
      Returns:
      a consumer that will receive a tree to check and an accumulator of failures found during inspection.