-
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
planner: fix compatibility bug for window function #11488
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11488 +/- ##
===============================================
- Coverage 81.8068% 81.3418% -0.465%
===============================================
Files 424 424
Lines 92738 90920 -1818
===============================================
- Hits 75866 73956 -1910
- Misses 11538 11639 +101
+ Partials 5334 5325 -9 |
Codecov Report
@@ Coverage Diff @@
## master #11488 +/- ##
===========================================
Coverage 81.3703% 81.3703%
===========================================
Files 425 425
Lines 91526 91526
===========================================
Hits 74475 74475
Misses 11717 11717
Partials 5334 5334 |
I think the codes are not special for |
@winoros Yes. It is better to change the description. |
DENSE_RANK
window functionThere 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.
lgtm
planner/core/logical_plan_builder.go
Outdated
if end.Type == ast.Following && !end.UnBounded { | ||
return spec, false, ErrWindowRangeFrameOrderType.GenWithStackByArgs(getWindowName(spec.Name.O)) | ||
} | ||
} |
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.
Your code is for frame validation, is that suitable to be put in handleDefaultFrame
?
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.
Besides, the ErrWindowRangeFrameOrderType error is needFrame
irrelevant, considering this case
SELECT FIRST_VALUE(fieldA) OVER w1 AS 'dense_rank', fieldA, fieldB FROM ( SELECT `col_time` AS fieldA, `col_time` AS fieldB FROM `table20_int_autoinc` ) as t WINDOW w1 AS ( PARTITION BY fieldB ORDER BY fieldB DESC, fieldA DESC RANGE BETWEEN CURRENT ROW AND 1 FOLLOWING);
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.
Actually, the handleDefaultFrame
is a function to remove the invalidated frames. So it's reasonable to put it 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.
And there are much more frame validations in buildWindowFunctionFrame
.
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.
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.
Now, the frame validations are after groupWindowFuncs
. We have to handleDefaultFrame
in groupWindowFuncs
. It hard to move this validation to buildWindowFunctionFrame
...
/rebuild |
/run-all-tests |
/run-all-tests |
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.
LGTM
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.
LGTM
/run-all-tests |
@lzmhhh123 merge failed. |
/run-all-tests |
/run-common-test tidb-test=pr/869 |
1 similar comment
/run-common-test tidb-test=pr/869 |
/run-common-test tidb-test=pr/869 |
1 similar comment
/run-common-test tidb-test=pr/869 |
/run-all-tests |
1 similar comment
/run-all-tests |
cherry pick to release-3.0 failed |
What problem does this PR solve?
Fix #11010, #11001, #11002, #11011.
What is changed and how it works?
The error judging should not be involved in the build function. It caused the wrong frame like the default frame to check. That's a fault.
Check List
Tests
Code changes
Related changes