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

JSON_TABLE FUNCTION always returning first element in the array.

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11.13
    • None
    • JSON
    • None

    Description

      Hi team,
      Good day,

      I was trying to extract elements from the JSON_TABLE Function and it is always returning first element of the array.

      Steps to reproduce:

       
      MariaDB [(none)]> SELECT VALUE FROM JSON_TABLE( '[50,48,49]', '$[1]' COLUMNS( VALUE INT PATH '$' ) ) AS JT;
      +-------+
      | VALUE |
      +-------+
      |    50 |
      +-------+
      1 row in set (0.000 sec)
      MariaDB [(none)]> SELECT * FROM JSON_TABLE(   '{"employees":[{"id":1,"info":{"name":"Alice"}},{"id":2,"info":{"name":"Bob"}}]}',   '$.employees[1]'   COLUMNS (     id INT PATH '$.id',     name VARCHAR(100) PATH '$.info.name'   ) ) AS jt;
      +------+-------+
      | id   | name  |
      +------+-------+
      |    1 | Alice |
      +------+-------+
      1 row in set (0.000 sec)
      

      In the above two examples.
      I was expecting the second element in the array but it was always returning the first element.

      This is not happening in 10.6.22.
      Logs:

      MariaDB [(none)]> SELECT VALUE FROM JSON_TABLE( '[50,48,49]', '$[2]' COLUMNS( VALUE INT PATH '$' ) ) AS JT
          -> ;
      +-------+
      | VALUE |
      +-------+
      |    49 |
      +-------+
      1 row in set (0.001 sec)
      

      Can you please confirm if this is expected behaviour after 10.6?

      Thanks,
      Akilan RM.

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              Akilan Rajmahendran Akilan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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