-
Notifications
You must be signed in to change notification settings - Fork 606
Assorted code simplification and doc improvements #131
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
Merged
Conversation
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
To use the new helper effectively, a few related changes were required: - Each of the parse_..._list functions (`parse_cte_list`, `parse_order_by_expr_list`, `parse_select_list`) was replaced with a version that parses a single element of the list (e.g. `parse_cte`), with their callers now using `self.parse_comma_separated(Parser::parse_<one_element>)?` - `parse_with_options` now parses the WITH keyword and a separate `parse_sql_option` function (named after the struct it produces) was added to parse a single k=v option. - `parse_list_of_ids` is gone, with the '.'-separated parsing moved to `parse_object_name`. Custom comma-separated parsing is still used in: - parse_transaction_modes (where the comma separator is optional) - parse_columns (allows optional trailing comma, before the closing ')')
It used to consume the `RParen` closing the encompassing `OVER (`, even when no window frame was parsed, which confused me a bit, even though I wrote it initially. After fixing that, I took the opportunity to reduce nesting and duplication a bit.
The note about WindowFrameBound::Following being only valid "in WindowFrame::end_bound" was both - confusing, as it was based on the ANSI SQL syntax the parser doesn't adhere to -- though it sounded like a promise about the AST one could expect to get from the parser - and incomplete, as the reality is that the bounds validation the SQL engine might want to perform is more complex. For example Postgres documentation says <https://www.postgresql.org/docs/11/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS>: > Restrictions are that frame_start cannot be UNBOUNDED FOLLOWING, > frame_end cannot be UNBOUNDED PRECEDING, and the frame_end choice > cannot appear earlier in the above list of frame_start and frame_end > options than the frame_start choice does — for example RANGE BETWEEN > CURRENT ROW AND offset PRECEDING is not allowed. But, for example, > ROWS BETWEEN 7 PRECEDING AND 8 PRECEDING is allowed, even though it > would never select any rows.
Pull Request Test Coverage Report for Build 413
💛 - Coveralls |
benesch
approved these changes
Jul 10, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for the review! |
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.
Including some follow-ups to #124 and #50 and
parse_comma_separated
(03efcf6)