Add support for Snowflake column aliases that use SQL keywords#1632
Merged
iffyio merged 3 commits intoapache:mainfrom Jan 16, 2025
Merged
Add support for Snowflake column aliases that use SQL keywords#1632iffyio merged 3 commits intoapache:mainfrom
iffyio merged 3 commits intoapache:mainfrom
Conversation
e393b20 to
98a5627
Compare
iffyio
reviewed
Jan 13, 2025
Contributor
iffyio
left a comment
There was a problem hiding this comment.
Thanks @yoavcloud! The approach sounds reasonable to me, left a comment
src/parser/mod.rs
Outdated
| Ok(IdentWithAlias { ident, alias }) | ||
| } | ||
|
|
||
| // Optionally parses an alias for a select list item |
Contributor
There was a problem hiding this comment.
Suggested change
| // Optionally parses an alias for a select list item | |
| /// Optionally parses an alias for a select list item |
src/parser/mod.rs
Outdated
Comment on lines
8749
to
8751
| if self | ||
| .dialect | ||
| .is_select_item_alias(after_as, &w.keyword, self) => |
Contributor
There was a problem hiding this comment.
it looks like the code is simlar to parse_optional_alias and they only differ in this clause? Thinking it would be nice to reuse the logic if so, maybe we have the shared function taking reserved_kwds as an optional argument and if None is passed, we use dialect.is_select_item_alias()
98a5627 to
dd5be2f
Compare
Contributor
Author
|
@iffyio in this iteration I re-used the logic but also aligned parsing of table aliases to column aliases, enabling customization by dialects. LMKWYT |
iffyio
approved these changes
Jan 16, 2025
Contributor
iffyio
left a comment
There was a problem hiding this comment.
LGTM! Thanks @yoavcloud!
cc @alamb
hansott
added a commit
to hansott/datafusion-sqlparser-rs
that referenced
this pull request
Jan 23, 2025
…o escape-literals * 'main' of github.com:hansott/datafusion-sqlparser-rs: National strings: check if dialect supports backslash escape (apache#1672) Add support for Create Iceberg Table statement for Snowflake parser (apache#1664) Add support for Snowflake account privileges (apache#1666) Update rat_exclude_file.txt (apache#1670) Update verson to 0.54.0 and update changelog (apache#1668) Add support for Snowflake AT/BEFORE (apache#1667) Add support for qualified column names in JOIN ... USING (apache#1663) Add support for `IS [NOT] [form] NORMALIZED` (apache#1655) fix parsing of `INSERT INTO ... SELECT ... RETURNING ` (apache#1661) Add support for Snowflake column aliases that use SQL keywords (apache#1632)
Vedin
pushed a commit
to Embucket/datafusion-sqlparser-rs
that referenced
this pull request
Feb 3, 2025
Vedin
pushed a commit
to Embucket/datafusion-sqlparser-rs
that referenced
this pull request
Feb 3, 2025
Vedin
added a commit
to Embucket/datafusion-sqlparser-rs
that referenced
this pull request
Feb 3, 2025
apache#1632)" This reverts commit bc153a4.
ayman-sigma
pushed a commit
to sigmacomputing/sqlparser-rs
that referenced
this pull request
Apr 10, 2025
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.
Attempts at solving issue #1607
Snowflake is not very strict with using SQL keywords as select list item aliases. Added support for the dialect to control if a word is parsed as an alias or not. Parsing of aliases is quite centralized now, and this PR breaks that up a bit, so feedback is welcomed if this is a good approach or alternative solutions are preferred.