-
Notifications
You must be signed in to change notification settings - Fork 601
Add support for qualified column names in JOIN ... USING #1663
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
Conversation
3b4b69e
to
22182a2
Compare
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.
Thanks @yoavcloud! Left some comments
src/parser/mod.rs
Outdated
allow_empty: bool, | ||
) -> Result<Vec<ObjectName>, ParserError> { | ||
self.parse_parenthesized_column_list_inner(optional, allow_empty, |p| { | ||
p.parse_object_name(false) |
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.
Should the in_table_clause
be configurable here? I thinking it's supposed to be set to true when parsing a USING
clause given the behavior being fixed
tests/sqlparser_snowflake.rs
Outdated
// Snowflake allows fully-qualified column names inside USING | ||
snowflake().verified_stmt("SELECT * FROM tbl1 AS t1 JOIN tbl2 AS t2 USING(t2.col1)"); |
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.
maybe we can add this scenario to the parse_joins_using
test in common.rs instead?
src/parser/mod.rs
Outdated
self.parse_parenthesized_column_list_inner(optional, allow_empty, |p| p.parse_identifier()) | ||
} | ||
|
||
/// Parses a parenthesized comma-separated list of unqualified, possibly quoted identifiers |
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.
The doc comment doesn't seem to match the behavior (unqualified vs qualified)? also it could be nice if the doc highlights that the parenthesis is also expected in the input (maybe with an example)
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 @yoavcloud!
cc @alamb
…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)
It appears that Snowflake allows specifying qualified column names in the USING column list. For example:
SELECT * FROM tbl1 AS t1 JOIN tbl2 AS t2 USING(t2.col1)
BTW, it's worthwhile exploring changing all occurrences to parse column lists as Vec instead of Vec, there are likely other statement patterns that get rejected...