Commit e4cd012
committed
Explicit window frames + LAST_VALUE: new FrameSpec / FrameBound types capture ROWS BETWEEN / RANGE BETWEEN with all five bound shapes (UNBOUNDED PRECEDING / N PRECEDING / CURRENT ROW / N FOLLOWING / UNBOUNDED FOLLOWING) and the single-bound shorthand (ROWS UNBOUNDED PRECEDING ≡ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW). Parser's RejectFrameSpec now raises Msg 10752 with the offending function name for ranking (ROW_NUMBER / RANK / DENSE_RANK / NTILE) and offset (LAG /LEAD) functions; FIRST_VALUE / LAST_VALUE / aggregate-OVER accept frames; frame without ORDER BY → Msg 10756; BETWEEN N FOLLOWING AND N PRECEDING|CURRENT ROW → Msg 4193; RANGE with numeric-offset bounds → Msg 4194 (probe-confirmed matches real SQL Server's separately-licensed-feature gate). Executor's new ComputeFrameExtent walks the no-OB-no-frame → whole partition / OB-only → default RANGE UNBOUNDED PRECEDING TO CURRENT ROW (running total with peer-tie grouping) / explicit-frame → ROWS row-precise arithmetic + RANGE CURRENT ROW peer-scan decision tree, with theoretical-then-clamp empty-frame detection (out-of-partition bounds → typed NULL for SUM/AVG/MIN/MAX/FIRST_VALUE/LAST_VALUE, 0 for COUNT). LAST_VALUE added as a new WindowKind sharing the FIRST_VALUE parse / execute paths keyed on Kind; aggregate-OVER's previous "ORDER BY → NotSupportedException" restriction lifted, with a whole-partition fast path retained when no frame applies. 27 new WindowFrameTests cover running totals (RANGE peer-ties + ROWS row-precise), sliding/expanding/whole-partition aggregates, MIN/MAX/AVG over frames, single-bound shorthand, LAST_VALUE under default (= current-row peer-tie last) vs explicit ROWS UNBOUNDED-to-UNBOUNDED (= partition last), FIRST_VALUE with explicit frame, and every rejection path (10752 across all six disallowed kinds via DataRow, 10756, 4193, 4194, 102 for invalid unbounded ends, 4112 for LAST_VALUE missing ORDER BY). WindowAggregateTests.NotSupportedShapes shrunk: ORDER-BY-in-OVER row deleted (works now), the two frame-without-ORDER-BY rows moved to WindowParserRejections asserting Msg 10756. CLAUDE.md "Not modeled" entry collapsed to RANGE-numeric-offset only; docs/claude/query.md expanded with the full frame grammar, default-frame logic, empty-frame semantics, and per-row extent execution model.
1 parent b15b721 commit e4cd012
10 files changed
Lines changed: 921 additions & 83 deletions
File tree
- SqlServerSimulator.Tests
- SqlServerSimulator
- Errors
- Parser
- Expressions
- docs/claude
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
| 161 | + | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
295 | 299 | | |
296 | 300 | | |
297 | 301 | | |
| |||
300 | 304 | | |
301 | 305 | | |
302 | 306 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
| |||
Large diffs are not rendered by default.
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
305 | 349 | | |
306 | 350 | | |
307 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
| 530 | + | |
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
0 commit comments