[C++][Compute] Fix null sorting of multiple sort keys
Describe the bug, including details regarding any error messages, version, and platform.
Currently, NullPlacement is a global control, and this parameter is used for all sortkeys. However, for databases like pg, it should be one for each sortkey, for example:
order by i nulls first, j, k nulls first;
code is
/// Column key(s) to order by and how to order by these sort keys.
std::vector<SortKey> sort_keys;
/// Whether nulls and NaNs are placed at the start or at the end
NullPlacement null_placement;
Component(s)
C++
So the NullPlacement should support being std::vector<NullPlacement> ?
How about moving NullPlacement to SortKey?
So the
NullPlacementshould support beingstd::vector<NullPlacement>?
yes.
How about moving
NullPlacementtoSortKey? In this case, it's better
If no one does it, I can try to implement it
Also cc @bkietz @ianmcook for some info here
https://github.com/apache/arrow-rs/blob/829708d4911bc0798ca2a388cd7df20478a4cc08/arrow-schema/src/lib.rs#L37
Seems that maybe this is better. But waiting for others idea for compability
when sorting multiple columns, rust also allows per-column null placement https://github.com/apache/arrow-rs/blob/1807abace4153cbfd287ee830f86ebaeeae50234/arrow-ord/src/sort.rs#L611
Seems reasonable to support in c++
It has been implemented, I will send a PR later, haha
I saw a comment about difficulties with sorting for multiple batches (ChunkedArray, Table), but it looks like you've solved it. lol
I'm interested in this issue because I'm interested in sorting for DictionaryType in multiple batches.
I found that the NullPlacement in the selectk scenario is all hard-coded AtEnd. It should also be modified correctly. Take this opportunity to apply it to each SortKey.
related issue: OrderBy SelectK does not display non-empty results
Issue resolved by pull request 46926 https://github.com/apache/arrow/pull/46926
Great! Thanks @pitrou!