#34717: Cannot use aggregate over window functions since 4.2
-----------------------------------------+------------------------
Reporter: younes-chaoui | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
After upgrading to Django 4.2, I encountered an exception when executing
ORM queries that involve aggregates over Window functions. The specific
error was `psycopg2.errors.GroupingError: aggregate function calls cannot
contain window function calls`
Dependencies :
psycopg2 version: 2.9.3
django version: 4.1.9
PostgreSQL version: 13.4
Example Code:
{{{
queryset = queryset.annotate(
cumul_DJR=Coalesce(Window(Sum("DJR"), order_by=F("date").asc()), 0.0)
)
aggregate = queryset.aggregate(
DJR_total=Sum("DJR"),
cumul_DJR_total=Sum("cumul_DJR")
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34717>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018963dd2bf0-a2dd3c6e-d071-45b4-8881-f08a689fea5f-000000%40eu-central-1.amazonses.com.