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


##########
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:
   Done in 69798b70: added `OTHERS` to `keywords.rs` and switched to 
`parse_keywords(&[Keyword::NO, Keyword::OTHERS])`. As a side effect, `EXCLUDE 
NO TIES` now reports `found: NO` instead of consuming `NO` first; I added that 
as a red test too. `others` still parses as a plain identifier in all dialects.



##########
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:
   Added as suggested. While there, I also switched the other negative cases to 
typed `Err(ParserError::ParserError(...))` assertions (no 
`unwrap_err`/`is_err()`). Also merged current main (add/add conflicts in the 
dialect files and the test file).



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