Documentation

Provenance.Window

The window operator's token #

A window gives every row of its input a further column: the aggregate over that row's frame. It removes no row, merges none, and changes no annotation – each row keeps the one it came with, and no group-existence factor arises, because a window creates no group.

What the row gains is an aggregate token, built from its frame exactly as a grouping builds one from its group. Which convention the token is read in is decided per row, by whether the row is in its own frame: a row that is reads its aggregate as a group's, never over nothing, while a row that is not may have an empty frame in a world where it is itself present, and its aggregate then ranges over no occurrence at all.

That is the second user of the scalar convention, and it arrives for the same reason as the first: a row whose existence does not guarantee its aggregate anything to range over.

The operator #

A window maps each occurrence of its input to one output occurrence: the same row, one column longer, with the same annotation and nothing pending. Which occurrence it is matters, because two occurrences carrying the same row may have different frames – that is what the family reading is for.

def ValueFrame.window {T K : Type} {n m p : ℕ} [ValueType T] [HasAltLinearOrder K] (P : Tuple (Fin n) m) (O : Tuple (Fin n) p) (o : OrderSpec p) (w : ValueFrame T p) (t : Term T n) (f : SeqAggFunc T) (r : OccFam (AnnotatedTuple T K n)) :
OccFam (GenRow T K (n + 1))

The window operator on a family: every occurrence keeps its row and its annotation, and gains the token of its frame.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    Dependency graph

    The window on a relation #

    Applying the operator to a relation means reading it as a family, and any two readings give the same answer, so the relation is what the answer is about.

    noncomputable def ValueFrame.windowRel {T K : Type} {n m p : ℕ} [ValueType T] [HasAltLinearOrder K] (P : Tuple (Fin n) m) (O : Tuple (Fin n) p) (o : OrderSpec p) (w : ValueFrame T p) (t : Term T n) (f : SeqAggFunc T) (r : AnnotatedRelation T K n) :
    Multiset (GenRow T K (n + 1))

    The window on a relation: read it as a family, apply the operator, forget the index.

    Equations
    Instances For
      Dependency graph

      The evaluator's window is this operator #

      The general evaluator computes a window on the canonical indexing of its input, because an evaluator has to be computable and a choice of indexing is not. What it computes is nonetheless the operator above on any indexing, so nothing in the answer depends on the canonical one having been chosen.