Skip to content
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

executor: check for null values when comparing different groups during streamAgg #15742

Merged
merged 9 commits into from
Mar 27, 2020

Conversation

Reminiscent
Copy link
Contributor

@Reminiscent Reminiscent commented Mar 26, 2020

What problem does this PR solve?

Close #15690
Close #15691
Close #15695
Close #15696
In the master version, we forget to check the null value when we compare the different groups during StreamAgg.

What is changed and how it works?

Add checks for null values when comparing different groups during StreamAgg.

Check List

Tests

  • Unit test
  • Integration test

@Reminiscent Reminiscent added type/bugfix This PR fixes a bug. sig/execution SIG execution labels Mar 26, 2020
@Reminiscent Reminiscent requested a review from a team as a code owner March 26, 2020 12:38
@ghost ghost removed their request for review March 26, 2020 12:39
@Reminiscent Reminiscent added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label Mar 26, 2020
@XuHuaiyu XuHuaiyu requested a review from qw4990 March 26, 2020 12:45
@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #15742 into master will decrease coverage by 0.0521%.
The diff coverage is 76.5957%.

@@               Coverage Diff                @@
##             master     #15742        +/-   ##
================================================
- Coverage   80.4669%   80.4148%   -0.0522%     
================================================
  Files           504        504                
  Lines        134649     134617        -32     
================================================
- Hits         108348     108252        -96     
- Misses        17831      17883        +52     
- Partials       8470       8482        +12

@qw4990
Copy link
Contributor

qw4990 commented Mar 26, 2020

Do we need to cherry-pick this PR to release-4.0?

Comment on lines 849 to 855
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec(`drop table if exists t;`)
tk.MustExec(`create table t(a int);`)
tk.MustExec(`insert into t values(null),(null);`)
tk.MustExec(`insert into t values(0),(2),(2),(4),(8);`)
tk.Se.GetSessionVars().MaxChunkSize = 2
tk.MustQuery(`select /*+ stream_agg() */ distinct * from t;`).Check(testkit.Rows("<nil>", "0", "2", "4", "8"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost LGTM, but please add more tests to cover more types for safety.

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing the comment makes LGTM

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reminiscent
Copy link
Contributor Author

/run-all-tests

@Reminiscent
Copy link
Contributor Author

Reminiscent commented Mar 27, 2020

/run-unit-test

@Reminiscent
Copy link
Contributor Author

@SunRunAway @qw4990 @XuHuaiyu Update. PTAL

@Reminiscent
Copy link
Contributor Author

Could you add some test cases for splitIntoGroups like others https://github.com/search?q=splitIntoGroups+repo%3Apingcap%2Ftidb+filename%3A_test.go&type=Code&ref=advsearch&l=&l=?

flag, err := groupChecker.splitIntoGroups(inputChk)
c.Assert(err, IsNil)
c.Assert(flag, Equals, testCase.expectedFlag[i])
Here can check the result of splitIntoGroups .

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

executor/aggregate_test.go Show resolved Hide resolved
Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SunRunAway SunRunAway added the status/can-merge Indicates a PR has been approved by a committer. label Mar 27, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Mar 27, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Mar 27, 2020

cherry pick to release-4.0 in PR #15777

ngaut pushed a commit that referenced this pull request Mar 28, 2020
Comment on lines +1116 to +1121
if firstRowIsNull {
firstRowDatum.SetNull()
}
if lastRowIsNull {
lastRowDatum.SetNull()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this behand switch eType, and reduce the if to check null in the switch.

@Reminiscent Reminiscent deleted the issue-15696 branch August 5, 2021 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug.
Projects
None yet
6 participants