on dev help sign in
window docs
commit6e3af0519cef1061d25bf1edbbb4ebbf86f1b602 authorEitan Chatav <eitan@Eitans-MacBook-Pro.local> dateFri 12 Apr 2019, 20:43 (8 years ago) parent3113a7a
1 file changed+11−1
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Window.hs+11−1
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Window.hs+11−1
@@ -100,7 +100,9 @@ data WindowDefinition outer commons grp schemas params from where
100100 WindowDefinition
101101 :: SOP.SListI bys
102102 => NP (Expression outer commons grp schemas params from) bys
103+ -- ^ partitions
103104 -> [SortExpression outer commons grp schemas params from]
105+ -- ^ ordering
104106 -> WindowDefinition outer commons grp schemas params from
105107
106108instance OrderBy WindowDefinition where
@@ -127,7 +129,7 @@ the same partition as the current row.
127129-}
128130partitionBy
129131 :: SOP.SListI bys
130− => NP (Expression outer commons grp schemas params from) bys
132+ => NP (Expression outer commons grp schemas params from) bys -- ^ partitions
131133 -> WindowDefinition outer commons grp schemas params from
132134partitionBy bys = WindowDefinition bys []
133135
@@ -193,6 +195,7 @@ unsafeWindowFunctionN fun xs = UnsafeWindowFunction $ fun <>
193195 parenthesized (renderCommaSeparated renderSQL xs)
194196
195197{- | rank of the current row with gaps; same as `rowNumber` of its first peer
198+
196199>>> printSQL rank
197200rank()
198201-}
@@ -200,6 +203,7 @@ rank :: WinFun0 ('NotNull 'PGint8)
200203rank = UnsafeWindowFunction "rank()"
201204
202205{- | number of the current row within its partition, counting from 1
206+
203207>>> printSQL rowNumber
204208row_number()
205209-}
@@ -207,6 +211,7 @@ rowNumber :: WinFun0 ('NotNull 'PGint8)
207211rowNumber = UnsafeWindowFunction "row_number()"
208212
209213{- | rank of the current row without gaps; this function counts peer groups
214+
210215>>> printSQL denseRank
211216dense_rank()
212217-}
@@ -214,6 +219,7 @@ denseRank :: WinFun0 ('NotNull 'PGint8)
214219denseRank = UnsafeWindowFunction "dense_rank()"
215220
216221{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
222+
217223>>> printSQL percentRank
218224percent_rank()
219225-}
@@ -222,6 +228,7 @@ percentRank = UnsafeWindowFunction "percent_rank()"
222228
223229{- | cumulative distribution: (number of partition rows
224230preceding or peer with current row) / total partition rows
231+
225232>>> printSQL cumeDist
226233cume_dist()
227234-}
@@ -230,6 +237,9 @@ cumeDist = UnsafeWindowFunction "cume_dist()"
230237
231238{- | integer ranging from 1 to the argument value,
232239dividing the partition as equally as possible
240+
241+>>> printSQL $ ntile 5
242+ntile(5)
233243-}
234244ntile :: WinFun1 ('NotNull 'PGint4) ('NotNull 'PGint4)
235245ntile = unsafeWindowFunction1 "ntile"