yoavcloud commented on code in PR #1501:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1501#discussion_r1835307304
##########
src/parser/mod.rs:
##########
@@ -12289,6 +12352,137 @@ impl<'a> Parser<'a> {
}
false
}
+
+ /// Look for an expected keyword, without consuming it
+ fn peek_keyword(&self, expected: Keyword) -> bool {
+ match self.peek_token().token {
+ Token::Word(w) => expected == w.keyword,
+ _ => false,
+ }
+ }
+
+ /// Look for one of expected keyword, without consuming it
+ fn peek_keywords(&self, expected: &[Keyword]) -> bool {
+ for kw in expected {
+ if self.peek_keyword(*kw) {
+ return true;
+ }
+ }
+ false
+ }
+
+ fn parse_show_opt_in(&mut self) -> Result<Option<ShowStatementIn>,
ParserError> {
+ let clause = match self.parse_one_of_keywords(&[Keyword::FROM,
Keyword::IN]) {
+ Some(Keyword::FROM) => ShowStatementInClause::FROM,
+ Some(Keyword::IN) => ShowStatementInClause::IN,
+ _ => return Ok(None),
Review Comment:
I don't think we can get to an unexpected state here because we will only
get a Some if the parser consumed a FROM or an IN keyword. If it's neither, it
means this show option does not exist in the statement and no other tokens were
consumed, so we should just return the None.
--
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]