BenSatori commented on code in PR #2521:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2521#discussion_r4766238207
##########
src/parser/mod.rs:
##########
@@ -13546,9 +13559,18 @@ impl<'a> Parser<'a> {
result,
)));
};
- let group_by = match expressions {
- None => GroupByExpr::All(modifiers),
- Some(exprs) => GroupByExpr::Expressions(exprs, modifiers),
+ let group_by = match (modifier, expressions) {
+ (None, None) => GroupByExpr::All(modifiers),
+ (Some(modifier), Some(exprs)) => {
+ GroupByExpr::ExpressionsWithModifier(modifier, exprs,
modifiers)
+ }
+ (None, Some(exprs)) => GroupByExpr::Expressions(exprs,
modifiers),
+ (Some(_), None) => {
+ return parser_err!(
+ "BUG: GROUP BY modifier requires expressions",
+ self.peek_token_ref().span.start
+ )
+ }
};
Review Comment:
Done in a0c3f363: matching on `(expressions, modifier)` now, and the
unreachable `(Some(_), None)` arm is gone.
##########
src/ast/query.rs:
##########
@@ -3819,6 +3840,10 @@ pub enum GroupByExpr {
All(Vec<GroupByWithModifier>),
/// `GROUP BY <expressions>` with optional modifiers.
Expressions(Vec<Expr>, Vec<GroupByWithModifier>),
+ /// `GROUP BY ALL | DISTINCT <expressions>` with optional modifiers.
Review Comment:
Done in a0c3f363, `[PostgreSQL]` is now referenced in the variant doc text,
and `RUSTDOCFLAGS=-Dwarnings cargo doc` passes.
##########
src/ast/query.rs:
##########
Review Comment:
Done in a0c3f363, the enum doc now lists all three forms. While here I also
switched `parse_group_by_modifier`'s negative case from `is_err()` to a typed
`ParserError` assertion. Also merged current main (resolved two add/add
conflicts in `postgresql.rs` and `sqlparser_postgres.rs`).
--
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]