[Django] #32906: Explain JSONBAgg benefit

2021-07-06 Thread Django
#32906: Explain JSONBAgg benefit
+
   Reporter:  Claude Paroz  |  Owner:  nobody
   Type:  Cleanup/optimization  | Status:  new
  Component:  Documentation |Version:  dev
   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 |
+
 When reading current Django docs and tests, I can't see how `JSONBAgg` has
 any advantage over `ArrayAgg`. It would be great to add both in docs and
 tests examples showing benefits/differences between  `ArrayAgg` and
 `JSONBAgg`, if any.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.d5a23c0f88152ffa8c944603774fb885%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-07 Thread Django
#32906: Explain JSONBAgg benefit
-+-
 Reporter:  Claude Paroz |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Documentation|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * cc: Mads Jensen (added)


Comment:

 I don't think there is a significant difference between them.
 `ARRAY_AGG()` returns array and `JSONB_AGG()` return JSON array, so when
 you aggregate `JSONField`s with `JSONBAgg()` then you can use key and
 index transforms which don't work with `ArrayAgg()` annotations.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.0616dec6d2480e007c3ad2f9d4e1c0dd%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-08 Thread Django
#32906: Explain JSONBAgg benefit
-+-
 Reporter:  Claude Paroz |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Documentation|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Claude Paroz):

 Then adding tests/docs with calling `JSONBAgg` on a `JSONField` would be
 great.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.5eaa0375f2a85a72d3be039e60ff497f%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-08 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * stage:  Unreviewed => Accepted


Comment:

 Agreed.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.24cfb56cb8e5bca904290bcdd44389f1%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-12 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Abhyudai):

 * owner:  nobody => Abhyudai
 * status:  new => assigned


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.f4a595b690f7aa6eb87b65ae026ac610%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-15 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Abhyudai):

 Replying to [comment:1 Mariusz Felisiak]:
 > I don't think there is a significant difference between them.
 `ARRAY_AGG()` returns array and `JSONB_AGG()` return JSON array, so when
 you aggregate `JSONField`s with `JSONBAgg()` then you can use key and
 index transforms which don't work with `ArrayAgg()` annotations.

 As far I can see, they both are giving the same results.

 {{{#!python
 # model

 class AggregateTestModel(PostgreSQLModel):
 """
 To test postgres-specific general aggregation functions
 """
 json_field = models.JSONField(null=True)

 }}}

 {{{#!sh
 # shell

 >>> AggreTestModel.objects.bulk_create(
  AggregateTestModel(json_field={'lang': 'pl'}),
  AggregateTestModel(json_field={'lang': 'en'}),
  AggregateTestModel(json_field={'breed': 'collie'})
 )

 >>> AggregateTestModel.objects.all().values_list('json_field', flat=True)
 
 >>> AggregateTestModel.objects.aggregate(val=JSONBAgg('json_field'))
 {'val': [None, {'lang': 'pl'}, {'lang': 'en'}, {'breed': 'collie'}]}
 >>> jsonb =
 AggregateTestModel.objects.aggregate(val=JSONBAgg('json_field'))
 >>> jsonb
 {'val': [None, {'lang': 'pl'}, {'lang': 'en'}, {'breed': 'collie'}]}
 >>> arr = AggregateTestModel.objects.aggregate(val=ArrayAgg('json_field'))
 >>> arr
 {'val': [None, {'lang': 'pl'}, {'lang': 'en'}, {'breed': 'collie'}]}
 >>> arr == jsonb
 True
 >>> type(arr)
 
 >>> type(jsonb)
 

 }}}

 Am I missing something here? The above snippet is just an abstracted
 version of the model inside the package `postgres_tests.models`, used for
 tests.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.64f6fb84323ae8c89b592f641cb3f1fe%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-15 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Mariusz Felisiak):

 Replying to [comment:5 Abhyudai]:
 > Am I missing something here? The above snippet is just an abstracted
 version of the model inside the package `postgres_tests.models`, used for
 tests.

 They are not the same on the PostgreSQL-level because `ARRAY_AGG()`
 returns array and `JSONB_AGG()` returns JSON array, see my
 [https://code.djangoproject.com/ticket/32906#comment:1 comment]. For
 example:

 {{{
 >>>
 
AggregateTestModel.objects.annotate(jsonbagg=JSONBAgg('json_field')).filter(jsonbagg__0__lang='en').values('jsonbagg')
 
 >>>
 
AggregateTestModel.objects.annotate(arrayagg=ArrayAgg('json_field')).filter(arrayagg__0__lang='en').values('arrayagg')
   File "/django/django/db/backends/utils.py", line 84, in _execute
 return self.cursor.execute(sql, params)
 psycopg2.errors.SyntaxError: syntax error at or near "["
 LINE 1: ..."postgres_tests_aggregatetestmodel"."json_field" )[1] -> 'la...
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.8666a3227ea9358a86fc62eeacaf0943%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-15 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Description changed by Abhyudai:

Old description:

> When reading current Django docs and tests, I can't see how `JSONBAgg`
> has any advantage over `ArrayAgg`. It would be great to add both in docs
> and tests examples showing benefits/differences between  `ArrayAgg` and
> `JSONBAgg`, if any.

New description:

 Thanks for the explanation, Mariusz.

--

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.6bab06274307aee54fe84e739d2be772%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-15 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Description changed by Abhyudai:

Old description:

> Thanks for the explanation, Mariusz.

New description:

 When reading current Django docs and tests, I can't see how `JSONBAgg` has
 any advantage over `ArrayAgg`. It would be great to add both in docs and
 tests examples showing benefits/differences between  `ArrayAgg` and
 `JSONBAgg`, if any.

--

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.8c9afd0db66ebd42248019a00d5de2a9%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-15 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Abhyudai):

 I had mistakenly put my reply in to modify ticket box. Sorry for the
 noise.

 Thanks, Mariusz, for the explanation.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.7bac0773138689aa048553a56fab1fa7%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-15 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Abhyudai):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/14640 pull-request]

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.1b981df86faf0fe06605e423259b3a7a%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-23 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.7ec2c23972e7b4c6c705b61d52d87fa4%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-23 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Abhyudai):

 * needs_better_patch:  1 => 0


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.be8e487a021380167d65872efd8d21b1%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-25 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.629d488963089d773e18b87593456631%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-26 Thread Django
#32906: Explain JSONBAgg benefit
--+
 Reporter:  Claude Paroz  |Owner:  Abhyudai
 Type:  Cleanup/optimization  |   Status:  assigned
Component:  Documentation |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Abhyudai):

 * needs_better_patch:  1 => 0


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.e903707a0e9f9f5c9a5d1a1cbd1da43a%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-26 Thread Django
#32906: Explain JSONBAgg benefit
-+-
 Reporter:  Claude Paroz |Owner:  Abhyudai
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Documentation|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.3f7df17924b6a6009dd9c0fe7cc5c461%40djangoproject.com.


Re: [Django] #32906: Explain JSONBAgg benefit

2021-07-26 Thread Django
#32906: Explain JSONBAgg benefit
-+-
 Reporter:  Claude Paroz |Owner:  Abhyudai
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Documentation|  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"5a634a7b6f248e5dead65f420ec5d30acd9724bf" 5a634a7b]:
 {{{
 #!CommitTicketReference repository=""
 revision="5a634a7b6f248e5dead65f420ec5d30acd9724bf"
 Fixed #32906 -- Added docs and tests for using key and index lookups on
 JSONBAgg results.

 Co-authored-by: Mariusz Felisiak 
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.4c6696b8f64210151b0a0e6ca428579a%40djangoproject.com.