iffyio commented on code in PR #1765:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1765#discussion_r1992132116


##########
src/parser/mod.rs:
##########
@@ -9490,6 +9490,55 @@ impl<'a> Parser<'a> {
         }
     }
 
+    pub fn parse_optional_limit_clause(&mut self) -> 
Result<Option<LimitClause>, ParserError> {

Review Comment:
   ```suggestion
      fn parse_optional_limit_clause(&mut self) -> Result<Option<LimitClause>, 
ParserError> {
   ```



##########
src/parser/mod.rs:
##########
@@ -9490,6 +9490,55 @@ impl<'a> Parser<'a> {
         }
     }
 
+    pub fn parse_optional_limit_clause(&mut self) -> 
Result<Option<LimitClause>, ParserError> {
+        let mut offset = if self.parse_keyword(Keyword::OFFSET) {
+            Some(self.parse_offset()?)
+        } else {
+            None
+        };
+
+        let (limit, limit_by) = if self.parse_keyword(Keyword::LIMIT) {
+            let expr = self.parse_limit()?;
+
+            if self.dialect.supports_limit_comma()
+                && offset.is_none()
+                && expr.is_some() // ALL not supported with comma
+                && self.consume_token(&Token::Comma)
+            {
+                return Ok(Some(LimitClause::OffsetCommaLimit {
+                    offset: expr.unwrap(), // Just checked `expr.is_some()`

Review Comment:
   we can replace the unwrap with an explicit error?



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to