You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on compute module stubs in #49201 I came across a buggy behavior of the top_k_unstable/bottom_k_unstable functions. Both compute functions can be called with Array/ChunkedArray or with RecordBatch/Table with different handling of the options.
For Array and ChunkedArray sort_keys shouldn't be accepted and should return ValueError with correct message but currently fails due to issues when appending to sort_keys:
As for the Table and RecordBatch, the signature suggests null_placements is optional but that errors with:
>>> pc.top_k_unstable(table, k=2, sort_keys=["a"])
...
File ~/Repos/arrow/python/pyarrow/compute.py:617, in top_k_unstable(values, k, sort_keys, null_placements, memory_pool)
614 sort_keys.append(("dummy", "descending", "at_end"))
615 else:
616 sort_keys = [(sort_key, "descending", null_placement)
--> 617 for sort_key, null_placement in zip(sort_keys, null_placements)]
618 options = SelectKOptions(k, sort_keys)
619 return call_function("select_k_unstable", [values], options, memory_pool)
TypeError: 'NoneType' object is not iterable
because zip does not accept None. To match C++, I suggest that null_placements to default to "at_end". Also, sort_keys and null_placements should be checked for being list-like (at least not str) and they should have the same length.
Activity