[MDEV-26257] JSON_TABLE() does not return ER_JSON_TABLE_MULTIPLE_MATCHES when column path has multiple matches Created: 2021-07-27  Updated: 2022-06-01

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.6.3
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-17399 Add support for JSON_TABLE Closed

 Description   

Since ERROR ON ERROR is set in the following query, I would expect it to fail with the error code ER_JSON_TABLE_MULTIPLE_MATCHES. However, the query succeeds, and JSON_TABLE() returns the first match:

SELECT * 
FROM JSON_TABLE(
   '[
        {"first_name": "John", "first_name": "Jonathan", "last_name": "Smith", "email": "john.smith@example.com"},
        {"first_name": "Jon", "last_name": "Smith", "email": "jon.smith@example.com"},
        {"first_name": "Johnny", "last_name": "Smith", "email": "john.smith@example.com"}
    ]', 
'$[*]'
COLUMNS(
   rowid FOR ORDINALITY,
   first_name VARCHAR(10) PATH '$.first_name' ERROR ON ERROR,
   last_name  VARCHAR(10) PATH '$.last_name' ERROR ON ERROR,
   email VARCHAR(50) PATH '$.email' ERROR ON ERROR
)
) AS people;

See here:

+-------+------------+-----------+------------------------+
| rowid | first_name | last_name | email                  |
+-------+------------+-----------+------------------------+
|     1 | John       | Smith     | john.smith@example.com |
|     2 | Jon        | Smith     | jon.smith@example.com  |
|     3 | Johnny     | Smith     | john.smith@example.com |
+-------+------------+-----------+------------------------+


Generated at Thu Feb 08 09:43:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.