Skip to content

Support standard syntax for filtered aggregations #16516

@findepi

Description

@findepi

Is your feature request related to a problem or challenge?

$ cargo run --bin datafusion-cli
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.18s
     Running `target/debug/datafusion-cli`
DataFusion CLI v48.0.0

> SELECT array_agg(a_varchar) filter (where a_varchar is not null)
FROM (VALUES ('a'), ('d'), ('c'), ('a')) t(a_varchar);  🤔 Invalid statement: SQL error: ParserError("Expected: end of statement, found: ( at Line: 1, Column: 36")

Describe the solution you'd like

This is standard syntax and supported under PostgreSQL dialect set datafusion.sql_parser.dialect = 'Postgres'; is enabled.
Add support for filtered aggregations in the default dialect (Generic) as well.

Describe alternatives you've considered

Using Postgres dialect.
I should not be forced out of my preferred dialect to access an existing feature, unless that feature is truly dialect-specific.
Moreover, switching to PostgreSQL dialect has its own issues: #16515

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions