Class WindowFunctionNode

All Implemented Interfaces:
Visitable
Direct Known Subclasses:
AggregateWindowFunctionNode, RowNumberFunctionNode

public abstract class WindowFunctionNode extends UnaryOperatorNode
Superclass of any window function call.
  • Field Details

  • Constructor Details

  • Method Details

    • isConstantExpression

      public boolean isConstantExpression()
      ValueNode override.
      Overrides:
      isConstantExpression in class UnaryOperatorNode
      Returns:
      Whether or not this expression tree represents a constant expression.
      See Also:
    • constantExpression

      boolean constantExpression(PredicateList whereClause)
      ValueNode override.
      Overrides:
      constantExpression in class UnaryOperatorNode
      Returns:
      True means this expression tree represents a constant value.
      See Also:
    • getWindow

      WindowNode getWindow()
      Returns:
      window associated with this window function
    • setWindow

      void setWindow(WindowDefinitionNode wdn)
      Set window associated with this window function call.
      Parameters:
      wdn - window definition
    • bindExpression

      ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException
      ValueNode override.
      Overrides:
      bindExpression in class UnaryOperatorNode
      Parameters:
      fromList - The FROM list for the query this expression is in, for binding columns.
      subqueryList - The subquery list being built as we find SubqueryNodes
      aggregates - The aggregate list being built as we find AggregateNodes
      Returns:
      The new top of the expression tree.
      Throws:
      StandardException - Thrown on error
      See Also:
    • definedWindow

      private WindowDefinitionNode definedWindow(WindowList windows, String name)
      Returns:
      if name matches a defined window (in windows), return the definition of that window, else null.
    • printSubNodes

      public void printSubNodes(int depth)
      QueryTreeNode override.
      Overrides:
      printSubNodes in class UnaryOperatorNode
      Parameters:
      depth - The depth of this node in the tree
      See Also:
    • replaceCallsWithColumnReferences

      ValueNode replaceCallsWithColumnReferences(ResultColumnList rcl, int tableNumber) throws StandardException
      Replace window function calls in the expression tree with a ColumnReference to that window function, append the aggregate to the supplied RCL (assumed to be from the child ResultSetNode) and return the ColumnReference.
      Parameters:
      rcl - The RCL to append to.
      tableNumber - The tableNumber for the new ColumnReference
      Returns:
      ValueNode The (potentially) modified tree.
      Throws:
      StandardException - Thrown on error
    • getGeneratedRef

      ColumnReference getGeneratedRef()
      Get the generated ColumnReference to this window function after the parent called replaceCallsWithColumnReferences().

      There are cases where this will not have been done because the tree has been re-written to eliminate the window function, e.g. for this query:

          SELECT * FROM t WHERE EXISTS
                (SELECT ROW_NUMBER() OVER () FROM t)
      

      in which case the top PRN of the subquery sitting over a WindowResultSetNode just contains a RC which is boolean constant true. This means that the replaceCallsWithColumnReferences will not have been called for this, so the returned generatedRef is null.

      Returns:
      the column reference
    • getNewNullResultExpression

      ValueNode getNewNullResultExpression() throws StandardException
      Get the null result expression column.
      Returns:
      the value node
      Throws:
      StandardException - on error