[Django] #19313: Count Aggregation documentation

31 views
Skip to first unread message

Django

unread,
Nov 17, 2012, 3:11:34 PM11/17/12
to django-...@googlegroups.com
#19313: Count Aggregation documentation
-------------------------------+-------------------------
Reporter: ebertti@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Keywords: aggregation
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------
add something in the documentation talking about the possibility of using
distinct aggregation done by count.

like:

Number of authors by category:
{{{
#!python
Author.objects.values('post__category__name').aggregate(qtd=Count('id',
distinct=True))
}}}

There is nothing on the internet or in the documentation and talking
something about it. I find that looking at the code.

--
Ticket URL: <https://code.djangoproject.com/ticket/19313>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 17, 2012, 5:38:33 PM11/17/12
to django-...@googlegroups.com
#19313: Count Aggregation documentation
-------------------------------+--------------------------------------

Reporter: ebertti@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Resolution:

Keywords: aggregation | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by aaugustin):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Internal APIs aren't documented because they're subject to change without
warning.

Could you check if the following query — which only uses documented APIs —
achieves the same result?

{{{
Author.objects.values('post__category__name').distinct('id').aggregate(qtd=Count('id'))
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:1>

Django

unread,
Nov 17, 2012, 5:41:59 PM11/17/12
to django-...@googlegroups.com
#19313: Count Aggregation documentation
-------------------------------+--------------------------------------
Reporter: ebertti@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Resolution:

Keywords: aggregation | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by anonymous):

Hi!

distinct by column name isn't suported by mysql backend.

--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:2>

Django

unread,
Nov 22, 2012, 5:30:22 AM11/22/12
to django-...@googlegroups.com
#19313: Count Aggregation documentation
-------------------------------+------------------------------------

Reporter: ebertti@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Resolution:
Keywords: aggregation | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by russellm):

* stage: Unreviewed => Accepted


Comment:

I'm comfortable calling this an oversight on my part. SELECT
COUNT(DISTINCT foo) FROM table is different to SELECT DISTINCT COUNT(foo)
FROM table, and support for distinct counts was a deliberate decision.

Although it's a feature that may not be universally available on all
databases, it is useful on those databases that support it.

--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:3>

Django

unread,
Jun 12, 2014, 5:05:21 PM6/12/14
to django-...@googlegroups.com
#19313: Count Aggregation documentation
-------------------------------+------------------------------------
Reporter: ebertti@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Resolution:
Keywords: aggregation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by jorgecarleitao):

This can be documented when ticket #14030 is addressed.

--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:4>

Django

unread,
Jun 16, 2014, 2:30:21 PM6/16/14
to django-...@googlegroups.com
#19313: Count Aggregation documentation
-------------------------------+------------------------------------
Reporter: ebertti@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.4
Severity: Normal | Resolution:
Keywords: aggregation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by jorgecarleitao):

Forget previous comment.

Isn't this documented in Count,
https://docs.djangoproject.com/en/1.6/ref/models/querysets/#django.db.models.Count.distinct,
which is different from distinct,
https://docs.djangoproject.com/en/1.6/ref/models/querysets/#distinct ?

--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:5>

Django

unread,
Jun 16, 2014, 2:40:05 PM6/16/14
to django-...@googlegroups.com
#19313: Count Aggregation documentation
-------------------------------+--------------------------------------
Reporter: ebertti@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.4
Severity: Normal | Resolution: worksforme

Keywords: aggregation | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => worksforme


Comment:

Yep, that looks like it.

--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:6>

Reply all
Reply to author
Forward
0 new messages