mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
enable supports_filter_during_aggregation
for Generic dialect (#1815)
This commit is contained in:
parent
4a487290ce
commit
3ec80e187d
2 changed files with 19 additions and 3 deletions
|
@ -163,4 +163,8 @@ impl Dialect for GenericDialect {
|
||||||
fn supports_comma_separated_set_assignments(&self) -> bool {
|
fn supports_comma_separated_set_assignments(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn supports_filter_during_aggregation(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11642,6 +11642,20 @@ fn parse_connect_by() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_selective_aggregation() {
|
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!(
|
let sql = concat!(
|
||||||
"SELECT ",
|
"SELECT ",
|
||||||
"ARRAY_AGG(name) FILTER (WHERE name IS NOT NULL), ",
|
"ARRAY_AGG(name) FILTER (WHERE name IS NOT NULL), ",
|
||||||
|
@ -11649,9 +11663,7 @@ fn test_selective_aggregation() {
|
||||||
"FROM region"
|
"FROM region"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
all_dialects_where(|d| d.supports_filter_during_aggregation())
|
testing_dialects.verified_only_select(sql).projection,
|
||||||
.verified_only_select(sql)
|
|
||||||
.projection,
|
|
||||||
vec![
|
vec![
|
||||||
SelectItem::UnnamedExpr(Expr::Function(Function {
|
SelectItem::UnnamedExpr(Expr::Function(Function {
|
||||||
name: ObjectName::from(vec![Ident::new("ARRAY_AGG")]),
|
name: ObjectName::from(vec![Ident::new("ARRAY_AGG")]),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue