LucaCappelletti94 commented on code in PR #2513:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2513#discussion_r4097901848


##########
src/parser/mod.rs:
##########
@@ -2705,13 +2705,39 @@ impl<'a> Parser<'a> {
         } else {
             (self.parse_window_frame_bound()?, None)
         };
+        let exclusion = if self.dialect.supports_window_frame_exclusion()
+            && self.parse_keyword(Keyword::EXCLUDE)
+        {
+            Some(self.parse_window_frame_exclusion()?)
+        } else {
+            None
+        };
         Ok(WindowFrame {
             units,
             start_bound,
             end_bound,
+            exclusion,
         })
     }
 
+    /// Parse a window frame exclusion clause following `EXCLUDE`.
+    pub fn parse_window_frame_exclusion(&mut self) -> 
Result<WindowFrameExclusion, ParserError> {
+        if self.parse_keywords(&[Keyword::CURRENT, Keyword::ROW]) {
+            Ok(WindowFrameExclusion::CurrentRow)
+        } else if self.parse_keyword(Keyword::GROUP) {
+            Ok(WindowFrameExclusion::Group)
+        } else if self.parse_keyword(Keyword::TIES) {
+            Ok(WindowFrameExclusion::Ties)
+        } else if self.parse_keyword(Keyword::NO)

Review Comment:
   You should match `NO OTHERS` by keyword.
   
   ```suggestion
           } else if self.parse_keywords(&[Keyword::NO, Keyword::OTHERS]) {
   ```



##########
tests/sqlparser_postgres.rs:
##########
@@ -10037,3 +10037,31 @@ fn parse_bitstring_literal_escaping() {
     pg_and_generic().verified_stmt("SELECT B''''");
     pg_and_generic().verified_stmt("SELECT B'it''s'");
 }
+
+#[test]
+fn parse_window_frame_exclusion() {
+    let dialects = pg_and_generic();
+    for sql in [
+        "SELECT sum(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE 
TIES)",
+        "SELECT sum(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW 
EXCLUDE CURRENT ROW)",
+        "SELECT sum(1) OVER (ROWS CURRENT ROW EXCLUDE GROUP)",
+        "SELECT sum(1) OVER (ROWS CURRENT ROW EXCLUDE NO OTHERS)",
+    ] {
+        dialects.verified_stmt(sql);
+    }
+

Review Comment:
   Red test associated to other note.
   
   ```suggestion
       dialects.one_statement_parses_to(
           "SELECT sum(1) OVER (ROWS CURRENT ROW exclude no others)",
           "SELECT sum(1) OVER (ROWS CURRENT ROW EXCLUDE NO OTHERS)",
       );
   ```



-- 
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]

Reply via email to