Bug #90835 NULL treatment of JSON_ARRAYAGG
| Submitted: | 11 May 2018 12:01 | Modified: | 12 May 2018 16:44 |
|---|---|---|---|
| Reporter: | Markus Winand | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: JSON | Severity: | S3 (Non-critical) |
| Version: | 5.7/8.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[12 May 2018 16:44]
MySQL Verification Team
Thank you for the bug report.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: The JSON_ARRAYAGG function uses a standard SQL name, but doesn't apply the NULL handling as mandated by the standard. Note that this is not about the absence of the <JSON constructor null clause> clause in MySQL, but that MySQL uses "NULL ON NULL" instead of the standard-mandated "ABSENT ON NULL" handing in lack of an explicit <JSON constructor null clause>. Example: SELECT JSON_ARRAYAGG(c) FROM (SELECT 1 c UNION ALL SELECT null c) t +------------------+ | JSON_ARRAYAGG(c) | +------------------+ | [1, null] | +------------------+ As per the standard, the result should be "[1]" because NULL values are removed. Whether or not you want to comply with the SQL standard is really up to you, but IMHO you should not diverge from standard behaviour if you are using standard function names. SQL-2:2016 10.11 SR 5a says for JSON_ARRAYAGG "If <JSON constructor null clause> is not specified, then ABSENT ON NULL is implicit." SQL-2:2016 10.11 GR 5 g ii 2 removes the NULL values from the result if <JSON constructor null clause> is other than NULL ON NULL. How to repeat: Run the above query.