Finally I decided to give it a try to this powerful JSON_TABLE function I keep seeing everywhere, and I am having an issue.
The minimum query I found to replicate it is:
SELECT * FROM JSON_TABLE('[{"foo":"bar","bar":5}]','$[*]' columns ( foo text path '$.foo' , bar int path '$.bar' , whole_row_json longtext path '$' )) AS x
Or even wrapped like
SELECT * FROM JSON_TABLE('{"data":[{"foo":"bar","bar":5}]}','$.data[*]' columns ( foo text path '$.foo' , bar int path '$.bar' , whole_row_json longtext path '$' )) AS x;
But for a complex requirement (and debugging purposes) I need the whole json document in a column, but I keep receiving null instead
| foo | bar | whole_row_json |
|---|---|---|
| bar | 5 | null |
I read the docs and even this notation is used on another answers here on SO, I have tried another weird notations (like '$.', '$', '$.'), but nothing seems to work.
What am I missing?
MariaDB Version: 10.7.4
Edits: What I need is the the json document that generated each row, not the literal whole json input
This issue seems to be reported on https://jira.mariadb.org/browse/MDEV-25875
and according to my findings, this doesn't work either on bare metal mariadb 10.7.4 nor docker mariadb:10.6.8-focal, mariadb:10.8, mariadb:10.9-rc