Repository navigation
Fix parsing of reserved keyword select items after a comma #2969
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
Jaden-Varkey
wants to merge
4
commits into
apache:main
Choose a base branch
from
Jaden-Varkey:fix/2049-keyword-after-comma
base: main
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.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1cdb748
Fix parsing of reserved keyword select items after a comma
Jaden-Varkey 61d34f8
Limit keyword select items to LIMIT and OFFSET
Jaden-Varkey 72996fe
Treat every select item terminator as ending a LIMIT/OFFSET column
Jaden-Varkey 4d8a864
Merge remote-tracking branch 'origin/main' into fix/2049-keyword-afte…
Jaden-Varkey 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 @@ | ||
| SELECT a, offset FROM t; |
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23517,6 +23517,53 @@ fn parse_national_character_string_types() { | |||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| #[test] | ||||||||||
| fn parse_projection_trailing_comma_keyword_column() { | ||||||||||
| let dialects = all_dialects_where(|d| d.supports_projection_trailing_commas()); | ||||||||||
|
|
||||||||||
| for sql in [ | ||||||||||
| "SELECT offset FROM t", | ||||||||||
| "SELECT offset, 'a' AS a FROM t", | ||||||||||
| "SELECT 'a' AS a, offset FROM t", | ||||||||||
| "SELECT a, offset FROM t", | ||||||||||
| "SELECT a, limit FROM t", | ||||||||||
| "SELECT a, offset, b FROM t", | ||||||||||
| "SELECT a, offset AS o FROM t", | ||||||||||
| "SELECT * FROM (SELECT a, offset FROM t)", | ||||||||||
| "SELECT a, offset", | ||||||||||
| "SELECT * FROM (SELECT a, offset) AS s", | ||||||||||
| "SELECT a, offset WHERE b", | ||||||||||
| "SELECT a, offset INTO u FROM t", | ||||||||||
| "SELECT a, offset UNION SELECT 1, 2", | ||||||||||
| ] { | ||||||||||
| dialects.verified_stmt(sql); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| dialects.one_statement_parses_to("SELECT a, FROM t", "SELECT a FROM t"); | ||||||||||
| dialects.one_statement_parses_to("SELECT a, LIMIT 1", "SELECT a LIMIT 1"); | ||||||||||
| assert_eq!( | ||||||||||
| dialects | ||||||||||
| .parse_sql_statements("SELECT a, union, b FROM t") | ||||||||||
| .unwrap_err(), | ||||||||||
| ParserError::ParserError( | ||||||||||
| "Expected: SELECT, VALUES, or a subquery in the query body, found: ,".to_string() | ||||||||||
| ) | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| let dialects = all_dialects_where(|d| d.supports_empty_projections()); | ||||||||||
| for sql in [ | ||||||||||
| "SELECT offset FROM t", | ||||||||||
| "SELECT limit, offset FROM t", | ||||||||||
| "SELECT offset AS o FROM t", | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should cover the same in the first position of an empty-projection dialect. Both fail on the current head, the first with
Suggested change
|
||||||||||
| "SELECT offset", | ||||||||||
| "SELECT offset WHERE b", | ||||||||||
| ] { | ||||||||||
| dialects.verified_stmt(sql); | ||||||||||
| } | ||||||||||
| dialects.verified_stmt("SELECT LIMIT 1"); | ||||||||||
| dialects.verified_stmt("SELECT OFFSET 1"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| #[test] | ||||||||||
| fn parse_create_procedure_string_body() { | ||||||||||
| match verified_stmt("CREATE PROCEDURE p (a INT) LANGUAGE sql AS 'INSERT INTO t VALUES (a)'") { | ||||||||||
|
|
||||||||||
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.
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.
You should limit the column reading to
LIMITandOFFSET. As written it covers every keyword inRESERVED_FOR_COLUMN_ALIAS.Since you are using claude to write this code, you sure make it fuzz and test extensively the syntax you want to add.