sqlalchemy / sqlalchemy/sqlalchemy
Support for postgresql aggregate options
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 12.2k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the use case
Postgresql supports many options for aggregate functions, like distinct, filter, etc. Documentation at https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-AGGREGATES
There is currently support for
- distinct using distinct
- order_by using aggregate_order_by.
A possible api may be to replace aggregate_order_by with an aggregate_options that accepts also other functionality.
Databases / Backends / Drivers targeted
postgresql
Example Use
select array_agg(distinct v order by v desc) FILTER (WHERE v < 3)
from (
select v
from generate_series(1, 3) v
union all
select v
from generate_series(2, 5) v
) as v
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading SQLAlchemy's existing distinct support and PostgreSQL aggregate_order_by API, then compare them with PostgreSQL's aggregate-expression documentation. Use the provided array_agg example as the target behavior and verify that the proposed API can represent its FILTER and ordering options in generated SQL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100