mvzink commented on code in PR #1538:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1538#discussion_r1861074669
##########
src/parser/mod.rs:
##########
@@ -4693,9 +4699,59 @@ impl<'a> Parser<'a> {
if_not_exists,
temporary,
to,
+ params: mysql_create_view_params,
})
}
+ /// Parse optional algorithm, definer, and security context parameters for
[MySQL]
+ ///
+ /// [MySQL]: https://dev.mysql.com/doc/refman/9.1/en/create-view.html
+ fn parse_mysql_create_view_params(&mut self) ->
Result<Option<MySQLViewParams>, ParserError> {
+ let algorithm = if self.parse_keyword(Keyword::ALGORITHM) {
+ self.expect_token(&Token::Eq)?;
+ Some(
+ match self.expect_one_of_keywords(&[
+ Keyword::UNDEFINED,
+ Keyword::MERGE,
+ Keyword::TEMPTABLE,
+ ])? {
+ Keyword::UNDEFINED => MySQLViewAlgorithm::Undefined,
+ Keyword::MERGE => MySQLViewAlgorithm::Merge,
+ Keyword::TEMPTABLE => MySQLViewAlgorithm::TempTable,
+ _ => unreachable!(),
Review Comment:
Did so be rewinding the token to then call `self.expected` (otherwise I
don't see how to get the location that it wants). Seems a bit clunky when this
is exactly the error that `self.expect_one_of_keywords` should have already
returned. The only way we would hit this branch is if someone added a keyword
to the `self.expect_one_of_keywords` call but forgot to add a corresponding
`match` arm. One overengineered solution which could be used here and elsewhere
would be to wrap it in a macro that looks like a `match` but collects the
keywords from the match arms into the `self.expect_one_of_keywords` for you.
--
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]