iffyio commented on code in PR #1476:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1476#discussion_r1835448776
##########
src/parser/mod.rs:
##########
@@ -7156,6 +7156,35 @@ impl<'a> Parser<'a> {
partition,
with_name,
}
+ } else if self.dialect.supports_alter_table_update() &&
self.parse_keyword(Keyword::UPDATE)
+ {
+ let mut assignments = vec![];
Review Comment:
One minor request, could we move this new block to its own function to keep
the branch of the current function smaller/more-focused?
##########
src/parser/mod.rs:
##########
@@ -7156,6 +7156,35 @@ impl<'a> Parser<'a> {
partition,
with_name,
}
+ } else if self.dialect.supports_alter_table_update() &&
self.parse_keyword(Keyword::UPDATE)
+ {
+ let mut assignments = vec![];
+ loop {
+ let target = self.parse_assignment_target()?;
+ self.expect_token(&Token::Eq)?;
+ // NOTE: Maybe it's better to save the index before
parse_subexpr to do a real look
Review Comment:
Ah so regarding the earlier comment, I think what we could do would be to
make `self.parse_assignment` reusable:
```rust
pub fn parse_assignment(&mut self) -> Result<Assignment, ParserError> {
self.parse_assignment_with_prec(self.dialect.prec_unknown())
}
fn parse_assignment_with_precedence(self, precedence: u8) ->
Result<Assignment, ParserError> {
let target = self.parse_assignment_target()?;
self.expect_token(&Token::Eq)?;
let value = self.parse_subexpr(precedence)?;
Ok(Assignment { target, value })
}
```
That would make it possible to use `parse_comma_separated` as well, since
the issue seems to be with the `IN PARTITION` precedence when parsing the
assigned expr
##########
src/parser/mod.rs:
##########
@@ -1081,7 +1081,7 @@ impl<'a> Parser<'a> {
self.parse_bigquery_struct_literal()
}
Keyword::PRIOR if matches!(self.state, ParserState::ConnectBy)
=> {
- let expr =
self.parse_subexpr(self.dialect.prec_value(Precedence::PlusMinus))?;
+ let expr =
self.parse_subexpr(self.dialect.prec_value(Precedence::Pipe))?;
Review Comment:
Oh was there a reason for this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]