mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-28 18:04:05 +00:00
Add fn support_group_by_expr to Dialect trait (#896)
This commit is contained in:
parent
2b37e4ae6e
commit
2296de2bc4
5 changed files with 17 additions and 1 deletions
|
@ -28,4 +28,8 @@ impl Dialect for DuckDbDialect {
|
|||
fn supports_filter_during_aggregation(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn supports_group_by_expr(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,8 @@ impl Dialect for GenericDialect {
|
|||
|| ch == '#'
|
||||
|| ch == '_'
|
||||
}
|
||||
|
||||
fn supports_group_by_expr(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,10 @@ pub trait Dialect: Debug + Any {
|
|||
fn supports_within_after_array_aggregation(&self) -> bool {
|
||||
false
|
||||
}
|
||||
/// Returns true if the dialects supports `group sets, roll up, or cube` expressions.
|
||||
fn supports_group_by_expr(&self) -> bool {
|
||||
false
|
||||
}
|
||||
/// Dialect-specific prefix parser override
|
||||
fn parse_prefix(&self, _parser: &mut Parser) -> Option<Result<Expr, ParserError>> {
|
||||
// return None to fall back to the default behavior
|
||||
|
|
|
@ -42,6 +42,10 @@ impl Dialect for PostgreSqlDialect {
|
|||
fn supports_filter_during_aggregation(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn supports_group_by_expr(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_comment(parser: &mut Parser) -> Result<Statement, ParserError> {
|
||||
|
|
|
@ -975,7 +975,7 @@ impl<'a> Parser<'a> {
|
|||
/// parse a group by expr. a group by expr can be one of group sets, roll up, cube, or simple
|
||||
/// expr.
|
||||
fn parse_group_by_expr(&mut self) -> Result<Expr, ParserError> {
|
||||
if dialect_of!(self is PostgreSqlDialect | DuckDbDialect | GenericDialect) {
|
||||
if self.dialect.supports_group_by_expr() {
|
||||
if self.parse_keywords(&[Keyword::GROUPING, Keyword::SETS]) {
|
||||
self.expect_token(&Token::LParen)?;
|
||||
let result = self.parse_comma_separated(|p| p.parse_tuple(false, true))?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue