-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect GROUP BY for JSON values #10467
Comments
Confirming this issue still exists in master: drop table if exists tx2;
create table tx2 (col json);
insert into tx2 values (json_array(3.0));
insert into tx2 values (json_array(3));
select col, count(1) from tx2 group by col;
..
mysql> select col, count(1) from tx2 group by col;
+-----+----------+
| col | count(1) |
+-----+----------+
| [3] | 1 |
| [3] | 1 |
+-----+----------+
2 rows in set (0.00 sec)
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-750-g8a661044c
Edition: Community
Git Commit Hash: 8a661044cedf8daad1de4fbf79a390962b6f6c3b
Git Branch: master
UTC Build Time: 2020-07-10 10:52:37
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec) |
I think the best way to fix this is to add the JSON type of decimal (see: #9988 ). There was a proposed PR for this which used float64 to compare, but that produces inaccurate results for some cases. If when grouping JSON values decimal is used, it should be safe for all cases. |
Please edit this comment or add a new comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA) (optional)2. Symptom (optional)3. All Trigger Conditions (optional)4. Workaround (optional)5. Affected versions6. Fixed versions |
Re-opening for TiKV investigation. |
What does |
If there is any development task that needs to be done, |
Sounds good to me. I will reclose. |
I think while this PR is closing a bug, it opens another one, due to not identical implementations between TiDB and TiKV. The fail case could be constructed. This might not be considered as a complete fix. |
Description
Bug Report
MySQL:
TiDB:
This simply indicates that generating the group key by using serialized value is incorrect. For JSON values, it is very clear that different memory / serialized values are treated as the same group.
SIG slack channel
#sig-exec
Score
Mentor
The text was updated successfully, but these errors were encountered: