You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
order by and < seems different for json value. You can see the warning when use order by
mysql> show warnings;
+---------+------+-------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------+
| Warning | 1235 | This version of MySQL doesn't yet support 'sorting of non-scalar JSON values' |+---------+------+-------------------------------------------------------------------------------+
JSON values are not ordered by their contents, but by their size.
But in MySQL documents:
ORDER BY and GROUP BY for JSON values works according to these principles:
Ordering of scalar JSON values uses the same rules as in the preceding discussion.
For ascending sorts, SQL NULL orders before all JSON values, including the JSON null literal; for descending sorts, SQL NULL orders after all JSON values, including the JSON null literal.
Sort keys for JSON values are bound by the value of the max_sort_length system variable, so keys that differ only after the first max_sort_length bytes compare as equal.
Sorting of nonscalar values is not currently supported and a warning occurs.
Non-scalar values are not supported in MySQL and give a warning. I think we'd better give a warning too 🤔
As suggested by @xiongjiwei, we could regard it as a feature TiDB has implemented, but not implemented by MySQL 🍻, then we can close this issue and the PR (which tried to add warning).
If we'll make a different decision / someone expects a different decision in the future, feel free to reopen the issue and PR 😸
Enhancement
Then consider the following two query:
The first line returns:
It indicates that
[5]
is the smallest one. However, the second one returns:It shows no one is greater than
[5]
. It's not consistent 😢 .For TiDB, it follows the json order, and returns:
For the first selection.
The text was updated successfully, but these errors were encountered: