Opened 7 months ago
Last modified 12 days ago
#35462 assigned New feature
Add support JSONArrayAgg
Reported by: | Robert Silén | Owned by: | Lufafa Joshua |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Normal | Keywords: | aggregation, ArrayAgg |
Cc: | Hisham Mahmood, Sage Abdullah | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I suggest to add ArrayAgg and related (aggregation) functions for MariaDB to Django. It has been noted in MariaDB Foundation ticket: https://jira.mariadb.org/browse/MDBF-690
E.g. ArrayAgg is mentioned on PostgreSQL specific aggregation functions:
https://docs.djangoproject.com/en/dev/ref/contrib/postgres/aggregates/#arrayagg
The equivalent in MariaDB is presumably this:
https://mariadb.com/kb/en/json_arrayagg/
More equivalent MariaDB aggregate functions are listed at the following address.
https://mariadb.com/kb/en/aggregate-functions/
Some have same name 1:1. I'm guessing e.g. StringAgg could be done with GROUP_CONCAT.
Feel free to ask more here, or in the MariaDB Foundation ticket.
Change History (13)
comment:1 by , 7 months ago
Description: | modified (diff) |
---|
comment:2 by , 7 months ago
Description: | modified (diff) |
---|
comment:3 by , 7 months ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Summary: | ArrayAgg and others for MariaDB → Add support JSONArrayAgg |
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 6 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 6 months ago
Cc: | added |
---|
comment:7 by , 5 months ago
Needs documentation: | set |
---|
comment:8 by , 5 months ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
comment:9 by , 3 months ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
comment:10 by , 2 months ago
Patch needs improvement: | set |
---|
comment:11 by , 4 weeks ago
Patch needs improvement: | unset |
---|
comment:12 by , 3 weeks ago
Cc: | added |
---|
comment:13 by , 12 days ago
Patch needs improvement: | set |
---|
The
contrib.postgres.ArrayAgg
expression you pointed at uses Postgres arrays and MariaDB doesn't have native array support so they are not equivalent.JSON_ARRAYAGG
is a standard SQL function implemented on Postgres, SQLite, MySQL, SQLite, Oracle, and MariaDB so if we were to include it in core it should be for all supported backends and not only for MariaDB.It should be trivial to implement by subclassing
Aggregate
in fact I suspect that the following should work on most backends by defaultOr with subtle adjusted as using
json_group_array
on SQLite.As for
StringAgg
with a fallback onGROUP_CONCAT
on MySQL and MariaDB it is already being explored in #35444 which plans to add support for configurable support forORDER BY
in aggregates.