Class TimeSeriesCollapse

All Implemented Interfaces:
NamedWriteable, Writeable, PostOptimizationVerificationAware, Resolvable

public class TimeSeriesCollapse extends UnaryPlan implements PostOptimizationVerificationAware
Logical plan node that collapses expanded rows into one multi-valued row per output series. The step and value columns become sparse, positionally-aligned multi-valued columns; the dimensions stay single-valued grouping keys.

The parser stacks this node directly on top of a PromqlCommand when the user writes TS_COLLAPSE (and the Prometheus query_range plan builder does the same so PrometheusQueryResponseListener can read one MV row per series). The start, end and stepBucketSize bounds are null at parse time and are filled in by TranslateTimeSeriesCollapse reading from the source PromqlCommand child; this avoids the divergence that would arise from resolving them independently from the PROMQL evaluation. They stay as ESQL expressions all the way down to the Mapper, which folds them to long when building the physical TimeSeriesCollapseExec.

  • 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
    • value

      public Attribute value()
    • step

      public Attribute step()
    • dimensions

      public List<Attribute> dimensions()
    • startLiteral

      public Literal startLiteral()
    • endLiteral

      public Literal endLiteral()
    • stepBucketSize

      public Expression stepBucketSize()
    • start

      public long start()
    • end

      public long end()
    • stepMillis

      public long stepMillis()
    • computeReferences

      protected AttributeSet computeReferences()
      Description copied from class: QueryPlan
      This very likely needs to be overridden for QueryPlan.references() to be correct when inheriting. This can be called on unresolved plans and therefore must not rely on calls to QueryPlan.output().
      Overrides:
      computeReferences in class QueryPlan<LogicalPlan>
    • expressionsResolved

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

      public TimeSeriesCollapse replaceChild(LogicalPlan newChild)
      Specified by:
      replaceChild in class UnaryPlan
    • 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
    • info

      protected NodeInfo<? extends LogicalPlan> info()
      Description copied from class: Node
      Normally, you want to use one of the static create methods 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 like QueryPlan#transformExpressionsOnly(Function) will not have an effect.

      Specified by:
      info in class Node<LogicalPlan>
    • verify

      public void verify(Failures failures)
    • isZeroLimit

      public static boolean isZeroLimit(LogicalPlan plan)
    • postOptimizationVerification

      public void postOptimizationVerification(Failures failures)
      Description copied from interface: PostOptimizationVerificationAware
      Validates the implementing expression - discovered failures are reported to the given Failures class.

      Example: the Bucket function, which produces buckets over a numerical or date field, based on a number of literal arguments needs to check if its arguments are all indeed literals. This is how this verification is performed:

           
      
            @Override
            public void postOptimizationVerification(Failures failures) {
                String operation = sourceText();
      
                failures.add(isFoldable(buckets, operation, SECOND))
                    .add(from != null ? isFoldable(from, operation, THIRD) : null)
                    .add(to != null ? isFoldable(to, operation, FOURTH) : null);
            }
           
           
      Specified by:
      postOptimizationVerification in interface PostOptimizationVerificationAware
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class UnaryPlan