fix: implement Spark-compatible null handling for arrays_overlap#3674
Draft
andygrove wants to merge 1 commit intoapache:mainfrom
Draft
fix: implement Spark-compatible null handling for arrays_overlap#3674andygrove wants to merge 1 commit intoapache:mainfrom
andygrove wants to merge 1 commit intoapache:mainfrom
Conversation
Replace DataFusion's array_has_any (which treats NULL == NULL) with a custom implementation that follows Spark's three-valued logic: - true when arrays share a common non-null element - null when no common non-null elements but either array has nulls - false when no common elements and no nulls Closes apache#3645
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?
Closes #3645.
Rationale for this change
DataFusion's
array_has_anyfunction treatsNULL == NULL, soarrays_overlap(array(1, NULL), array(NULL, 2))incorrectly returnstrueinstead ofnull. This violates Spark's three-valued null semantics forarrays_overlap.What changes are included in this PR?
arrays_overlapimplementation in Rust (native/spark-expr/src/array_funcs/arrays_overlap.rs) that intercepts thearray_has_anyfunction name with correct null handling:truewhen arrays share a common non-null elementnullwhen no common non-null elements exist but either array contains nullsfalsewhen no common elements and no nullsHashSet<T::Native>) and strings (HashSet<&str>), with aScalarValuefallback for complex typesListArrayandLargeListArrayviaGenericListArray<O>ignoreannotations from previously-failing SQL testsHow are these changes tested?