Use logical null count in case_when_with_expr#18872
Merged
comphead merged 1 commit intoapache:mainfrom Nov 21, 2025
Merged
Conversation
e37d026 to
5e41c7f
Compare
Contributor
Author
No, that's expected. The code was computing the correct result in spite of this. What was happens on With this change the null handling code path is taken and the null values get filtered out before reaching the when branch handling. |
logan-keede
pushed a commit
to logan-keede/datafusion
that referenced
this pull request
Nov 23, 2025
## Which issue does this PR close? - None, followup to apache#18152 ## Rationale for this change `case_when_with_expr` has a code path to handle `null` values early on in the evaluation. It determines the presence of nulls using `value_array.null_count() > 0`. For nested arrays this may not be correct. `logical_null_count()` should be used instead. ## What changes are included in this PR? Check `logical_null_count` instead of `null_count`. ## Are these changes tested? Additional tests added to ensure the nested array case is tested. The test already passed before this change, but was a bit less efficient since the null values were tested for equality against each possible when value. ## Are there any user-facing changes? No
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
case_when_with_exprhas a code path to handlenullvalues early on in the evaluation. It determines the presence of nulls usingvalue_array.null_count() > 0. For nested arrays this may not be correct.logical_null_count()should be used instead.What changes are included in this PR?
Check
logical_null_countinstead ofnull_count.Are these changes tested?
Additional tests added to ensure the nested array case is tested. The test already passed before this change, but was a bit less efficient since the null values were tested for equality against each possible when value.
Are there any user-facing changes?
No