- Notifications
You must be signed in to change notification settings - Fork5.1k
Commit25a30bb
committed
Add IGNORE NULLS/RESPECT NULLS option to Window functions.
Add IGNORE NULLS/RESPECT NULLS option (null treatment clause) to lead,lag, first_value, last_value and nth_value window functions. Ifunspecified, the default is RESPECT NULLS which includes NULL valuesin any result calculation. IGNORE NULLS ignores NULL values.Built-in window functions are modified to call new APIWinCheckAndInitializeNullTreatment() to indicate whether they acceptIGNORE NULLS/RESPECT NULLS option or not (the API can be called byuser defined window functions as well). If WinGetFuncArgInPartition'sallowNullTreatment argument is true and IGNORE NULLS option is given,WinGetFuncArgInPartition() or WinGetFuncArgInFrame() will returnevaluated function's argument expression on specified non NULL row (ifit exists) in the partition or the frame.When IGNORE NULLS option is given, window functions need to visit andevaluate same rows over and over again to look for non null rows. Tomitigate the issue, 2-bit not null information array is created whileexecuting window functions to remember whether the row has beenalready evaluated to NULL or NOT NULL. If already evaluated, we couldskip the evaluation work, thus we could get better performance.Author: Oliver Ford <ojford@gmail.com>Co-authored-by: Tatsuo Ishii <ishii@postgresql.org>Reviewed-by: Krasiyan Andreev <krasiyan@gmail.com>Reviewed-by: Andrew Gierth <andrew@tao11.riddles.org.uk>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: David Fetter <david@fetter.org>Reviewed-by: Vik Fearing <vik@postgresfriends.org>Reviewed-by: "David G. Johnston" <david.g.johnston@gmail.com>Reviewed-by: Chao Li <lic@highgo.com>Discussion:https://postgr.es/m/flat/CAGMVOdsbtRwE_4+v8zjH1d9xfovDeQAGLkP_B6k69_VoFEgX-A@mail.gmail.com1 parent381f5cf commit25a30bb
File tree
15 files changed
+1092
-61
lines changed- doc/src/sgml
- func
- src
- backend
- catalog
- executor
- optimizer/util
- parser
- utils/adt
- include
- nodes
- parser
- test/regress
- expected
- sql
15 files changed
+1092
-61
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
140 | 140 |
| |
141 | 141 |
| |
142 | 142 |
| |
143 |
| - | |
| 143 | + | |
144 | 144 |
| |
145 | 145 |
| |
146 | 146 |
| |
| |||
165 | 165 |
| |
166 | 166 |
| |
167 | 167 |
| |
168 |
| - | |
| 168 | + | |
169 | 169 |
| |
170 | 170 |
| |
171 | 171 |
| |
| |||
188 | 188 |
| |
189 | 189 |
| |
190 | 190 |
| |
191 |
| - | |
| 191 | + | |
192 | 192 |
| |
193 | 193 |
| |
194 | 194 |
| |
| |||
202 | 202 |
| |
203 | 203 |
| |
204 | 204 |
| |
205 |
| - | |
| 205 | + | |
206 | 206 |
| |
207 | 207 |
| |
208 | 208 |
| |
| |||
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
219 |
| - | |
| 219 | + | |
220 | 220 |
| |
221 | 221 |
| |
222 | 222 |
| |
| |||
265 | 265 |
| |
266 | 266 |
| |
267 | 267 |
| |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
268 | 281 |
| |
269 | 282 |
| |
270 |
| - | |
271 |
| - | |
272 |
| - | |
273 |
| - | |
274 |
| - | |
275 |
| - | |
276 |
| - | |
277 |
| - | |
278 |
| - | |
279 |
| - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
280 | 288 |
| |
281 | 289 |
| |
282 | 290 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1834 | 1834 |
| |
1835 | 1835 |
| |
1836 | 1836 |
| |
1837 |
| - | |
1838 |
| - | |
| 1837 | + | |
| 1838 | + | |
1839 | 1839 |
| |
1840 | 1840 |
| |
1841 | 1841 |
| |
| |||
1873 | 1873 |
| |
1874 | 1874 |
| |
1875 | 1875 |
| |
1876 |
| - | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
1877 | 1879 |
| |
1878 | 1880 |
| |
1879 | 1881 |
| |
| |||
2048 | 2050 |
| |
2049 | 2051 |
| |
2050 | 2052 |
| |
2051 |
| - | |
| 2053 | + | |
2052 | 2054 |
| |
2053 | 2055 |
| |
2054 | 2056 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
518 | 518 |
| |
519 | 519 |
| |
520 | 520 |
| |
521 |
| - | |
| 521 | + | |
522 | 522 |
| |
523 | 523 |
| |
524 | 524 |
| |
|
0 commit comments
Comments
(0)