enable supports_filter_during_aggregation for Generic dialect (#1815)

This commit is contained in:
Jax Liu 2025-04-19 19:14:45 +08:00 committed by GitHub
parent 4a487290ce
commit 3ec80e187d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View file

@ -163,4 +163,8 @@ impl Dialect for GenericDialect {
fn supports_comma_separated_set_assignments(&self) -> bool {
true
}
fn supports_filter_during_aggregation(&self) -> bool {
true
}
}

View file

@ -11642,6 +11642,20 @@ fn parse_connect_by() {
#[test]
fn test_selective_aggregation() {
let testing_dialects = all_dialects_where(|d| d.supports_filter_during_aggregation());
let expected_dialects: Vec<Box<dyn Dialect>> = vec![
Box::new(PostgreSqlDialect {}),
Box::new(DatabricksDialect {}),
Box::new(HiveDialect {}),
Box::new(SQLiteDialect {}),
Box::new(DuckDbDialect {}),
Box::new(GenericDialect {}),
];
assert_eq!(testing_dialects.dialects.len(), expected_dialects.len());
expected_dialects
.into_iter()
.for_each(|d| assert!(d.supports_filter_during_aggregation()));
let sql = concat!(
"SELECT ",
"ARRAY_AGG(name) FILTER (WHERE name IS NOT NULL), ",
@ -11649,9 +11663,7 @@ fn test_selective_aggregation() {
"FROM region"
);
assert_eq!(
all_dialects_where(|d| d.supports_filter_during_aggregation())
.verified_only_select(sql)
.projection,
testing_dialects.verified_only_select(sql).projection,
vec![
SelectItem::UnnamedExpr(Expr::Function(Function {
name: ObjectName::from(vec![Ident::new("ARRAY_AGG")]),