Repository navigation
Implement window - #478
Implement window#478
Conversation
| current row. If a bound is omitted, segment will extend until the end of the table (or group). | ||
|
|
||
| For example: | ||
| - `rows:0..3` means current row plus two following, |
There was a problem hiding this comment.
I was thinking how to do current — this approach is perfect, can't believe I didn't think of it
There was a problem hiding this comment.
Though I'm still thinking through the answer to the question "what number is the current row?".
Did you think about making 0 the current row on both sides, and the range being inclusive?
It looks like that's how it's defined here:
`rows:-3..0` means two preceding rows plus current row,
but possibly not here:
`rows:..1` means all rows from the start of the table to and including current row,
Or am I missing something?
There was a problem hiding this comment.
Oh, that's a mistake. It should be
`rows:-2..1` means two preceding rows plus current row,
Such indexing was supported by Dijkstra it it seem most natural to me. I also wanted this to be similar to python and rust, while distancing from matlab...
There was a problem hiding this comment.
Wonderful reference and explanation.
Do you think we should have a slightly different syntax for inclusive vs exclusive ranges, like rust has, then? My concern is that SQL ranges are by default inclusive; e.g. BETWEEN 0 and 3, or in 0..3 includes both 0 & 3, as does range:0..3
There are a few areas like this where it's difficult to completely upgrade SQL, because we can't see through to the data. So we can either separate off the parts we can — e.g. different approach to rows than other ranges — or compromises to their standards — e.g. just use inclusive for everything.
WDYT?
|
|
||
| For ease of use, there are two flags that override `rows` or `range`: | ||
|
|
||
| - `expanding:true` is an alias for `range:..1`. Sum using this window is also known as "cumulative sum". |
There was a problem hiding this comment.
Wouldn't this be (but probably I'm misunderstanding):
| - `expanding:true` is an alias for `range:..1`. Sum using this window is also known as "cumulative sum". | |
| - `expanding:true` is an alias for `rows:..1`. Sum using this window is also known as "cumulative sum". |
?
There was a problem hiding this comment.
@aljazerzen just wanted to check you saw this. IIUC this only matters when there are duplicate values; otherwise they're the same (or possibly my SQL knowledge is rusty)
|
Very impressive! I left a few comments re the I think this is the last big code feature in the compiler for 0.2! FYI I'll have some time this weekend to clean up things we need for 0.2 — docs / website / follow-ups etc. |
Co-authored-by: Maximilian Roos <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
I've:
windowtransform, including docs,AnyOfwrapper for types, so functions such assumcan returncolumn | scalarselectandderivebe window functions and not aggregationCloses #420
Closes #3