1.v7.5.0尝试验证,语法尚未兼容,会报错。
mysql> select version();
+--------------------+
| version() |
+--------------------+
| 8.0.11-TiDB-v7.5.0 |
+--------------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM JSON_TABLE ('[ {"c1": 1} ]', '$[*]' COLUMNS( c1 INT PATH '$.c1' ERROR ON ERROR )) as jt;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 27 near "('[ {"c1": 1} ]', '$[*]' COLUMNS( c1 INT PATH '$.c1' ERROR ON ERROR )) as jt"
2.MySQL官方文档
https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html
Extracts data from a JSON document and returns it as a relational table having the specified columns.
One of the new JSON functions in MySQL 8.0 is JSON_TABLE.
It is also MySQL’s first table function.
That is, the return value is not a scalar value, but a result set.
JSON_TABLE will convert (part of) a JSON document into a relational table.
3.结论:
JSON_TABLE 是MySQL 8.0 的函数,TiDB v6.5 应该是还没有兼容支持,应该在后续新版本里应该会兼容。
楼主你可以在你的版本里验证,也是会有类似的结论。
如果业务有强依赖,就先通过其他的方式绕过JSON_TABLE 函数吧。