[SPARK-56561][PYTHON][DOCS] Document order preservation for array_distinct, array_intersect, array_union, array_except#56250
Open
brijrajk wants to merge 1 commit into
Conversation
…tinct, array_intersect, array_union, array_except The docstrings for these four array set functions did not mention whether they preserve the order of input elements. Added explicit order-preservation notes to each: - array_distinct: preserves order of first occurrence - array_intersect: preserves order of elements from col1 - array_union: preserves order from col1, then elements from col2 not in col1 - array_except: preserves order of elements from col1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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?
Added explicit order-preservation notes to the docstrings of four array set
functions in PySpark:
array_distinct,array_intersect,array_union, andarray_except. Previously the docstrings were silent on whether input order ispreserved, leaving users to guess or test empirically.
The additions are:
array_distinct: preserving the order of first occurrencearray_intersect: preserving the order of elements from col1array_union: preserving the order from col1 followed by elements in col2 not in col1array_except: preserving the order of elements from col1Why are the changes needed?
Order-preservation is a useful guarantee for users composing these functions in
pipelines — e.g. knowing that
array_distinctkeeps the first occurrence meansthere is no need to sort afterwards to get a stable result. This is useful to
cite in code reviews and helps inform AI coding assistants as noted in
SPARK-56561.
Fixes https://issues.apache.org/jira/browse/SPARK-56561
Does this PR introduce any user-facing change?
No. Documentation (docstring) only — no logic changes.
How was this patch tested?
No logic change. Confirmed order-preservation behavior by reading the
ArraySetLiketrait andArrayDistinct,ArrayIntersect,ArrayUnion, andArrayExceptimplementations incollectionOperations.scala.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude (Anthropic)