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
Rescoped to be just slice(). The other functions were implemented in ARROW-13766.
Original description:
Implement slice(), slice_head(), and slice_tail() methods for ArrowTabular, Dataset, and arrow_dplyr_query objects . I believe this should be relatively straightforward, using Take() to return only the specified rows. We already have a head() method which I believe we can reuse for slice_head().
Joris Van den Bossche / @jorisvandenbossche:
Just a note that there is also a C++ Table::Slice method that can already be directly used for this (not a compute kernel, though, but method on the Table). The pyarrow.Table.slice method uses that (
Neal Richardson / @nealrichardson:
I'm not sure about these (and about head/tail in general now) since dataset scans are no longer in deterministic order. How do dbplyr backends support these for databases that behave similarly?
since dataset scans are no longer in deterministic order
What do you mean exactly? (did something change recently? I thought the scans can have deterministic order if needed) For example the Scanner has a Head method to returns the first n rows (I would suppose this is deterministic?)
These are better written using slice_min(), though there has been some evolution around that + top_n() and the like. I've seen code like the above (with arrange + slice_head) a lot.
Weston Pace / @westonpace:
This has come up a few times and I think the resolution is always "we'll probably have to figure that out at some point" so I went ahead and sent something to the ML so we can have the conversation.
This issue has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this issue will be closed in 14 days. If this improvement is still desired but has no current owner, please add the 'Status: needs champion' label.
Activity
asfimport commentedon Aug 30, 2021
Joris Van den Bossche / @jorisvandenbossche:
Just a note that there is also a C++
Table::Slicemethod that can already be directly used for this (not a compute kernel, though, but method on the Table). Thepyarrow.Table.slicemethod uses that (arrow/python/pyarrow/table.pxi
Lines 1307 to 1334 in 26a34c3
asfimport commentedon Aug 30, 2021
Neal Richardson / @nealrichardson:
Right, we use Slice internally
asfimport commentedon Sep 20, 2021
Neal Richardson / @nealrichardson:
I'm not sure about these (and about head/tail in general now) since dataset scans are no longer in deterministic order. How do dbplyr backends support these for databases that behave similarly?
asfimport commentedon Sep 20, 2021
Joris Van den Bossche / @jorisvandenbossche:
What do you mean exactly? (did something change recently? I thought the scans can have deterministic order if needed) For example the Scanner has a
Headmethod to returns the first n rows (I would suppose this is deterministic?)asfimport commentedon Sep 20, 2021
Weston Pace / @westonpace:
This is an interesting question. The datasets API does have an ordered scan. This is used by the head method.
However, R has moved away from the datasets API and is using the exec plan directly now. The datasets API's ordering is not part of the exec plan.
asfimport commentedon Sep 20, 2021
Jonathan Keane / @jonkeane:
The dplyr docs say they "do not work with relational databases"
Though, IME, many real-world uses of
slice(),slice_head(),slice_tail()happen after an arrange:These are better written using
slice_min(), though there has been some evolution around that +top_n()and the like. I've seen code like the above (witharrange+slice_head) a lot.asfimport commentedon Sep 20, 2021
Weston Pace / @westonpace:
This has come up a few times and I think the resolution is always "we'll probably have to figure that out at some point" so I went ahead and sent something to the ML so we can have the conversation.
asfimport commentedon Feb 28, 2022
Vitalie Spinu:
This one turned to be a blocker for us during a conversion of a project from a SQL DB to arrow dataset.
How does one go with slicing within a group before this issue is fixed?
thisisnic commentedon Sep 23, 2026
This issue has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this issue will be closed in 14 days. If this improvement is still desired but has no current owner, please add the 'Status: needs champion' label.