Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23029

JSON_OBJECTAGG returns NULL when used together with GROUP BY

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.5.4
    • Fix Version/s: 10.5.5
    • Component/s: JSON
    • Labels:
    • Environment:
      Built from source.

      Description

      I might be missing somthing totally trivial, but the following example doesn't look correct to me:

      (psergey: fixed formatting)

      CREATE TABLE t (
          e INTEGER,
          a VARCHAR(255),
          v VARCHAR(255)
      );
       
      INSERT INTO t VALUES (0, 'a1', '1')
                         , (0, 'a2', '2')
                         , (1, 'b1', '3');
       
      SELECT e, JSON_OBJECTAGG(a, v)
        FROM t
       GROUP BY e;
      

      This is what I get:

      MariaDB 5.5.5-10.5.4-MariaDB> SELECT e, JSON_OBJECTAGG(a, v)
          ->   FROM t
          ->  GROUP BY e;
      +------+----------------------+
      | e    | JSON_OBJECTAGG(a, v) |
      +------+----------------------+
      |    0 | NULL                 |
      |    1 | NULL                 |
      +------+----------------------+
      2 rows in set (0.00 sec)
      

      The second column is NULL, although it should contain the actual data (like MySQL does).

      Removing the GROUP BY yields a correct result.

        Attachments

          Activity

            People

            Assignee:
            varun Varun Gupta
            Reporter:
            Markus Winand Markus Winand
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: