-
-
Notifications
You must be signed in to change notification settings - Fork 263
GENERATE_SERIES function #8795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sim1984
wants to merge
9
commits into
FirebirdSQL:master
Choose a base branch
from
sim1984:gen-series
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+460
−1
Open
GENERATE_SERIES function #8795
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
46c836b
GENERATE_SERIES function
sim1984 e2c86bd
don't use temp space
sim1984 8f660b8
fixed after hvlad review
sim1984 328eb39
More transparent code and other fixes according to @asfernandes.
sim1984 84d9f20
support INT128 datatype
sim1984 232c0b1
Use union instead sd::variant
sim1984 e5e04da
Corrected according to @dyemanov
sim1984 d5e333c
correction parse.y
sim1984 68672ea
Use braces if condition has more than one line.
sim1984 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # GENERATE_SERIES function | ||
|
|
||
| The `GENERATE_SERIES` function creates a series of numbers within a specified interval. | ||
| The interval and the step between series values are defined by the user. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ``` | ||
| <generate_series_function> ::= | ||
| GENERATE_SERIES(<start>, <finish> [, <step>]) [AS] <correlation name> [ ( <derived column name> ) ] | ||
| ``` | ||
|
|
||
| ## Arguments | ||
|
|
||
| * `start` - The first value in the interval. `start` is specified as a variable, a literal, or a scalar expression of type | ||
| `SMALLINT`, `INTEGER`, `BIGINT`, `INT128` or `NUMERIC/DECIMAL`. | ||
|
|
||
| * `finish` - The last value in the interval. `finish` is specified as a variable, a literal, or a scalar expression of | ||
| type `SMALLINT`, `INTEGER`, `BIGINT`, `INT128` or `NUMERIC/DECIMAL`. The series stops once the last generated step value | ||
| exceeds the `finish` value. | ||
|
|
||
| * `step` - Indicates the number of values to increment or decrement between steps in the series. `step` is an expression | ||
| of type `SMALLINT`, `INTEGER`, `BIGINT`, `INT128` or `NUMERIC/DECIMAL`. | ||
| `step` can be either negative or positive, but can't be zero (0). This argument is optional. The default value for `step` is 1. | ||
|
|
||
| ## Returning type | ||
|
|
||
| The function `GENERATE_SERIES` returns a set with `BIGINT`, `INT128` or `NUMERIC(18, x)/NUMERIC(38, x)` column, | ||
| where the scale is determined by the maximum of the scales of the function arguments. | ||
|
|
||
| ## Rules | ||
|
|
||
| * If `start > finish` and a negative `step` value is specified, an empty set is returned. | ||
|
|
||
| * If `start < finish` and a positive `step` value is specified, an empty set is returned. | ||
|
|
||
| * If the `step` argument is zero, an error is thrown. | ||
|
|
||
| ## Examples | ||
|
|
||
| ``` | ||
| SELECT n | ||
| FROM GENERATE_SERIES(1, 3) AS S(n); | ||
|
|
||
| SELECT n | ||
| FROM GENERATE_SERIES(3, 1, -1) AS S(n); | ||
|
|
||
| SELECT n | ||
| FROM GENERATE_SERIES(0, 9.9, 0.1) AS S(n); | ||
|
|
||
| SELECT | ||
| DATEADD(n MINUTE TO timestamp '2025-01-01 12:00') AS START_TIME, | ||
| DATEADD(n MINUTE TO timestamp '2025-01-01 12:00:59.9999') AS FINISH_TIME | ||
| FROM GENERATE_SERIES(0, 59) AS S(n); | ||
| ``` | ||
|
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 133 shift/reduce conflicts, 13 reduce/reduce conflicts. | ||
| 134 shift/reduce conflicts, 13 reduce/reduce conflicts. |
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.