simonvandel commented on code in PR #1879:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1879#discussion_r2173772494


##########
src/parser/mod.rs:
##########
@@ -9947,6 +9947,51 @@ impl<'a> Parser<'a> {
         Ok(IdentWithAlias { ident, alias })
     }
 
+    /// Parse `identifier [AS] identifier` where the AS keyword is optional
+    pub fn parse_identifier_with_optional_alias(&mut self) -> 
Result<IdentWithAlias, ParserError> {
+        let ident = self.parse_identifier()?;
+        let _after_as = self.parse_keyword(Keyword::AS);
+        let alias = self.parse_identifier()?;
+        Ok(IdentWithAlias { ident, alias })
+    }
+
+    /// Parse comma-separated list of parenthesized queries for pipe operators
+    fn parse_pipe_operator_queries(&mut self) -> Result<Vec<Query>, 
ParserError> {
+        self.parse_comma_separated(|parser| {
+            parser.expect_token(&Token::LParen)?;
+            let query = parser.parse_query()?;
+            parser.expect_token(&Token::RParen)?;
+            Ok(*query)
+        })
+    }
+
+    /// Parse set quantifier for pipe operators that require DISTINCT. E.g. 
INTERSECT and EXCEPT
+    fn parse_distinct_required_set_quantifier(
+        &mut self,
+        operator_name: &str,
+    ) -> Result<SetQuantifier, ParserError> {
+        if self.parse_keywords(&[Keyword::DISTINCT, Keyword::BY, 
Keyword::NAME]) {
+            Ok(SetQuantifier::DistinctByName)
+        } else if self.parse_keyword(Keyword::DISTINCT) {
+            Ok(SetQuantifier::Distinct)
+        } else {
+            Err(ParserError::ParserError(format!(
+                "{} pipe operator requires DISTINCT modifier",
+                operator_name
+            )))
+        }

Review Comment:
   Thanks 
https://github.com/apache/datafusion-sqlparser-rs/pull/1879/commits/bfbd0086d541ac2d6a7279fd877646ccf071939a



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