-
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
expression, session: handle CASE WHEN
specially when folding constant during outerJoin Simplification
#11105
Conversation
Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
Codecov Report
@@ Coverage Diff @@
## master #11105 +/- ##
===========================================
Coverage 81.4185% 81.4185%
===========================================
Files 424 424
Lines 90795 90795
===========================================
Hits 73924 73924
Misses 11571 11571
Partials 5300 5300 |
SELECT ... CASE WHEN ... ELSE NULL...
SELECT ... CASE WHEN ... ELSE NULL...
/run-all-tests |
1 similar comment
/run-all-tests |
/run-integration-common-test |
/run-all-tests |
/rebuild |
/run-all-tests |
A simpler sql to re-produce this issue: tidb> select t1.id from kankan1 t1 left join kankan2 t2 on t1.id = t2.id where (case when t1.name='b' then 'case2' when t1.name='a' then 'case1' else NULL end) = 'case1';
+------+
| id |
+------+
| 2 |
+------+ The root cause for this bug is that: |
I wonder that can we put case-when in |
Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
@XuHuaiyu Good advice, I have modified it. |
/rebuild |
1 similar comment
/rebuild |
expression/constant_fold.go
Outdated
isDeferredConst = isDeferredConst || isDeferred1 | ||
} | ||
|
||
if l%2 == 1 && isFirstCondition { |
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.
Does this mean the else
expr? Please add some comments.
Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...`
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 |
/run-all-tests |
/run-sqllogic-test-1 |
/run-sqllogic-test-1 |
/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
/run-all-tests |
success |
cherry pick to release-2.1 failed |
cherry pick to release-3.0 failed |
…nt during outerJoin Simplification (pingcap#11105) Test pass, auto merge by Bot
…nt during outerJoin Simplification (pingcap#11105) Test pass, auto merge by Bot
What problem does this PR solve?
fix issue:#11102 Unexcepted result in
SELECT ... CASE WHEN ... ELSE NULL...
What is changed and how it works?
Check List
Tests