Skip to content

GH-66: [Python] Default null_placements to "at_end" in top_k_unstable/bottom_k_unstable - #67

Open
rok wants to merge 1 commit into
mainfrom
GH-66-top-k-null-placements
Open

rok wants to merge 1 commit into
mainfrom
GH-66-top-k-null-placements

Conversation

@rok

@rok rok commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Rationale for this change

pc.top_k_unstable(table, k, sort_keys) and pc.bottom_k_unstable(...) raise
TypeError: 'NoneType' object is not iterable on table-like input when
null_placements is omitted. This has been the case since apache#46926 added the
parameter (first released in 25.0.0).

What changes are included in this PR?

  • When null_placements is None, use "at_end" for every sort key. This
    matches the array branch and the previous behavior.
  • Use zip(..., strict=True) so a null_placements list whose length differs
    from sort_keys raises ValueError instead of silently dropping sort keys.
  • Clarify the null_placements docstring: 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 both Table and
RecordBatch. It covers the default placement, nulls sorting last, and the
length-mismatch error.

Are there any user-facing changes?

Yes. Calls that omit null_placements work again. Calls that pass a
null_placements list of a different length than sort_keys now raise
ValueError; before, they silently ignored the extra sort keys.

…_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.
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #66 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant