Skip to content

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 Changes to the physical-expr crates 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
@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 Changes to the physical-expr crates 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