-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
statistics: fix get wrong topn with data -0 and 0 #57464
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #57464 +/- ##
================================================
+ Coverage 72.8394% 73.6385% +0.7991%
================================================
Files 1672 1702 +30
Lines 462873 470888 +8015
================================================
+ Hits 337154 346755 +9601
+ Misses 104938 102721 -2217
- Partials 20781 21412 +631
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/retest |
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
/retest |
1 similar comment
/retest |
@hawkingrei: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest lgtm
@@ -61,15 +62,36 @@ func CopySampleItems(items []*SampleItem) []*SampleItem { | |||
return n | |||
} | |||
|
|||
func sortSampleItems(sc *stmtctx.StatementContext, items []*SampleItem) error { | |||
func sortDatumByBinary(items []types.Datum, getComparedBytes func(datum types.Datum) ([]byte, error)) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you comment on why binary format matters rather than simple item value comparison? for later reviewer's quick grabbing
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: winoros The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: close #57448
Problem Summary:
What changed and how does it work?
first, you can add the following code to debug this code, then create the table and insert the data as describe by the issue.
so you will get the print log as following.
From the logs below, it can be observed that the final topn contains multiple identical values. Additionally, the inserted data also has duplicates. Finally, in the sorted results, we found that the order of 0 and -0 is incorrect.
the root cause is that
sortSampleItems
is sorted by the semantics, but getComparedBytes is compared by the binary order.The two semantics are different, which led to the final issue.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.