Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
None
-
None
Description
If json_arrayagg result is used in a having clause, it is surrounded by extra brackets in the resultset.
How to reproduce:
CREATE TABLE tst (a INTEGER, b VARCHAR(255)); |
INSERT INTO tst VALUES (1, 'test string'); |
SELECT a, JSON_ARRAYAGG(b) AS js FROM tst GROUP BY 1; |
/* Correct:
|
+------+-----------------+
|
| a | js |
|
+------+-----------------+
|
| 1 | ["test string"] |
|
+------+-----------------+
|
*/
|
SELECT a, JSON_ARRAYAGG(b) AS js FROM tst GROUP BY 1 HAVING a=1; |
/* Correct:
|
+------+-----------------+
|
| a | js |
|
+------+-----------------+
|
| 1 | ["test string"] |
|
+------+-----------------+
|
*/
|
SELECT a, JSON_ARRAYAGG(b) AS js FROM tst GROUP BY 1 HAVING js<>''; |
/* Extra brackets:
|
+------+-------------------+
|
| a | js |
|
+------+-------------------+
|
| 1 | [["test string"]] |
|
+------+-------------------+
|
*/
|
-- but at the same time it has correct value within HAVING conditions:
|
SELECT a, JSON_ARRAYAGG(b) AS js FROM tst GROUP BY 1 HAVING js='["test string"]'; |
/*
|
+------+-------------------+
|
| a | js |
|
+------+-------------------+
|
| 1 | [["test string"]] |
|
+------+-------------------+
|
*/
|
SELECT a, JSON_ARRAYAGG(b) AS js FROM tst GROUP BY 1 HAVING js='["test string"]'; |
/*
|
Empty set (0,002 sec)
|
*/ |
Attachments
Issue Links
- duplicates
-
MDEV-23069 Duplicate square brackets in JSON_ARRAYAGG upon query with HAVING
-
- Confirmed
-