[SPARK-54698][SQL] Support hashing for all data types for array set like operations #53468
+198
−299
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.
What changes were proposed in this pull request?
Update all array set-like expressions to use hashing for all data types. Currently complex types and certain string collations fallback to a nested comparison loop that is O(n^2) for the size of the array, which can get really expensive for larger arrays. Instead, this borrows the idea from
InternalRowComparableWrapperand creates aGenericComparableWrapperthat works for any data type, usingMurmur3HashFunctionfor the hash code andInterpretedOrderingfor equals.Additionally, since there is just one code path for these expressions now, I moved the eval logic directly into the
nullSafeEvalfunction instead of keeping the transient function call.Why are the changes needed?
To improve performance of array set-like operations for complex types.
Does this PR introduce any user-facing change?
No, just performance improvement.
How was this patch tested?
Since there's no behavior change, existing tests should suffice, but I can add any additional ones if needed.
Was this patch authored or co-authored using generative AI tooling?
No