feat(sql): add generate_series() functions#5761
Merged
bluestreak01 merged 17 commits intomasterfrom Jun 27, 2025
Merged
Conversation
…, double and timestamp series
…n` would initialise lastValue=0 (default), but then reset it to lastValue=null. also, cacheValue was not being reset between runs
jerrinot
reviewed
Jun 20, 2025
...ain/java/io/questdb/griffin/engine/functions/date/GenerateSeriesLongRecordCursorFactory.java
Outdated
Show resolved
Hide resolved
jerrinot
reviewed
Jun 20, 2025
...ain/java/io/questdb/griffin/engine/functions/date/GenerateSeriesLongRecordCursorFactory.java
Show resolved
Hide resolved
jerrinot
reviewed
Jun 23, 2025
...java/io/questdb/griffin/engine/functions/date/AbstractGenerateSeriesRecordCursorFactory.java
Outdated
Show resolved
Hide resolved
jerrinot
reviewed
Jun 23, 2025
.../questdb/griffin/engine/functions/date/GenerateSeriesTimestampStringRecordCursorFactory.java
Outdated
Show resolved
Hide resolved
jerrinot
reviewed
Jun 23, 2025
.../questdb/griffin/engine/functions/date/GenerateSeriesTimestampStringRecordCursorFactory.java
Outdated
Show resolved
Hide resolved
Contributor
jerrinot
requested changes
Jun 23, 2025
Contributor
jerrinot
left a comment
There was a problem hiding this comment.
some easy to fix issues should be resolved before releasing it
jerrinot
approved these changes
Jun 26, 2025
jerrinot
approved these changes
Jun 27, 2025
Contributor
[PR Coverage check]😍 pass : 361 / 396 (91.16%) file detail
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

There have been some pain points with
timestamp_sequencefor a while:hasNextcalls.long_sequence.For example:
This should return timestamps in minutes, but it actually returns them in two minute increments.
This is because the function is accessed both for the
ORDER BY tsclause and in thetsprojection.There are workarounds, for example:
Instead, we can now generate timestamps as a pseudo-table, using
generate_series(NNL/NNS).In Postgres, the range is inclusive. Therefore, you must use
'2025-06-13T10:00:00'::timestamp - 1to omit the final entry, or just adjust the timestamp directly i.e'2025-06-13T09:59:59'or usedateaddi.edateadd('u', -1, '2025-06-13T10:00:00').This PR also includes variants for generating
LONGandDOUBLE:generate_series(LL/LLL)andgenerate_series(DD/DDD). The default increment for theDDandLLcases will be1or1.0.If the third parameter is negative, the result set will be returned in reverse order:
generate_series(1, 5, -2);If the start/end values are back to front, they will be automatically swapped for you:
All variants support constants or bind variable constants.
This PR additionally fixed a long-standing bu when using non-keyed sample by fill prev, wherein dirty state would be left behind in
SimpleMapValuePeeker. In theFILL(PREV)case, since this was not a constant fill, subsequent calls to the function would return different data.Also, there was an issue in the same cursor where the first timestamp of the range would be skipped, which is now also fixed. This wasn't caught in testing because
assertFactoryCursorwould always executeassertTimestampfirst, so both of the cursor calls were run with already 'dirtied' state.Also fixes a dirty state bug in
LastValueDoubleWindowFunctionFactory.