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

JSON_OBJECTAGG returns NULL when used together with GROUP BY

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.5.4
    • 10.5.5
    • JSON
    • 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

            varun Varun Gupta (Inactive)
            Markus Winand Markus Winand
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.