Bug #79010 JSON support should include aggregate functions
Submitted: 28 Oct 2015 21:45 Modified: 10 Oct 2016 10:33
Reporter: Roland Bouman Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: JSON Severity:S4 (Feature request)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[28 Oct 2015 21:45] Roland Bouman
Description:
The current JSON function list (https://dev.mysql.com/doc/refman/5.7/en/json-function-reference.html) does not include any functions that allow documents to be created by aggregating a resultset. 

These would be very convenient additions to complement the current JSON feature set.

Proposal1: JSON_AGG_ARRAY(expression)
Returns a JSON array having the expression as its elements

example: SELECT JSON_AGG_ARRAY(film_id) FROM sakila.film
result: [1,2,3...]

JSON_AGG_ARRAY should allow the DISTINCT keyword to collect only distinct values into the array:

exmple: SELECT JSON_AGG_ARRAY(DISTINCT rating) FROM sakila.film
result: ["PG", "G", "NC-17", "PG-13", "R"]

Proposal2: JSON_AGG_DOCUMENTS(expression, [expression[, expression ...etc]])

example: SELECT JSON_AGG_DOCUMENTS(film_id, title AS name) FROM sakila.film
result: [
  {"film_id": 1, "name": "ACADEMY DINOSAUR"}, 
  {"film_id": 2, ....}, 
  ...
]

How to repeat:
n/a

Suggested fix:
please implement json aggregation functions
[28 Oct 2015 22:04] Roland Bouman
category JSON
[30 Oct 2015 6:05] MySQL Verification Team
Hello Roland,

Thank you for the feature request.

Thanks,
Umesh
[10 Oct 2016 10:33] Jon Stephens
Duplicate of BUG#78117 (which was fixed in MySQL 8.0.1).