Aggregation Final Report

3 views
Skip to first unread message

Nicolas Lara

unread,
Aug 21, 2008, 4:12:35 PM8/21/08
to django-d...@googlegroups.com
Hello,

I am writing to let you know that I have posted the latest patches on
aggregation support. All the planned features are implemented in the
patch for #3566.
For those not keping trac these are:

* Two queryset modifiers for doing aggregation: aggregate() and annotate().
* aggregate() is a terminal clause and returns a dictionary.
* annotate() returns a queryset and each object is extended with
the aggregation information. By default objects are grouped by all the
fields in the model.
* There are aggregate objects for representing the aggregation
functions to be used. Aggregate objects for the main SQL aggregation
functions are available.
* Count aggregate object takes an extra parameter 'distinct' that
translates into the sql: COUNT(DISTINCT field)
* It is possible to define custom grouping by calling
values('fields', 'to', 'group', 'by') before doing an annotate() call.
This will result in a group by call at the backend level.
* Aliases for the aggregations are generated automatically when
not explicitly provided.
* Filtering on aggregated values is possible. It results in a
HAVING sql clause. There are some interesting cases of filtering that
can be found in the documentation and tests.
* Ordering on aggregates is allowed.
* In MySQL: When not specifying grouping explicitly on annotate
the grouping is made only by the pk and not all the fields.
* Doing annotate().aggregate() does aggregation on the previous query.
* When grouping an extra parameter is available to get the result
along with a queryset to retrieve the objects that were grouped.

There is also a patch posing a re-write of #7210 to remove the
dependency on the model so it would be easy to have aggregates (and
columns selected via extra() ) working with F objects.

All that's left now is a bit of community testing. I'll keep the
patches updated and be aware of any bug that might arise to try and
fix it as soon as possible.


Best Regards =),

--
Nicolas Lara

flo...@gmail.com

unread,
Aug 22, 2008, 4:26:25 AM8/22/08
to Django developers
Awesome! Simply, awesome! Thanks for all your hard work. I can't
wait to see this in trunk!

-Eric Florenzano

Russell Keith-Magee

unread,
Aug 22, 2008, 7:03:48 AM8/22/08
to django-d...@googlegroups.com
On Fri, Aug 22, 2008 at 4:12 AM, Nicolas Lara <nicol...@gmail.com> wrote:
>
> Hello,
>
> I am writing to let you know that I have posted the latest patches on
> aggregation support. All the planned features are implemented in the
> patch for #3566.

I would just like to take this opportunity to thank Nicolas for his
hard work. Aggregates have been a long standing feature request for
Django, so it's great to be able to finally be in a position to be
able to close the ticket.

For those looking out for aggregates in trunk - my goal is to start
integrating this once the dust has settled (and the hangovers have
subsided) on v1.0.

Again, great work Nicolas. I hope you hang around the Django community
and contribute more great work like this.

Russ Magee %-)

alex....@gmail.com

unread,
Aug 22, 2008, 10:55:00 AM8/22/08
to Django developers
I'd also just like to say thanks, it looks like a tremendous amount of
work, and a big gain for the entire django community!

On Aug 22, 7:03 am, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages