fix: retain unordered take semantics

This commit is contained in:
Gatefixer
2026-08-24 17:25:13 +00:00
parent 0eda8ac32c
commit d87d69c181
6 changed files with 131 additions and 49 deletions
+5 -5
View File
@@ -1489,9 +1489,9 @@ class Table(ABC):
Offsets are mostly useful for sampling as the set of all valid offsets is easily
known in advance to be [0, len(table)).
Results are returned in the same order as the given offsets. Repeated offsets
produce repeated rows, which makes this method suitable for sampling with
replacement.
No guarantees are made regarding the order in which results are returned.
Repeated offsets produce repeated rows, which makes this method suitable for
sampling with replacement.
Parameters
----------
@@ -6291,8 +6291,8 @@ class AsyncTable:
Offsets are mostly useful for sampling as the set of all valid offsets is easily
known in advance to be [0, len(table)).
Results are returned in the same order as the given offsets, including repeated
occurrences.
No guarantees are made regarding the order in which results are returned.
Repeated offsets produce repeated rows.
Parameters
----------
+4 -7
View File
@@ -1891,13 +1891,10 @@ def test_take_queries(tmp_path):
17,
]
# Duplicate offsets are occurrences, not set members, and preserve input order.
assert table.take_offsets([5, 2, 5, 17]).to_pandas()["idx"].to_list() == [
5,
2,
5,
17,
]
# Duplicate offsets are occurrences, not set members. Ordering is unspecified.
assert sorted(
table.take_offsets([5, 2, 5, 17]).to_pandas()["idx"].to_list()
) == [2, 5, 5, 17]
# Take by row id
assert list(
+1 -1
View File
@@ -510,8 +510,8 @@ def test_remote_permutation_is_picklable():
table = db.open_table("test")
assert table.take_offsets([0, 2, 0, 4]).to_list() == [
{"a": 0},
{"a": 2},
{"a": 0},
{"a": 2},
{"a": 4},
]