Interface GroupedExpressionValues


public interface GroupedExpressionValues
The value of an expression written over GROUPED rows, computed over the row's own source group.

A window stage that runs after grouping sees one row per group, and those rows no longer carry the values an aggregate would need: ROW_NUMBER() OVER (ORDER BY SUM(b)) has to know each group's SUM(b), and LAG(SUM(b)) OVER (…) has to know it as an ARGUMENT. Where the aggregate is also a SELECT item its computed value can be read positionally, but it need not be — and then the only place left to compute it is the group the output row came from.

Implemented by the query executor, which holds the output-row-to-group map; the window evaluator asks through this interface so it never has to know how grouping stored its rows.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Object
    Answered when the expression cannot be computed over a group, so the caller keeps its own path.
  • Method Summary

    Modifier and Type
    Method
    Description
    The FROM clause's alias map paired with baseTable(), or null for a single relation.
    Every joined relation paired with baseTable(), or null for a single relation.
    The relation the groups were formed over — the FROM table the projected rows no longer are.
    valueOf(Row projectedRow, String expressionText)
    The expression's value for one grouped output row.
  • Field Details

    • UNRESOLVED

      static final Object UNRESOLVED
      Answered when the expression cannot be computed over a group, so the caller keeps its own path.
  • Method Details

    • valueOf

      Object valueOf(Row projectedRow, String expressionText)
      The expression's value for one grouped output row.
      Parameters:
      projectedRow - the output row, one per group
      expressionText - the expression as written
      Returns:
      the value, or UNRESOLVED when this row has no group or the text does not compute
    • baseTable

      Table baseTable()
      The relation the groups were formed over — the FROM table the projected rows no longer are.

      A window stage over grouped rows resolves VALUES against the projected shape, but a DECLARED type is a property of the base relation: RATIO_TO_REPORT(SUM(a)) OVER () beside GROUP BY a is NUMBER(30,8) on the account because a is the NUMBER(10,2) column it always was, not the untyped slot the projection put it in. This is where that relation is found.

      Returns:
      the base table, never null
    • aliasToTable

      Map<String,Table> aliasToTable()
      The FROM clause's alias map paired with baseTable(), or null for a single relation.
      Returns:
      alias to table, or null
    • allTables

      List<Table> allTables()
      Every joined relation paired with baseTable(), or null for a single relation.
      Returns:
      the joined tables, or null