Skip to content

[Python] top_k_unstable / bottom_k_unstable raise TypeError on tables when null_placements is omitted #66

Open

Description

@rok

Describe the bug, including details regarding any error messages, version, and platform.

Since pyarrow 25.0.0, calling pc.top_k_unstable or pc.bottom_k_unstable on a
Table or RecordBatch with sort_keys but without null_placements fails:

>>> import pyarrow as pa
>>> import pyarrow.compute as pc
>>> pc.bottom_k_unstable(pa.table({"a": [3, 1, 2]}), 2, ["a"])
Traceback (most recent call last):
  ...
TypeError: 'NoneType' object is not iterable

This worked before 25.0.0. The null_placements parameter was added in
apache#38558 (apache#46926), and the table-like branch now does
zip(sort_keys, null_placements) while null_placements defaults to None.
The array branch already uses "at_end", so the table branch should default to
"at_end" for every sort key too.

A related problem: if null_placements is shorter than sort_keys, zip
silently drops the extra sort keys.

Reproduced with pyarrow 26.0.1; the same code is on main.

Component(s)

Python

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions