[SPARK-55533][SQL] Support IGNORE NULLS / RESPECT NULLS for collect_set#54329
Open
yaooqinn wants to merge 1 commit intoapache:masterfrom
Open
[SPARK-55533][SQL] Support IGNORE NULLS / RESPECT NULLS for collect_set#54329yaooqinn wants to merge 1 commit intoapache:masterfrom
yaooqinn wants to merge 1 commit intoapache:masterfrom
Conversation
Currently, collect_list/array_agg supports IGNORE NULLS and RESPECT NULLS syntax (SPARK-55256), but collect_set does not. This PR adds the same support to collect_set: - collect_set(expr) — default, skips nulls (unchanged behavior) - collect_set(expr) IGNORE NULLS — explicitly skips nulls - collect_set(expr) RESPECT NULLS — includes null in the result set Implementation mirrors the existing CollectList pattern: - Added ignoreNulls parameter to CollectSet - Wired CollectSet into FunctionResolution.applyIgnoreNulls - Handled null safely in eval() for BinaryType Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3e8d94a to
579cb59
Compare
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.
What changes were proposed in this pull request?
This PR adds
IGNORE NULLS/RESPECT NULLSsupport tocollect_set, mirroring the existingcollect_listbehavior added in SPARK-55256.collect_set(expr)— default, skips nulls (unchanged behavior)collect_set(expr) IGNORE NULLS— explicitly skips nullscollect_set(expr) RESPECT NULLS— includes null in the result setWhy are the changes needed?
For consistency:
collect_list/array_aggalready supports this syntax, butcollect_setdoes not. Users who want to include null in collected sets currently have no way to do so.Does this PR introduce any user-facing change?
Yes.
collect_setnow acceptsIGNORE NULLSandRESPECT NULLSclauses in SQL.How was this patch tested?
Added 3 new tests in
DataFrameAggregateSuite:collect_set skips nulls by defaultcollect_set with IGNORE NULLS explicitly skips nullscollect_set with RESPECT NULLS preserves null in setWas this patch authored or co-authored using generative AI tooling?
Yes, co-authored with GitHub Copilot.