-
Notifications
You must be signed in to change notification settings - Fork 475
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
Add support for DuckDB functions named arguments with assignment operator #1195
Add support for DuckDB functions named arguments with assignment operator #1195
Conversation
src/ast/mod.rs
Outdated
@@ -4556,13 +4556,16 @@ pub enum FunctionArgOperator { | |||
Equals, | |||
/// function(arg1 => value1) | |||
RightArrow, | |||
/// function(arg1 := value1) | |||
DuckAssignment, |
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.
I suggest a general name like Assignment
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.
I renamed both Token and FunctionArg to Assignment , since snowflake uses it too
What do you think @universalmind303 ?
If is best to split the Token rename to another PR I can do it, just let me know, thanks!
…Operator enum variants
Other dialects might use |
Good catch @jmhain, thanks! |
@gstvg Yeah that sounds fine to me! |
Pull Request Test Coverage Report for Build 8582499731Details
💛 - Coveralls |
src/parser/mod.rs
Outdated
let name = self.parse_identifier(false)?; | ||
|
||
self.expect_token(&Token::Assignment)?; | ||
let arg = self.parse_wildcard_expr()?.into(); |
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.
is wildcard included?
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.
Probably not, thanks. To be honest, I just copied from the code few lines above which does the same for =>
and =
. Changing them to parse_expr
doesn't break any test. Don't know if they need it too.
Anyway, i changed mine to parse_expr
, thanks again 🙏
src/parser/mod.rs
Outdated
@@ -8602,6 +8602,18 @@ impl<'a> Parser<'a> { | |||
arg, | |||
operator: FunctionArgOperator::Equals, | |||
}) | |||
} else if dialect_of!(self is DuckDbDialect) && self.peek_nth_token(1) == Token::Assignment |
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.
Normally we also support Generic dialect as well for syntaxes. I took the liberty of adding this in another commit
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.
Thank you for the contribution @gstvg -- sorry I am behind and it took so long to review this
…ator (sqlparser-rs#1195) Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Some nested DuckDB functions use assignment operator