Repository navigation
Conversation
…_k_unstable Passing sort_keys without null_placements for table-like input raised TypeError since apacheGH-38558 (apache#46926) added the null_placements parameter. Default every sort key to "at_end", as the array branch does, and use zip(strict=True) so mismatched lengths raise instead of silently dropping sort keys.
|
|
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.
Rationale for this change
pc.top_k_unstable(table, k, sort_keys)andpc.bottom_k_unstable(...)raiseTypeError: 'NoneType' object is not iterableon table-like input whennull_placementsis omitted. This has been the case since apache#46926 added theparameter (first released in 25.0.0).
What changes are included in this PR?
null_placementsisNone, use"at_end"for every sort key. Thismatches the array branch and the previous behavior.
zip(..., strict=True)so anull_placementslist whose length differsfrom
sort_keysraisesValueErrorinstead of silently dropping sort keys.null_placementsdocstring: optional, one entry per sort key,defaults to
"at_end".Are these changes tested?
Yes. There is a new parametrized test,
test_top_bottom_k_unstable_default_null_placements, for bothTableandRecordBatch. It covers the default placement, nulls sorting last, and thelength-mismatch error.
Are there any user-facing changes?
Yes. Calls that omit
null_placementswork again. Calls that pass anull_placementslist of a different length thansort_keysnow raiseValueError; before, they silently ignored the extra sort keys.top_k_unstable/bottom_k_unstableraise TypeError on tables whennull_placementsis omitted #66