Class Window

All Implemented Interfaces:
Cloneable, RelOptNode, Hintable, RelNode
Direct Known Subclasses:
Bindables.BindableWindow, EnumerableWindow, LogicalWindow

public abstract class Window extends SingleRel implements Hintable
A relational expression representing a set of window aggregates.

A Window can handle several window aggregate functions, over several partitions, with pre- and post-expressions, and an optional post-filter. Each of the partitions is defined by a partition key (zero or more columns) and a range (logical or physical). The partitions expect the data to be sorted correctly on input to the relational expression.

Each Window.Group has a set of RexOver objects.

Created by ProjectToWindowRule.

  • Field Details

    • groups

      public final com.google.common.collect.ImmutableList<Window.Group> groups
    • constants

      public final com.google.common.collect.ImmutableList<RexLiteral> constants
    • hints

      protected final com.google.common.collect.ImmutableList<RelHint> hints
  • Constructor Details

    • Window

      protected Window(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelNode input, List<RexLiteral> constants, RelDataType rowType, List<Window.Group> groups)
      Creates a window relational expression.
      Parameters:
      cluster - Cluster
      traitSet - Trait set
      hints - Hints for this node
      input - Input relational expression
      constants - List of constants that are additional inputs
      rowType - Output row type
      groups - Windows
    • Window

      public Window(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, List<RexLiteral> constants, RelDataType rowType, List<Window.Group> groups)
      Creates a window relational expression.
      Parameters:
      cluster - Cluster
      traitSet - Trait set
      input - Input relational expression
      constants - List of constants that are additional inputs
      rowType - Output row type
      groups - Windows
  • Method Details

    • copy

      public abstract Window copy(List<RexLiteral> constants)
      Creates a copy of this Window.
      Parameters:
      constants - Replaces the list of constants in the returned copy
      Returns:
      New Window
    • isValid

      public boolean isValid(Litmus litmus, @Nullable RelNode.Context context)
      Description copied from interface: RelNode
      Returns whether this relational expression is valid.

      If assertions are enabled, this method is typically called with litmus = THROW, as follows:

      assert rel.isValid(Litmus.THROW)

      This signals that the method can throw an AssertionError if it is not valid.

      Specified by:
      isValid in interface RelNode
      Overrides:
      isValid in class AbstractRelNode
      Parameters:
      litmus - What to do if invalid
      context - Context for validity checking
      Returns:
      Whether relational expression is valid
    • explainTerms

      public RelWriter explainTerms(RelWriter pw)
      Description copied from class: AbstractRelNode
      Describes the inputs and attributes of this relational expression. Each node should call super.explainTerms, then call the RelWriter.input(String, RelNode) and RelWriter.item(String, Object) methods for each input and attribute.
      Overrides:
      explainTerms in class SingleRel
      Parameters:
      pw - Plan writer
      Returns:
      Plan writer for fluent-explain pattern
    • getProjectOrdinals

      public static ImmutableIntList getProjectOrdinals(List<RexNode> exprs)
    • getCollation

      public static RelCollation getCollation(List<RexFieldCollation> collations)
    • getConstants

      public List<RexLiteral> getConstants()
      Returns constants that are additional inputs of current relation.
      Returns:
      constants that are additional inputs of current relation
    • computeSelfCost

      public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
      Description copied from interface: RelNode
      Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

      NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

      Specified by:
      computeSelfCost in interface RelNode
      Overrides:
      computeSelfCost in class AbstractRelNode
      Parameters:
      planner - Planner for cost calculation
      mq - Metadata query
      Returns:
      Cost of this plan (not including children)
    • getHints

      public com.google.common.collect.ImmutableList<RelHint> getHints()
      Description copied from interface: Hintable
      Returns the hints of this relational expressions as an immutable list.
      Specified by:
      getHints in interface Hintable