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

fix: make sure CASE WHEN pick first true branch when WHEN clause is true #8477

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

haohuaijin
Copy link
Contributor

@haohuaijin haohuaijin commented Dec 9, 2023

Which issue does this PR close?

Closes #8475

Rationale for this change

In our current implementation, when WHEN clause is true, we will always pick the last true branch.
Because when WHEN is true(WHEN true or the expression can simplified to WHEN true), we don't set when_value to false (even though it already has the result)in the below code, so we always update the current_value.
https://github.com/apache/arrow-datafusion/blob/2765fee4dd7518a4dc39244d1b495329b9771be1/datafusion/physical-expr/src/expressions/case.rs#L194-L208

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt) labels Dec 9, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks good to me -- thank you @haohuaijin

@alamb
Copy link
Contributor

alamb commented Dec 12, 2023

cc @yjshen in case you have afew moments to review

@alamb alamb merged commit 5a24ec9 into apache:main Dec 15, 2023
22 checks passed
@alamb
Copy link
Contributor

alamb commented Dec 15, 2023

Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CASE WHEN doesn't pick first true branch? Differs from SQLite/Postgres
2 participants