runWindows runs a query composed of expressions containing
window
functions.
runWindows is similar to Opaleye.aggregate, with the main
difference being that in a window query, each input row corresponds
to one output row, whereas aggregation queries fold the entire
input query down into a single row per group. In Haskell
terminology, Opaleye.aggregate is to foldl as runWindows is
to scanl.
Moduleopaleye-0.10.8.0Haskell2010
Opaleye.Window
Support for PostgreSQL window functions
- 3 types
- 16 values
- Packageopaleye-0.10.8.0
- Exports19
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceWindow.hs
Run window functions on a Select
1 declarationCreate Windows
2 declarationsYou can create Windows using over, and combine and manipulate
them using the Applicative and Profunctor
operations.
Instances3Profunctor, Functor, Applicative
Profunctor WindowsDefined in opaleye-0.10.8.0 · Opaleye.Internal.WindowFunctor (Windows a)Defined in opaleye-0.10.8.0 · Opaleye.Internal.WindowApplicative (Windows a)Defined in opaleye-0.10.8.0 · Opaleye.Internal.Window
over applies a WindowFunction on a particular Window. For example,
over (aggregatorWindowFunction Opaleye.sum salary) (partitionBy department) (Opaleye.desc salary)
If you want to use a Window that consists of the entire SELECT
then supply mempty for the Window a argument. If you don't
want to order the Window then supply mempty for the Order
a argument.
Create a Window
2 declarationsIn PostgreSQL, window functions must specify the "window" over
which they operate. The syntax for this looks like: SUM(salary)
OVER (PARTITION BY department). The Opaleye type Window
represents the segment consisting of the PARTIION BY.
You can create a Window using partitionBy and combine two
Windows in a single one which combines the partition of both by
using <>.
The window where each partition shares the same value for the
given Field.
Create a WindowFunction
1 declarationWindowFunction represents expressions that contain window
functions.
You can choose a WindowFunction from the options below, and
combine and manipulate them using the Applicative and
Profunctor operations.
Instances3Profunctor, Functor, Applicative
Profunctor WindowFunctionDefined in opaleye-0.10.8.0 · Opaleye.Internal.WindowFunctor (WindowFunction a)Defined in opaleye-0.10.8.0 · Opaleye.Internal.WindowApplicative (WindowFunction a)Defined in opaleye-0.10.8.0 · Opaleye.Internal.Window
Window functions
13 declarationsYou might like to also refer to the Postgres documentation page that describes its window functions.
A WindowFunction that doesn't actually contain any window function.
aggregatorWindowFunction allows the use of Aggregators in
WindowFunctions. In particular, aggregatorWindowFunction
gives a running total (when combined with an order
argument to over).Opaleye.sum